From 73b4b44785d803e3c74e97bdea59d230a94f3ed1 Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Sun, 17 Mar 2024 00:43:35 +0100 Subject: [PATCH] common: fix build --- .github/workflows/server.yml | 20 +++++--------------- common/CMakeLists.txt | 17 ++++++++--------- common/common.cpp | 4 ++-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index d0458629a..bb321aa1c 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -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 diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index c8a21a9c2..3beda6d25 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -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 @@ -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 () diff --git a/common/common.cpp b/common/common.cpp index 007424fd9..77b8f1d7c 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -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; };