@@ -1,92 +0,0 @@
1−# Accumulate suffixes for taking in the right input parameters with the `mangle*`
2−# functions below. See setup-hook for details.
3−accumulateRoles() {
4− declare -ga role_suffixes=()
5− if [ "${NIX_@wrapperName@_TARGET_BUILD_@suffixSalt@:-}" ]; then
6− role_suffixes+=('_FOR_BUILD')
7− fi
8− if [ "${NIX_@wrapperName@_TARGET_HOST_@suffixSalt@:-}" ]; then
9− role_suffixes+=('')
10− fi
11− if [ "${NIX_@wrapperName@_TARGET_TARGET_@suffixSalt@:-}" ]; then
12− role_suffixes+=('_FOR_TARGET')
13− fi
14−}
15−
16−mangleVarList() {
17− local var="$1"
18− shift
19− local -a role_suffixes=("$@")
20−
21− local outputVar="${var}_@suffixSalt@"
22− declare -gx ${outputVar}+=''
23− # For each role we serve, we accumulate the input parameters into our own
24− # cc-wrapper-derivation-specific environment variables.
25− for suffix in "${role_suffixes[@]}"; do
26− local inputVar="${var}${suffix}"
27− if [ -v "$inputVar" ]; then
28− export ${outputVar}+="${!outputVar:+ }${!inputVar}"
29− fi
30− done
31−}
32−
33−mangleVarBool() {
34− local var="$1"
35− shift
36− local -a role_suffixes=("$@")
37−
38− local outputVar="${var}_@suffixSalt@"
39− declare -gxi ${outputVar}+=0
40− for suffix in "${role_suffixes[@]}"; do
41− local inputVar="${var}${suffix}"
42− if [ -v "$inputVar" ]; then
43− # "1" in the end makes `let` return success error code when
44− # expression itself evaluates to zero.
45− # We don't use `|| true` because that would silence actual
46− # syntax errors from bad variable values.
47− let "${outputVar} |= ${!inputVar:-0}" "1"
48− fi
49− done
50−}
51−
52−skip () {
53− if (( "${NIX_DEBUG:-0}" >= 1 )); then
54− echo "skipping impure path $1" >&2
55− fi
56−}
57−
58−
59−# Checks whether a path is impure. E.g., `/lib/foo.so' is impure, but
60−# `/nix/store/.../lib/foo.so' isn't.
61−badPath() {
62− local p=$1
63−
64− # Relative paths are okay (since they're presumably relative to
65− # the temporary build directory).
66− if [ "${p:0:1}" != / ]; then return 1; fi
67−
68− # Otherwise, the path should refer to the store or some temporary
69− # directory (including the build directory).
70− test \
71− "$p" != "/dev/null" -a \
72− "${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
73− "${p:0:4}" != "/tmp" -a \
74− "${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
75−}
76−
77−expandResponseParams() {
78− declare -ga params=("$@")
79− local arg
80− for arg in "$@"; do
81− if [[ "$arg" == @* ]]; then
82− # phase separation makes this look useless
83− # shellcheck disable=SC2157
84− if [ -x "@expandResponseParams@" ]; then
85− # params is used by caller
86− #shellcheck disable=SC2034
87− readarray -d '' params < <("@expandResponseParams@" "$@")
88− return 0
89− fi
90− fi
91− done
92−}