gen_common.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. # common logic accross linux and darwin
  2. init_vars() {
  3. PATCHES="0001-Expose-callable-API-for-server.patch"
  4. CMAKE_DEFS="-DLLAMA_ACCELERATE=on"
  5. # TODO - LLAMA_K_QUANTS is stale and needs to be mapped to newer cmake settings
  6. CMAKE_TARGETS="--target ggml --target ggml_static --target llama --target build_info --target common --target ext_server"
  7. if echo "${CGO_CFLAGS}" | grep -- '-g' > /dev/null ; then
  8. CMAKE_DEFS="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_VERBOSE_MAKEFILE=on -DLLAMA_GPROF=on ${CMAKE_DEFS}"
  9. else
  10. # TODO - add additional optimization flags...
  11. CMAKE_DEFS="-DCMAKE_BUILD_TYPE=Release ${CMAKE_DEFS}"
  12. fi
  13. }
  14. git_module_setup() {
  15. # TODO add flags to skip the init/patch logic to make it easier to mod llama.cpp code in-repo
  16. git submodule init
  17. git submodule update --force gguf
  18. }
  19. apply_patches() {
  20. # Workaround git apply not handling creation well for iteration
  21. rm -f gguf/examples/server/server.h
  22. for patch in ${PATCHES} ; do
  23. git -C gguf apply ../patches/${patch}
  24. done
  25. }
  26. build() {
  27. cmake -S gguf -B ${BUILD_DIR} ${CMAKE_DEFS}
  28. cmake --build ${BUILD_DIR} ${CMAKE_TARGETS} -j8
  29. }