cc-wrapper: Use separate mangler for "bool" variables
This avoids any `NIX_FOOBAR=1 1` not triggering conditions.
This commit is contained in:
parent
fc7ed86915
commit
bdd6c037c0
@ -4,7 +4,7 @@
|
|||||||
# that case, it is cheaper/better to not repeat this step and let the forked
|
# that case, it is cheaper/better to not repeat this step and let the forked
|
||||||
# wrapped binary just inherit the work of the forker's wrapper script.
|
# wrapped binary just inherit the work of the forker's wrapper script.
|
||||||
|
|
||||||
var_templates=(
|
var_templates_list=(
|
||||||
NIX+CFLAGS_COMPILE
|
NIX+CFLAGS_COMPILE
|
||||||
NIX+CFLAGS_LINK
|
NIX+CFLAGS_LINK
|
||||||
NIX+CXXSTDLIB_COMPILE
|
NIX+CXXSTDLIB_COMPILE
|
||||||
@ -14,7 +14,9 @@ var_templates=(
|
|||||||
NIX+LDFLAGS
|
NIX+LDFLAGS
|
||||||
NIX+LDFLAGS_BEFORE
|
NIX+LDFLAGS_BEFORE
|
||||||
NIX+LDFLAGS_AFTER
|
NIX+LDFLAGS_AFTER
|
||||||
|
)
|
||||||
|
|
||||||
|
var_templates_bool=(
|
||||||
NIX+SET_BUILD_ID
|
NIX+SET_BUILD_ID
|
||||||
NIX+DONT_SET_RPATH
|
NIX+DONT_SET_RPATH
|
||||||
NIX+ENFORCE_NO_NATIVE
|
NIX+ENFORCE_NO_NATIVE
|
||||||
@ -35,9 +37,12 @@ fi
|
|||||||
|
|
||||||
# We need to mangle names for hygiene, but also take parameters/overrides
|
# We need to mangle names for hygiene, but also take parameters/overrides
|
||||||
# from the environment.
|
# from the environment.
|
||||||
for var in "${var_templates[@]}"; do
|
for var in "${var_templates_list[@]}"; do
|
||||||
mangleVarList "$var" "${role_infixes[@]}"
|
mangleVarList "$var" "${role_infixes[@]}"
|
||||||
done
|
done
|
||||||
|
for var in "${var_templates_bool[@]}"; do
|
||||||
|
mangleVarBool "$var" "${role_infixes[@]}"
|
||||||
|
done
|
||||||
|
|
||||||
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
# `-B@out@/bin' forces cc to use ld-wrapper.sh when calling ld.
|
||||||
NIX_@infixSalt@_CFLAGS_COMPILE="-B@out@/bin/ $NIX_@infixSalt@_CFLAGS_COMPILE"
|
NIX_@infixSalt@_CFLAGS_COMPILE="-B@out@/bin/ $NIX_@infixSalt@_CFLAGS_COMPILE"
|
||||||
|
@ -1,20 +1,35 @@
|
|||||||
mangleVarList() {
|
mangleVarList() {
|
||||||
declare var="$1"
|
local var="$1"
|
||||||
shift
|
shift
|
||||||
declare -a role_infixes=("$@")
|
local -a role_infixes=("$@")
|
||||||
|
|
||||||
outputVar="${var/+/_@infixSalt@_}"
|
local outputVar="${var/+/_@infixSalt@_}"
|
||||||
export ${outputVar}+=''
|
declare -gx ${outputVar}+=''
|
||||||
# For each role we serve, we accumulate the input parameters into our own
|
# For each role we serve, we accumulate the input parameters into our own
|
||||||
# cc-wrapper-derivation-specific environment variables.
|
# cc-wrapper-derivation-specific environment variables.
|
||||||
for infix in "${role_infixes[@]}"; do
|
for infix in "${role_infixes[@]}"; do
|
||||||
inputVar="${var/+/${infix}}"
|
local inputVar="${var/+/${infix}}"
|
||||||
if [ -v "$inputVar" ]; then
|
if [ -v "$inputVar" ]; then
|
||||||
export ${outputVar}+="${!outputVar:+ }${!inputVar}"
|
export ${outputVar}+="${!outputVar:+ }${!inputVar}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mangleVarBool() {
|
||||||
|
local var="$1"
|
||||||
|
shift
|
||||||
|
local -a role_infixes=("$@")
|
||||||
|
|
||||||
|
local outputVar="${var/+/_@infixSalt@_}"
|
||||||
|
declare -gxi ${outputVar}+=0
|
||||||
|
for infix in "${role_infixes[@]}"; do
|
||||||
|
local inputVar="${var/+/${infix}}"
|
||||||
|
if [ -v "$inputVar" ]; then
|
||||||
|
let "${outputVar} |= ${!inputVar}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
skip () {
|
skip () {
|
||||||
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
if (( "${NIX_DEBUG:-0}" >= 1 )); then
|
||||||
echo "skipping impure path $1" >&2
|
echo "skipping impure path $1" >&2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user