otadump: init at 0.1.2 (#329129)
[NixPkgs.git] / pkgs / development / compilers / zig / 0.12 / setup-hook.sh
blob0053c5997da6be2ed5ba0cd539eaf11289dec98e
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 {
12 runHook preBuild
14 local flagsArray=()
15 concatTo flagsArray zigDefaultFlagsArray \
16 zigBuildFlags zigBuildFlagsArray
18 echoCmd 'zig build flags' "${flagsArray[@]}"
19 zig build "${flagsArray[@]}"
21 runHook postBuild
24 function zigCheckPhase {
25 runHook preCheck
27 local flagsArray=()
28 concatTo flagsArray zigDefaultFlagsArray \
29 zigCheckFlags zigCheckFlagsArray
31 echoCmd 'zig check flags' "${flagsArray[@]}"
32 zig build test "${flagsArray[@]}"
34 runHook postCheck
37 function zigInstallPhase {
38 runHook preInstall
40 local flagsArray=()
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[@]}"
53 runHook postInstall
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