diff options
author | Olivier Chafik <ochafik@users.noreply.github.com> | 2024-04-21 18:48:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 18:48:53 +0100 |
commit | 5cf5e7d490dfdd2e70bface2d35dfd14aa44b4fb (patch) | |
tree | 9af269d3fa30667bbaefc6978db94013d68b3f22 /examples/server/CMakeLists.txt | |
parent | 40f74e4d739e9250431cf339ae7588b28d8d0663 (diff) |
`build`: generate hex dump of server assets during build (#6661)
* `build`: generate hex dumps of server assets on the fly
* build: workaround lack of -n on gnu xxd
* build: don't use xxd in cmake
* build: don't call xxd from build.zig
* build: more idiomatic hexing
* build: don't use xxd in Makefile (od hackery instead)
* build: avoid exceeding max cmd line limit in makefile hex dump
* build: hex dump assets at cmake build time (not config time)
Diffstat (limited to 'examples/server/CMakeLists.txt')
-rw-r--r-- | examples/server/CMakeLists.txt | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/examples/server/CMakeLists.txt b/examples/server/CMakeLists.txt index 61f58417..4b89c530 100644 --- a/examples/server/CMakeLists.txt +++ b/examples/server/CMakeLists.txt @@ -1,12 +1,29 @@ set(TARGET server) option(LLAMA_SERVER_VERBOSE "Build verbose logging option for Server" ON) option(LLAMA_SERVER_SSL "Build SSL support for the server" OFF) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -add_executable(${TARGET} +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +set(TARGET_SRCS server.cpp utils.hpp httplib.h ) +set(PUBLIC_ASSETS + index.html + index.js + completion.js + json-schema-to-grammar.mjs +) +foreach(asset ${PUBLIC_ASSETS}) + set(input "${CMAKE_CURRENT_SOURCE_DIR}/public/${asset}") + set(output "${CMAKE_CURRENT_BINARY_DIR}/${asset}.hpp") + list(APPEND TARGET_SRCS ${output}) + add_custom_command( + DEPENDS "${input}" + OUTPUT "${output}" + COMMAND "${CMAKE_COMMAND}" "-DINPUT=${input}" "-DOUTPUT=${output}" -P "${PROJECT_SOURCE_DIR}/scripts/xxd.cmake" + ) +endforeach() +add_executable(${TARGET} ${TARGET_SRCS}) install(TARGETS ${TARGET} RUNTIME) target_compile_definitions(${TARGET} PRIVATE SERVER_VERBOSE=$<BOOL:${LLAMA_SERVER_VERBOSE}> |