1 # shellcheck shell=bash
3 # shellcheck disable=SC2034
4 readonly zigDefaultFlagsArray
=(@zig_default_flags@
)
6 function zigSetGlobalCacheDir
{
7 ZIG_GLOBAL_CACHE_DIR
=$
(mktemp
-d)
8 export ZIG_GLOBAL_CACHE_DIR
11 function zigBuildPhase
{
15 concatTo flagsArray zigDefaultFlagsArray \
16 zigBuildFlags zigBuildFlagsArray
18 echoCmd
'zig build flags' "${flagsArray[@]}"
19 zig build
"${flagsArray[@]}"
24 function zigCheckPhase
{
28 concatTo flagsArray zigDefaultFlagsArray \
29 zigCheckFlags zigCheckFlagsArray
31 echoCmd
'zig check flags' "${flagsArray[@]}"
32 zig build
test "${flagsArray[@]}"
37 function zigInstallPhase
{
41 concatTo flagsArray zigDefaultFlagsArray \
42 zigBuildFlags zigBuildFlagsArray \
43 zigInstallFlags zigInstallFlagsArray
45 if [ -z "${dontAddPrefix-}" ]; then
46 # Zig does not recognize `--prefix=/dir/`, only `--prefix /dir/`
47 flagsArray
+=("${prefixKey:---prefix}" "$prefix")
50 echoCmd
'zig install flags' "${flagsArray[@]}"
51 zig build
install "${flagsArray[@]}"
56 # shellcheck disable=SC2154
57 addEnvHooks
"$targetOffset" zigSetGlobalCacheDir
59 if [ -z "${dontUseZigBuild-}" ] && [ -z "${buildPhase-}" ]; then
60 buildPhase
=zigBuildPhase
63 if [ -z "${dontUseZigCheck-}" ] && [ -z "${checkPhase-}" ]; then
64 checkPhase
=zigCheckPhase
67 if [ -z "${dontUseZigInstall-}" ] && [ -z "${installPhase-}" ]; then
68 installPhase
=zigInstallPhase