summaryrefslogtreecommitdiff
path: root/mesa-run
blob: 274c18b0d87c0445f6d5578c0871513d0a1c6518 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash

die() {
	echo "$1"
	exit 255
}

[[ -z ${builddir} ]] && die "builddir must be set"
prefix="${builddir}"/install

IFS=: read -r -a extra_args <<< "${extra_args}"

machine=$(uname -m)
case "$machine" in
x86_64)
	vulkan_drivers=intel
	gallium_drivers=iris
	tools=drm-shim,intel
	extra_args+=(
		-Dintel-rt=disabled
	)
	;;
aarch64|arm*)
	vulkan_drivers=freedreno
	gallium_drivers=freedreno
	tools=drm-shim,freedreno
	;;
esac

case "$1" in
wipe|wipeout)
	echo "Removing ${builddir}"
	rm -r "${builddir}"
	;&
configure)
	export LLVM_MAJOR_VERSION="20"
	llvm_config_paths=(
		"/usr/bin/llvm-config-${LLVM_MAJOR_VERSION}"
		"/usr/lib/llvm/${LLVM_MAJOR_VERSION}/bin/llvm-config"
	)
	for llvm_config in "${llvm_config_paths[@]}"; do
		if [[ -x "${llvm_config}" ]]; then
			export LLVM_CONFIG="${llvm_config}"
			break
		fi
	done

	llvm_pkg_config_paths=(
		"/usr/lib/llvm/${LLVM_MAJOR_VERSION}/lib64/pkgconfig"
		"/usr/lib/x86_64-linux-gnu/pkgconfig"
	)
	for llvm_pkg_config_path in "${llvm_pkg_config_paths[@]}"; do
		if [[ -f "${llvm_pkg_config_path}/LLVMSPIRVLib.pc" ]]; then
			export LLVM_CONFIG="${llvm_config}"
			spirv_llvm_translator_pkg_config_path="${llvm_pkg_config_path}"
			break
		fi
	done

	#export CC="/usr/lib/llvm/${LLVM_MAJOR_VERSION}/bin/clang"
	#export CXX="/usr/lib/llvm/${LLVM_MAJOR_VERSION}/bin/clang++"
	#export CC_LD="/usr/lib/llvm/${LLVM_MAJOR_VERSION}/bin/lld"
	#export CXX_LD="${CC_LD}"
	export CC_LD="mold"
	export CXX_LD="mold"

	args=(
		--pkg-config-path "${spirv_llvm_translator_pkg_config_path}"
		-Dprefix="${prefix}"
		-Dc_args="${cflags}"
		-Dcpp_args="${cxxflags}"
		-Dtools="${tools}"
		-Dbuild-tests=false
		-Dvulkan-drivers="${vulkan_drivers}"
		-Dgallium-drivers="${gallium_drivers}"
		-Dgallium-rusticl=false
		-Dgallium-va=disabled
		-Dintel-elk=false
		-Dvulkan-beta=true
		-Dbuildtype="${buildtype}"
		-Dbackend=ninja
		"${extra_args[@]}"
		"${builddir}"
	)
	echo meson setup --reconfigure "${args[@]}"
	exec meson setup --reconfigure "${args[@]}"
	;;
build)
	exec nj "${buildtype}" install
	;;
esac

LD_PRELOAD="${GCC_ASAN_PRELOAD}" exec meson devenv -C "${builddir}" -w "${PWD}" "$@"