Skip to content

Commit

Permalink
common: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
phymbert committed Mar 16, 2024
1 parent 1ddaf71 commit 73b4b44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,31 +103,21 @@ jobs:
with:
fetch-depth: 0

- name: Download libCURL
- name: libCURL
id: get_libcurl
env:
CURL_TAG: 8_6_0
CURL_VERSION: 8.6.0
CURL_VERSION: 8.6.0_6
run: |
curl.exe -o $env:RUNNER_TEMP/libcurl.tar.gz -L "https://github.com/curl/curl/releases/download/curl-${env:CURL_TAG}/curl-${env:CURL_VERSION}.tar.gz"
curl.exe -o $env:RUNNER_TEMP/curl.zip -L "https://curl.se/windows/dl-${env:CURL_VERSION}/curl-${env:CURL_VERSION}-win64-mingw.zip"
mkdir $env:RUNNER_TEMP/libcurl
tar.exe -xvf $env:RUNNER_TEMP/libcurl.tar.gz --strip-components=1 -C $env:RUNNER_TEMP/libcurl
- name: Build libcurl
id: build_libcurl
run: |
cd $env:RUNNER_TEMP/libcurl
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
tar.exe -xvf $env:RUNNER_TEMP/curl.zip --strip-components=1 -C $env:RUNNER_TEMP/libcurl
- name: Build
id: cmake_build
run: |
mkdir build
cd build
cmake .. -DLLAMA_CURL=ON -DCURL_LIBRARY="${env:RUNNER_TEMP}/libcurl/lib/Release/libcurl_imp.lib" -DCURL_INCLUDE_DIR="${env:RUNNER_TEMP}/libcurl/include" -DLLAMA_BUILD_SERVER=ON -DLLAMA_NATIVE=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
cmake .. -DLLAMA_CURL=ON -DCURL_LIBRARY="$env:RUNNER_TEMP/libcurl/lib" -DCURL_INCLUDE_DIR="$env:RUNNER_TEMP/libcurl/include" -DLLAMA_BUILD_SERVER=ON -DLLAMA_NATIVE=OFF -DBUILD_SHARED_LIBS=ON
cmake --build . --config Release -j ${env:NUMBER_OF_PROCESSORS} --target server
- name: Python setup
Expand Down
17 changes: 8 additions & 9 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ if (BUILD_SHARED_LIBS)
endif()


# Check for curl
if (LLAMA_CURL)
find_package(CURL)
add_definitions(-DLLAMA_USE_CURL)
include_directories(${CURL_INCLUDE_DIRS})
link_libraries(${CURL_LIBRARIES})
endif ()


set(TARGET common)

add_library(${TARGET} STATIC
Expand All @@ -80,3 +71,11 @@ endif()
target_include_directories(${TARGET} PUBLIC .)
target_compile_features(${TARGET} PUBLIC cxx_std_11)
target_link_libraries(${TARGET} PRIVATE build_info PUBLIC llama)

# Use curl to download model url
if (LLAMA_CURL)
find_package(CURL)
add_definitions(-DLLAMA_USE_CURL)
target_include_directories(${TARGET} ${CURL_INCLUDE_DIRS})
target_link_libraries(${TARGET} PRIVATE curl)
endif ()
4 changes: 2 additions & 2 deletions common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1710,13 +1710,13 @@ struct llama_model * llama_load_model_from_url(const char * model_url, const cha

const char * etag_prefix = "etag: ";
if (strncmp(buffer, etag_prefix, strlen(etag_prefix)) == 0) {
strncpy(headers->etag, buffer + strlen(etag_prefix), n_items - strlen(etag_prefix) - 2); // Remove LRLF
strncpy(headers->etag, buffer + strlen(etag_prefix), n_items - strlen(etag_prefix) - 2); // Remove CRLF
}

const char * last_modified_prefix = "last-modified: ";
if (strncmp(buffer, last_modified_prefix, strlen(last_modified_prefix)) == 0) {
strncpy(headers->last_modified, buffer + strlen(last_modified_prefix),
n_items - strlen(last_modified_prefix) - 2); // Remove LRLF
n_items - strlen(last_modified_prefix) - 2); // Remove CRLF
}
return n_items;
};
Expand Down

0 comments on commit 73b4b44

Please sign in to comment.