Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / development / compilers / zig / 0.9 / setup-hook.sh
blob689ebec8a30777bfaef5d5d07c431788de14234c
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 {
11 runHook preBuild
13 local flagsArray=(
14 "${zigDefaultFlagsArray[@]}"
15 $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 "${zigDefaultFlagsArray[@]}"
29 $zigCheckFlags "${zigCheckFlagsArray[@]}"
32 echoCmd 'zig check flags' "${flagsArray[@]}"
33 zig build test "${flagsArray[@]}"
35 runHook postCheck
38 function zigInstallPhase {
39 runHook preInstall
41 local flagsArray=(
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[@]}"
55 runHook postInstall
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