vinix-ports / llvm19-dev / PKGBUILD.vile
58 lines · 57 sloc · 3.56 KB · 7ade13dc423b299a96fab74b2246566225fc7db2
Raw
1checkpoint := get-environment-variable("VINIX_LLVM_BUILD")
2reuse := if string?(checkpoint) { not(string=?("", checkpoint)) } else { #f }
3build-dir := if reuse { checkpoint } else { "build" }
4sdk := get-environment-variable("VPAC_MAKEPKG_ROOT")
5
6defpkgbuild(llvm19-dev,
7 #:pkgname, "llvm19-dev",
8 #:pkgver, "19.1.4",
9 #:pkgrel, 1,
10 #:pkgdesc, "LLVM headers and configuration utility for Mesa (LLVM 19)",
11 #:arch, [#:x86-64, #:aarch64],
12 #:license, "Apache-2.0 WITH LLVM-exception",
13 #:url, "https://llvm.org/",
14 #:depends, ["llvm19-libs=19.1.4-2"],
15 #:makedepends, ["linux-headers"],
16 #:source, if reuse { list() } else { ["llvm-project-19.1.4.src.xz::https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.4/llvm-project-19.1.4.src.tar.xz",
17 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/fix-memory-mf_exec-on-aarch64.patch",
18 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/llvm19/llvm-stack-size.patch"] },
19 #:sha256sums, if reuse { list() } else { ["3aa2d2d2c7553164ad5c6f3b932b31816e422635e18620c9349a7da95b98d811",
20 "0163a3cf492b5d0b91cafc142a6ac4f1333c65bc52e627bbccbf3ad927f8d527",
21 "3cacabc5c9b540c6240c063f8d9eca64c0f0d955ffec86bafc04d5f9bd986d78"] },
22 #:prepare, fn() {
23 if reuse {
24 ; Use only the tree whose library is the installed runtime from this feed.
25 normalized := string-append(srcdir(), "/llvm-runtime-check")
26 run("env", string-append("DESTDIR=", normalized), "cmake", "--install", build-dir, "--component", "LLVM", "--prefix", "/usr")
27 run("cmp", string-append(normalized, "/usr/lib/libLLVM.so.19.1"),
28 string-append(sdk, "/usr/lib/libLLVM.so.19.1"))
29 run("rm", "-r", "--", normalized)
30 run("test", "-s", string-append(build-dir, "/CMakeCache.txt"))
31 } else {
32 ; LLVM's release archive also contains Clang, LLDB and other independent projects.
33 run("tar", "-xf", "llvm-project-19.1.4.src.xz", "llvm-project-19.1.4.src/llvm", "llvm-project-19.1.4.src/cmake", "llvm-project-19.1.4.src/third-party")
34 for-each(fn(patch) { run("patch", "--batch", "--fuzz=0", "-d", "llvm-project-19.1.4.src", "-p1", "-i", string-append("../", patch)) },
35 list("fix-memory-mf_exec-on-aarch64.patch", "llvm-stack-size.patch"))
36 }
37 },
38 #:build, fn() {
39 if not(reuse) {
40 run("vinix-llvm", "19.1.4", "llvm-project-19.1.4.src/llvm", build-dir)
41 }
42 run("vinix-ninja", build-dir, "llvm-headers", "llvm-config")
43 },
44 #:check, fn() {
45 run("vinix-run", string-append(build-dir, "/bin/llvm-config"), "--version")
46 run("test", "-s", string-append(build-dir, "/include/llvm/Config/llvm-config.h"))
47 },
48 #:package, fn() {
49 run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-headers")
50 run("env", string-append("DESTDIR=", pkgdir()), "cmake", "--install", build-dir, "--component", "llvm-config", "--prefix", "/usr/lib/llvm19")
51 run("mkdir", "-p", string-append(pkgdir(), "/usr/bin"), string-append(pkgdir(), "/usr/lib/llvm19/lib"))
52 run("ln", "-s", "../lib/llvm19/bin/llvm-config", string-append(pkgdir(), "/usr/bin/llvm-config-19"))
53 for-each(fn(soname) {
54 run("ln", "-s", "../../libLLVM.so.19.1", string-append(pkgdir(), "/usr/lib/llvm19/lib/", soname))
55 }, list("libLLVM.so.19.1", "libLLVM-19.so", "libLLVM.so"))
56 run("install", "-Dm644", string-append(sdk, "/usr/share/licenses/llvm19-libs/LICENSE.TXT"),
57 string-append(pkgdir(), "/usr/share/licenses/llvm19-dev/LICENSE.TXT"))
58 })
59