summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0c63db54dd3915ac496dc21d8dc6eefecfcaa600 (plain)
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
52
53
54
55
56
57
pkgname=stable-diffusion.cpp-vulkan-git
pkgver=r156.ac54e00
pkgrel=1
pkgdesc="Stable Diffusion and Flux in pure C/C++ (Vulkan version)"
license=("MIT")
depends=("gcc-libs" "glibc" "vulkan-icd-loader")
makedepends=("cmake" "git" "vulkan-headers" "shaderc")
arch=("x86_64")
url="https://github.com/leejet/stable-diffusion.cpp"
provides=("stable-diffusion.cpp")
conflicts=("stable-diffusion.cpp")
source=("git+https://github.com/leejet/stable-diffusion.cpp.git"
        "git+https://github.com/ggerganov/ggml.git"
        "001-fix-shared-lib-install.diff")
sha256sums=('SKIP'
            'SKIP'
            '24954814b385350ca52e7ee5b29f89e66ade873aadb27cd302bfa6ce50ef11a3')

prepare() {
    cd "$srcdir/stable-diffusion.cpp"
    git submodule init
    git config submodule.ggml.url "$srcdir/ggml"
    git -c protocol.file.allow=always submodule update
    git apply ../001-fix-shared-lib-install.diff
}

pkgver() {
    cd "$srcdir/stable-diffusion.cpp"
    echo "r$(git rev-list --count HEAD).$(git rev-parse --short=7 HEAD)"
}

build() {
    CFLAGS+=" -DNDEBUG"
    CXXFLAGS+=" -DNDEBUG"
    cmake -B build-vulkan -S stable-diffusion.cpp \
        -DCMAKE_BUILD_TYPE=None \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DSD_CUBLAS=OFF \
        -DSD_HIPBLAS=OFF \
        -DSD_METAL=OFF \
        -DSD_VULKAN=ON \
        -DSD_SYCL=OFF \
        -DSD_FLASH_ATTN=ON \
        -DSD_FAST_SOFTMAX=OFF \
        -DSD_BUILD_SHARED_LIBS=ON
    cmake --build build-vulkan
}

package() {
    DESTDIR="$pkgdir" cmake --install build-vulkan
    install -Dm644 stable-diffusion.cpp/LICENSE \
        "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
    # Remove ggml contents
    rm -r "$pkgdir/usr/bin/vulkan-shaders-gen" \
          "$pkgdir/usr/include" \
          "$pkgdir/usr/lib/libggml.a"
}