#!/bin/bash ## Patches ## Apply the base `patches/` series (top-level *.patch only; *.md/dirs skipped). ## The stock llama-cpp backend is patch-free by default, so this normally does ## nothing. The Makefile `llama.cpp` target already `git apply`s any base patch ## at checkout, so each apply here is `-N` (skip already-applied): re-applying a ## git-format patch with `patch` would fuzzily duplicate hunks. This block only ## does real work if prepare.sh is run against an unpatched checkout. if [ -d "patches" ]; then for patch in patches/*.patch; do [ -e "$patch" ] || continue echo "Applying patch $patch" patch -d llama.cpp/ -p1 -N -r - < "$patch" || true done fi set -e for file in $(ls llama.cpp/tools/server/); do cp -rfv llama.cpp/tools/server/$file llama.cpp/tools/grpc-server/ done cp -r CMakeLists.txt llama.cpp/tools/grpc-server/ cp -r grpc-server.cpp llama.cpp/tools/grpc-server/ # Shared message-reconstruction helpers (included by grpc-server.cpp) and their # unit test (compiled only when -DLLAMA_GRPC_BUILD_TESTS=ON). cp -r message_content.h llama.cpp/tools/grpc-server/ cp -r message_content_test.cpp llama.cpp/tools/grpc-server/ cp -rfv llama.cpp/vendor/nlohmann/json.hpp llama.cpp/tools/grpc-server/ cp -rfv llama.cpp/vendor/cpp-httplib/httplib.h llama.cpp/tools/grpc-server/ set +e if grep -q "grpc-server" llama.cpp/tools/CMakeLists.txt; then echo "grpc-server already added" else echo "add_subdirectory(grpc-server)" >> llama.cpp/tools/CMakeLists.txt fi set -e