gen_windows.ps1 1.59 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!powershell

$ErrorActionPreference = "Stop"

function init_vars {
    $script:buildDir="gguf/build/wincuda"
    $script:installDir="gguf/build/wincuda/dist"
    $script:patches = @("0001-Expose-callable-API-for-server.patch")
    $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")

    if ($env:CGO_CFLAGS -contains "-g") {
        $script:cmakeDefs += @("-DCMAKE_VERBOSE_MAKEFILE=on")
        $script:config += "RelWithDebInfo"
    } else {
        $script:config += "Release"
    }
}

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
    & git submodule update --force gguf
}

function apply_patches {
    rm -erroraction ignore -path "gguf/examples/server/server.h"
    foreach ($patch in $patches) {
        write-host "Applying patch $patch"
        & git -C gguf apply ../patches/$patch
    }
}

function build {
    write-host "generating config with: cmake -S gguf -B $buildDir $cmakeDefs"
    & cmake --version
    & cmake -S gguf -B $buildDir $cmakeDefs
    write-host "building with: cmake --build $buildDir --config $config"
    & cmake --build $buildDir --config $config
}

function install {
    rm -erroraction ignore -recurse -force -path $installDir
    & cmake --install $buildDir --prefix $installDir --config $config

}

init_vars
git_module_setup
apply_patches
build
install