|
@@ -3,6 +3,7 @@
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
function init_vars {
|
|
|
+ $script:llamacppDir = "../llama.cpp"
|
|
|
$script:patches = @("0001-Expose-callable-API-for-server.patch")
|
|
|
$script:cmakeDefs = @("-DBUILD_SHARED_LIBS=on", "-DLLAMA_NATIVE=off", "-DLLAMA_F16C=off", "-DLLAMA_FMA=off", "-DLLAMA_AVX512=off", "-DLLAMA_AVX2=off", "-DLLAMA_AVX=on", "-A","x64")
|
|
|
$script:cmakeTargets = @("ggml", "ggml_static", "llama", "build_info", "common", "ext_server_shared", "llava_static")
|
|
@@ -19,25 +20,25 @@ function git_module_setup {
|
|
|
# TODO add flags to skip the init/patch logic to make it easier to mod llama.cpp code in-repo
|
|
|
& git submodule init
|
|
|
if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)}
|
|
|
- & git submodule update --force gguf
|
|
|
+ & git submodule update --force "${script:llamacppDir}"
|
|
|
if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)}
|
|
|
}
|
|
|
|
|
|
function apply_patches {
|
|
|
# Wire up our CMakefile
|
|
|
- if (!(Select-String -Path "gguf/examples/server/CMakeLists.txt" -Pattern 'ollama')) {
|
|
|
- Add-Content -Path "gguf/examples/server/CMakeLists.txt" -Value 'include (../../../CMakeLists.txt) # ollama'
|
|
|
+ if (!(Select-String -Path "${script:llamacppDir}/examples/server/CMakeLists.txt" -Pattern 'ollama')) {
|
|
|
+ Add-Content -Path "${script:llamacppDir}/examples/server/CMakeLists.txt" -Value 'include (../../../ext_server/CMakeLists.txt) # ollama'
|
|
|
}
|
|
|
# Avoid duplicate main symbols when we link into the cgo binary
|
|
|
- $content = Get-Content -Path "./gguf/examples/server/server.cpp"
|
|
|
+ $content = Get-Content -Path "${script:llamacppDir}/examples/server/server.cpp"
|
|
|
$content = $content -replace 'int main\(', 'int __main('
|
|
|
- Set-Content -Path "./gguf/examples/server/server.cpp" -Value $content
|
|
|
+ Set-Content -Path "${script:llamacppDir}/examples/server/server.cpp" -Value $content
|
|
|
}
|
|
|
|
|
|
function build {
|
|
|
- write-host "generating config with: cmake -S gguf -B $script:buildDir $script:cmakeDefs"
|
|
|
+ write-host "generating config with: cmake -S ${script:llamacppDir} -B $script:buildDir $script:cmakeDefs"
|
|
|
& cmake --version
|
|
|
- & cmake -S gguf -B $script:buildDir $script:cmakeDefs
|
|
|
+ & cmake -S "${script:llamacppDir}" -B $script:buildDir $script:cmakeDefs
|
|
|
if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)}
|
|
|
write-host "building with: cmake --build $script:buildDir --config $script:config ($script:cmakeTargets | ForEach-Object { "--target", $_ })"
|
|
|
& cmake --build $script:buildDir --config $script:config ($script:cmakeTargets | ForEach-Object { "--target", $_ })
|
|
@@ -55,7 +56,7 @@ function install {
|
|
|
}
|
|
|
|
|
|
function cleanup {
|
|
|
- Set-Location "gguf/examples/server"
|
|
|
+ Set-Location "${script:llamacppDir}/examples/server"
|
|
|
git checkout CMakeLists.txt server.cpp
|
|
|
}
|
|
|
|
|
@@ -64,20 +65,20 @@ git_module_setup
|
|
|
apply_patches
|
|
|
|
|
|
# first build CPU based
|
|
|
-$script:buildDir="gguf/build/windows/cpu"
|
|
|
+$script:buildDir="${script:llamacppDir}/build/windows/cpu"
|
|
|
|
|
|
build
|
|
|
install
|
|
|
|
|
|
# Then build cuda as a dynamically loaded library
|
|
|
init_vars
|
|
|
-$script:buildDir="gguf/build/windows/cuda"
|
|
|
+$script:buildDir="${script:llamacppDir}/build/windows/cuda"
|
|
|
$script:cmakeDefs += @("-DLLAMA_CUBLAS=ON")
|
|
|
build
|
|
|
install
|
|
|
|
|
|
# TODO - actually implement ROCm support on windows
|
|
|
-$script:buildDir="gguf/build/windows/rocm"
|
|
|
+$script:buildDir="${script:llamacppDir}/build/windows/rocm"
|
|
|
|
|
|
rm -ea 0 -recurse -force -path "${script:buildDir}/lib"
|
|
|
md "${script:buildDir}/lib" -ea 0 > $null
|