1 # shellcheck shell=bash disable=SC2154,SC2086
3 readonly zigDefaultFlagsArray
=(@zig_default_flags@
)
5 function zigSetGlobalCacheDir
{
6 ZIG_GLOBAL_CACHE_DIR
=$
(mktemp
-d)
7 export ZIG_GLOBAL_CACHE_DIR
10 function zigBuildPhase
{
14 "${zigDefaultFlagsArray[@]}"
15 $zigBuildFlags "${zigBuildFlagsArray[@]}"
18 echoCmd
'zig build flags' "${flagsArray[@]}"
19 zig build
"${flagsArray[@]}"
24 function zigCheckPhase
{
28 "${zigDefaultFlagsArray[@]}"
29 $zigCheckFlags "${zigCheckFlagsArray[@]}"
32 echoCmd
'zig check flags' "${flagsArray[@]}"
33 zig build
test "${flagsArray[@]}"
38 function zigInstallPhase
{
42 "${zigDefaultFlagsArray[@]}"
43 $zigBuildFlags "${zigBuildFlagsArray[@]}"
44 $zigInstallFlags "${zigInstallFlagsArray[@]}"
47 if [ -z "${dontAddPrefix-}" ]; then
48 # Zig does not recognize `--prefix=/dir/`, only `--prefix /dir/`
49 flagsArray
+=("${prefixKey:---prefix}" "$prefix")
52 echoCmd
'zig install flags' "${flagsArray[@]}"
53 zig build
install "${flagsArray[@]}"
58 addEnvHooks
"$targetOffset" zigSetGlobalCacheDir
60 if [ -z "${dontUseZigBuild-}" ] && [ -z "${buildPhase-}" ]; then
61 buildPhase
=zigBuildPhase
64 if [ -z "${dontUseZigCheck-}" ] && [ -z "${checkPhase-}" ]; then
65 checkPhase
=zigCheckPhase
68 if [ -z "${dontUseZigInstall-}" ] && [ -z "${installPhase-}" ]; then
69 installPhase
=zigInstallPhase