gen_windows.ps1 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!powershell
  2. $ErrorActionPreference = "Stop"
  3. function init_vars {
  4. $script:buildDir="gguf/build/wincuda"
  5. $script:installDir="gguf/build/wincuda/dist"
  6. $script:patches = @("0001-Expose-callable-API-for-server.patch")
  7. $script:cmakeDefs = @("-DLLAMA_NATIVE=off", "-DLLAMA_F16C=off", "-DLLAMA_FMA=off", "-DLLAMA_AVX512=off", "-DLLAMA_AVX2=off", "-DLLAMA_AVX=on", "-DLLAMA_K_QUANTS=on", "-DLLAMA_ACCELERATE=on", "-DLLAMA_CUBLAS=ON","-DCMAKE_VERBOSE_MAKEFILE=ON","-DBUILD_SHARED_LIBS=on","-A","x64")
  8. if ($env:CGO_CFLAGS -contains "-g") {
  9. $script:cmakeDefs += @("-DCMAKE_VERBOSE_MAKEFILE=on")
  10. $script:config += "RelWithDebInfo"
  11. } else {
  12. $script:config += "Release"
  13. }
  14. }
  15. function git_module_setup {
  16. # TODO add flags to skip the init/patch logic to make it easier to mod llama.cpp code in-repo
  17. & git submodule init
  18. & git submodule update --force gguf
  19. }
  20. function apply_patches {
  21. rm -erroraction ignore -path "gguf/examples/server/server.h"
  22. foreach ($patch in $patches) {
  23. write-host "Applying patch $patch"
  24. & git -C gguf apply ../patches/$patch
  25. }
  26. }
  27. function build {
  28. write-host "generating config with: cmake -S gguf -B $buildDir $cmakeDefs"
  29. & cmake --version
  30. & cmake -S gguf -B $buildDir $cmakeDefs
  31. write-host "building with: cmake --build $buildDir --config $config"
  32. & cmake --build $buildDir --config $config
  33. }
  34. function install {
  35. rm -erroraction ignore -recurse -force -path $installDir
  36. & cmake --install $buildDir --prefix $installDir --config $config
  37. }
  38. init_vars
  39. git_module_setup
  40. apply_patches
  41. build
  42. install