2023-08-04 22:07:22 +00:00
|
|
|
# shellcheck shell=bash disable=SC2154,SC2086
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
readonly zigDefaultFlagsArray=(@zig_default_flags@)
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
function zigSetGlobalCacheDir {
|
|
|
|
ZIG_GLOBAL_CACHE_DIR=$(mktemp -d)
|
|
|
|
export ZIG_GLOBAL_CACHE_DIR
|
|
|
|
}
|
|
|
|
|
|
|
|
function zigBuildPhase {
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
local flagsArray=(
|
|
|
|
"${zigDefaultFlagsArray[@]}"
|
|
|
|
$zigBuildFlags "${zigBuildFlagsArray[@]}"
|
|
|
|
)
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
echoCmd 'zig build flags' "${flagsArray[@]}"
|
2023-08-04 22:07:22 +00:00
|
|
|
zig build "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
}
|
|
|
|
|
|
|
|
function zigCheckPhase {
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
local flagsArray=(
|
|
|
|
"${zigDefaultFlagsArray[@]}"
|
|
|
|
$zigCheckFlags "${zigCheckFlagsArray[@]}"
|
|
|
|
)
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
echoCmd 'zig check flags' "${flagsArray[@]}"
|
2023-08-04 22:07:22 +00:00
|
|
|
zig build test "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
function zigInstallPhase {
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
local flagsArray=(
|
|
|
|
"${zigDefaultFlagsArray[@]}"
|
|
|
|
$zigBuildFlags "${zigBuildFlagsArray[@]}"
|
|
|
|
$zigInstallFlags "${zigInstallFlagsArray[@]}"
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ -z "${dontAddPrefix-}" ]; then
|
|
|
|
# Zig does not recognize `--prefix=/dir/`, only `--prefix /dir/`
|
|
|
|
flagsArray+=("${prefixKey:---prefix}" "$prefix")
|
|
|
|
fi
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
echoCmd 'zig install flags' "${flagsArray[@]}"
|
2023-08-04 22:07:22 +00:00
|
|
|
zig build install "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
}
|
|
|
|
|
|
|
|
addEnvHooks "$targetOffset" zigSetGlobalCacheDir
|
|
|
|
|
|
|
|
if [ -z "${dontUseZigBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
|
|
buildPhase=zigBuildPhase
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${dontUseZigCheck-}" ] && [ -z "${checkPhase-}" ]; then
|
|
|
|
checkPhase=zigCheckPhase
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${dontUseZigInstall-}" ] && [ -z "${installPhase-}" ]; then
|
|
|
|
installPhase=zigInstallPhase
|
|
|
|
fi
|