2024-09-19 14:19:46 +00:00
|
|
|
# shellcheck shell=bash
|
2023-08-04 22:07:22 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# shellcheck disable=SC2034
|
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
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
local flagsArray=()
|
|
|
|
concatTo flagsArray zigDefaultFlagsArray \
|
|
|
|
zigBuildFlags zigBuildFlagsArray
|
2023-08-04 22:07:22 +00:00
|
|
|
|
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
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
local flagsArray=()
|
|
|
|
concatTo flagsArray zigDefaultFlagsArray \
|
|
|
|
zigCheckFlags zigCheckFlagsArray
|
2023-08-04 22:07:22 +00:00
|
|
|
|
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
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
local flagsArray=()
|
|
|
|
concatTo flagsArray zigDefaultFlagsArray \
|
|
|
|
zigBuildFlags zigBuildFlagsArray \
|
|
|
|
zigInstallFlags zigInstallFlagsArray
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
# shellcheck disable=SC2154
|
2023-08-04 22:07:22 +00:00
|
|
|
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
|