Skip to content

Commit 0070a11

Browse files
committed
scripts: add build-mesa & build-spirv-tools
1 parent d56af3e commit 0070a11

5 files changed

Lines changed: 115 additions & 0 deletions

File tree

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ CMAKE_POLICY_VERSION_MINIMUM="4.1"
99
MACOSX_DEPLOYMENT_TARGET="${MACOSX_DEPLOYMENT_TARGET:-26.2}"
1010
CFLAGS="-mcpu=native"
1111
CXXFLAGS="${CFLAGS}"
12+
PYTHONPATH="${PWD}/src/python"
13+
PIP_TARGET="${PYTHONPATH}"

build-mesa

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash -e
2+
#
3+
# Mesa
4+
# https://gitlab.freedesktop.org/mesa/mesa.git
5+
#
6+
# Homebrew dependencies:
7+
# libclc spirv-llvm-translator
8+
#
9+
# Local dependencies:
10+
# spirv-tools
11+
#
12+
cd "$(dirname "$0")"
13+
set -a; . .env; set +a
14+
15+
pkgname="mesa"
16+
pkgdir="${STOWDIR}/${pkgname}"
17+
srcdir="src/mesa"
18+
builddir="${TMPDIR:-/tmp}/build.${pkgname}"
19+
20+
echo "::group::$0"
21+
22+
rm -rf "${builddir}"
23+
24+
meson setup "${builddir}" "${srcdir}" \
25+
--prefix="${pkgdir}" \
26+
--native-file=meson/native/llvm.ini \
27+
-Dwrap_mode=nodownload \
28+
-Dbuildtype=release \
29+
-Dplatforms=macos \
30+
-Dvulkan-drivers=kosmickrisp \
31+
-Dvulkan-icd-dir="${pkgdir}/etc/vulkan/icd.d" \
32+
-Dgallium-drivers=[] \
33+
-Dvideo-codecs=all \
34+
-Dopengl=false \
35+
-Dgles1=disabled \
36+
-Dgles2=disabled \
37+
-Dglx=disabled \
38+
-Dxmlconfig=disabled \
39+
-Dzstd=disabled \
40+
"$@"
41+
42+
meson compile -C "${builddir}"
43+
44+
rm -rf "${pkgdir}"
45+
46+
meson install -C "${builddir}"
47+
stow -Rd "${STOWDIR}" "${pkgname}"
48+
49+
rm -rf "${builddir}"
50+
51+
echo "::endgroup::"

build-spirv-tools

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash -e
2+
#
3+
# SPIRV-Tools
4+
# https://github.com/KhronosGroup/SPIRV-Tools.git
5+
#
6+
cd "$(dirname "$0")"
7+
set -a; . .env; set +a
8+
9+
pkgname="spirv-tools"
10+
pkgdir="${STOWDIR}/${pkgname}"
11+
srcdir="src/SPIRV-Tools"
12+
builddir="${TMPDIR:-/tmp}/build.${pkgname}"
13+
14+
echo "::group::$0"
15+
16+
rm -rf "${builddir}"
17+
18+
cmake -B "${builddir}" -S "${srcdir}" \
19+
-DCMAKE_INSTALL_PREFIX="${pkgdir}" \
20+
-DCMAKE_INSTALL_NAME_DIR="${pkgdir}/lib" \
21+
-DCMAKE_BUILD_TYPE=Release \
22+
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
23+
-DBUILD_SHARED_LIBS=OFF \
24+
-DSPIRV_SKIP_EXECUTABLES=ON \
25+
-DSPIRV_SKIP_TESTS=ON \
26+
"$@"
27+
28+
cmake --build "${builddir}"
29+
30+
rm -rf "${pkgdir}"
31+
32+
cmake --install "${builddir}"
33+
rm -rf "${pkgdir}"/lib/cmake
34+
stow -Rd "${STOWDIR}" "${pkgname}"
35+
36+
rm -rf "${builddir}"
37+
38+
echo "::endgroup::"

fetch

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash -e
22

33
cd "$(dirname "$0")"
4+
set -a; . .env; set +a
45

56
print_usage() {
67
echo "Usage:"
@@ -133,6 +134,13 @@ fetch_luajit() {
133134
git -C src clone --depth 1 "${url}"
134135
}
135136

137+
fetch_mesa() {
138+
local url="https://gitlab.freedesktop.org/mesa/mesa.git"
139+
rm -rf src/mesa
140+
git -C src clone --depth 1 "${url}"
141+
pip3 install --no-cache-dir -U mako packaging pyyaml
142+
}
143+
136144
fetch_moltenvk() {
137145
local url="https://github.com/KhronosGroup/MoltenVK.git"
138146
rm -rf src/MoltenVK
@@ -164,6 +172,14 @@ fetch_shaderc() {
164172
git -C src clone --depth 1 "${url}"
165173
}
166174

175+
fetch_spirv-tools() {
176+
local toolsurl="https://github.com/KhronosGroup/SPIRV-Tools.git"
177+
local headersurl="https://github.com/KhronosGroup/SPIRV-Headers.git"
178+
rm -rf src/SPIRV-Tools
179+
git -C src clone --depth 1 "${toolsurl}"
180+
git -C src clone --depth 1 "${headersurl}" SPIRV-Tools/external/spirv-headers
181+
}
182+
167183
fetch_svt-av1() {
168184
local url="https://gitlab.com/AOMediaCodec/SVT-AV1.git"
169185
rm -rf src/SVT-AV1
@@ -300,6 +316,9 @@ else
300316
"luajit")
301317
fetch_luajit
302318
;;
319+
"mesa")
320+
fetch_mesa
321+
;;
303322
"moltenvk")
304323
fetch_moltenvk
305324
;;
@@ -312,6 +331,9 @@ else
312331
"shaderc")
313332
fetch_shaderc
314333
;;
334+
"spirv-tools")
335+
fetch_spirv-tools
336+
;;
315337
"svt-av1")
316338
fetch_svt-av1
317339
;;

meson/native/llvm.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[binaries]
2+
llvm-config = '/opt/homebrew/opt/llvm/bin/llvm-config'

0 commit comments

Comments
 (0)