2024-08-19 07:42:05 +00:00
|
|
|
# shellcheck shell=bash
|
2023-07-15 03:57:49 +00:00
|
|
|
|
2024-06-09 16:49:39 +00:00
|
|
|
# shellcheck disable=SC2034
|
2023-08-06 02:41:13 +00:00
|
|
|
readonly zigDefaultFlagsArray=(@zig_default_flags@)
|
2023-07-15 03:57:49 +00:00
|
|
|
|
|
|
|
function zigSetGlobalCacheDir {
|
|
|
|
ZIG_GLOBAL_CACHE_DIR=$(mktemp -d)
|
|
|
|
export ZIG_GLOBAL_CACHE_DIR
|
|
|
|
}
|
|
|
|
|
|
|
|
function zigBuildPhase {
|
|
|
|
runHook preBuild
|
|
|
|
|
2024-06-09 16:49:39 +00:00
|
|
|
local flagsArray=()
|
|
|
|
concatTo flagsArray zigDefaultFlagsArray \
|
|
|
|
zigBuildFlags zigBuildFlagsArray
|
2023-07-15 03:57:49 +00:00
|
|
|
|
2023-09-07 23:11:12 +00:00
|
|
|
echoCmd 'zig build flags' "${flagsArray[@]}"
|
2023-07-15 03:57:49 +00:00
|
|
|
zig build "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
}
|
|
|
|
|
|
|
|
function zigCheckPhase {
|
|
|
|
runHook preCheck
|
|
|
|
|
2024-06-09 16:49:39 +00:00
|
|
|
local flagsArray=()
|
|
|
|
concatTo flagsArray zigDefaultFlagsArray \
|
|
|
|
zigCheckFlags zigCheckFlagsArray
|
2023-07-15 03:57:49 +00:00
|
|
|
|
2023-09-07 23:11:12 +00:00
|
|
|
echoCmd 'zig check flags' "${flagsArray[@]}"
|
2023-07-15 03:57:49 +00:00
|
|
|
zig build test "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
}
|
|
|
|
|
|
|
|
function zigInstallPhase {
|
|
|
|
runHook preInstall
|
|
|
|
|
2024-06-09 16:49:39 +00:00
|
|
|
local flagsArray=()
|
|
|
|
concatTo flagsArray zigDefaultFlagsArray \
|
|
|
|
zigBuildFlags zigBuildFlagsArray \
|
|
|
|
zigInstallFlags zigInstallFlagsArray
|
2023-07-15 03:57:49 +00:00
|
|
|
|
|
|
|
if [ -z "${dontAddPrefix-}" ]; then
|
|
|
|
# Zig does not recognize `--prefix=/dir/`, only `--prefix /dir/`
|
|
|
|
flagsArray+=("${prefixKey:---prefix}" "$prefix")
|
|
|
|
fi
|
|
|
|
|
2023-09-07 23:11:12 +00:00
|
|
|
echoCmd 'zig install flags' "${flagsArray[@]}"
|
2023-07-15 03:57:49 +00:00
|
|
|
zig build install "${flagsArray[@]}"
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
}
|
|
|
|
|
2024-08-19 07:42:05 +00:00
|
|
|
# shellcheck disable=SC2154
|
2023-07-15 03:57:49 +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
|