# Mesa 24.0.9 — LLVMPIPE (render por software CON LLVM JIT). Variante de mesa-swrast (softpipe) para
# el escritorio KDE en VM: kwin exige un GBM/EGL de software COMPLETO, y softpipe no bindea las
# extensiones que kwin pide ("failed to bind extensions" → "Failed to create gbm device"). llvmpipe
# (el driver `swrast` de gallium cuando `-Dllvm=enabled`) sí las provee. Ver [[kde-metal-qemu-desktop]].
#
# La ÚNICA diferencia con mesa-swrast.toml es `-Dllvm=enabled` (+ el toolchain LLVM en el sandbox).
# Si el sandbox no trae libLLVM/llvm-config, este build falla en configure ⇒ hay que sellar LLVM
# desde fuente primero (el monstruo). Test primero, decidir después.
name    = "mesa-llvmpipe"
version = "24.0.9"

[source]
tarball = "https://archive.mesa3d.org/mesa-24.0.9.tar.xz"
sha256  = "51aa686ca4060e38711a9e8f60c8f1efaa516baf411946ed7f2c265cd582ca4c"
patches = ["mesa-version-script-comma.patch"]

[build]
compiler    = "zig-cc"
target      = "x86_64-linux-musl"
link        = "dynamic"
zig_version = "0.13.0"

[build.phases]
configure = "CC=gcc CXX=g++ LLVM_CONFIG=/usr/bin/llvm-config PYTHONPATH=/usr/lib/python3.12/site-packages meson setup output --prefix=/usr --buildtype=release -Db_ndebug=true -Dgallium-drivers=swrast -Dvulkan-drivers= -Dllvm=enabled -Dshared-llvm=enabled -Dintel-clc=disabled -Dplatforms=wayland -Dglx=disabled -Dgbm=enabled -Degl=enabled -Dopengl=true -Dgles1=disabled -Dgles2=enabled -Dexpat=enabled -Dzstd=enabled -Dshader-cache=enabled -Dxmlconfig=enabled -Dglvnd=false -Dgallium-rusticl=false -Dgallium-va=disabled -Dgallium-extra-hud=false -Dvideo-codecs= -Dtools= -Dbuild-tests=false -Dvalgrind=disabled -Dlibunwind=disabled"
compile   = "PYTHONPATH=/usr/lib/python3.12/site-packages ninja -C output"
install   = "DESTDIR=/out ninja -C output install"

[deps]
# llvm18: el libLLVM hammer-built (soberano) que llvmpipe JIT-linkea. hammer lo materializa en el
# sandbox en /usr ⇒ /usr/bin/llvm-config es el de LLVM 18 (no el LLVM 22 de Alpine, que mesa 24.0.9
# no traga). Runtime: libLLVM.so.18 se inyecta a la imagen QEMU (NEEDED sólo libc por -static-libstdc++).
build = ["llvm18", "meson", "samurai", "python3", "pkgconf", "flex", "bison", "mako", "markupsafe", "packaging", "libdrm", "wayland", "wayland-protocols", "expat", "zlib", "zstd", "libffi"]
