{bintools,cc}-wrapper: Factor out role accumulation logic
This commit is contained in:
parent
2110c0bd30
commit
8b0fce8cb1
|
@ -11,16 +11,7 @@ var_templates_bool=(
|
||||||
NIX+DONT_SET_RPATH
|
NIX+DONT_SET_RPATH
|
||||||
)
|
)
|
||||||
|
|
||||||
declare -a role_infixes=()
|
accumulateRoles
|
||||||
if [ "${NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_BUILD:-}" ]; then
|
|
||||||
role_infixes+=(_BUILD_)
|
|
||||||
fi
|
|
||||||
if [ "${NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_HOST:-}" ]; then
|
|
||||||
role_infixes+=(_)
|
|
||||||
fi
|
|
||||||
if [ "${NIX_BINTOOLS_WRAPPER_@infixSalt@_TARGET_TARGET:-}" ]; then
|
|
||||||
role_infixes+=(_TARGET_)
|
|
||||||
fi
|
|
||||||
|
|
||||||
for var in "${var_templates_list[@]}"; do
|
for var in "${var_templates_list[@]}"; do
|
||||||
mangleVarList "$var" "${role_infixes[@]}"
|
mangleVarList "$var" "${role_infixes[@]}"
|
||||||
|
|
|
@ -294,7 +294,7 @@ stdenv.mkDerivation {
|
||||||
set +u
|
set +u
|
||||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||||
substituteAll ${../cc-wrapper/utils.sh} $out/nix-support/utils.sh
|
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
||||||
|
|
||||||
##
|
##
|
||||||
## Extra custom steps
|
## Extra custom steps
|
||||||
|
@ -305,7 +305,7 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
inherit dynamicLinker expand-response-params;
|
inherit dynamicLinker expand-response-params;
|
||||||
|
|
||||||
# for substitution in utils.sh
|
# for substitution in utils.bash
|
||||||
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
||||||
|
|
||||||
meta =
|
meta =
|
||||||
|
|
|
@ -14,7 +14,7 @@ if [ -n "@coreutils_bin@" ]; then
|
||||||
PATH="@coreutils_bin@/bin"
|
PATH="@coreutils_bin@/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source @out@/nix-support/utils.sh
|
source @out@/nix-support/utils.bash
|
||||||
|
|
||||||
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
||||||
source @out@/nix-support/add-flags.sh
|
source @out@/nix-support/add-flags.sh
|
||||||
|
|
|
@ -14,18 +14,7 @@ var_templates_bool=(
|
||||||
NIX+ENFORCE_NO_NATIVE
|
NIX+ENFORCE_NO_NATIVE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Accumulate infixes for taking in the right input parameters. See setup-hook
|
accumulateRoles
|
||||||
# for details.
|
|
||||||
declare -a role_infixes=()
|
|
||||||
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_BUILD:-}" ]; then
|
|
||||||
role_infixes+=(_BUILD_)
|
|
||||||
fi
|
|
||||||
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_HOST:-}" ]; then
|
|
||||||
role_infixes+=(_)
|
|
||||||
fi
|
|
||||||
if [ "${NIX_CC_WRAPPER_@infixSalt@_TARGET_TARGET:-}" ]; then
|
|
||||||
role_infixes+=(_TARGET_)
|
|
||||||
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.
|
||||||
|
|
|
@ -15,7 +15,7 @@ if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then
|
||||||
PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin"
|
PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source @out@/nix-support/utils.sh
|
source @out@/nix-support/utils.bash
|
||||||
|
|
||||||
# Flirting with a layer violation here.
|
# Flirting with a layer violation here.
|
||||||
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
|
||||||
|
|
|
@ -282,7 +282,7 @@ stdenv.mkDerivation {
|
||||||
+ ''
|
+ ''
|
||||||
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.sh
|
||||||
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
substituteAll ${./add-hardening.sh} $out/nix-support/add-hardening.sh
|
||||||
substituteAll ${./utils.sh} $out/nix-support/utils.sh
|
substituteAll ${../wrapper-common/utils.bash} $out/nix-support/utils.bash
|
||||||
|
|
||||||
##
|
##
|
||||||
## Extra custom steps
|
## Extra custom steps
|
||||||
|
@ -293,7 +293,7 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
inherit expand-response-params;
|
inherit expand-response-params;
|
||||||
|
|
||||||
# for substitution in utils.sh
|
# for substitution in utils.bash
|
||||||
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
|
||||||
|
|
||||||
meta =
|
meta =
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
# Accumulate infixes for taking in the right input parameters with the `mangle*`
|
||||||
|
# functions below. See setup-hook for details.
|
||||||
|
accumulateRoles() {
|
||||||
|
declare -ga role_infixes=()
|
||||||
|
if [ "${NIX_@wrapperName@_@infixSalt@_TARGET_BUILD:-}" ]; then
|
||||||
|
role_infixes+=(_BUILD_)
|
||||||
|
fi
|
||||||
|
if [ "${NIX_@wrapperName@_@infixSalt@_TARGET_HOST:-}" ]; then
|
||||||
|
role_infixes+=(_)
|
||||||
|
fi
|
||||||
|
if [ "${NIX_@wrapperName@_@infixSalt@_TARGET_TARGET:-}" ]; then
|
||||||
|
role_infixes+=(_TARGET_)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
mangleVarList() {
|
mangleVarList() {
|
||||||
local var="$1"
|
local var="$1"
|
||||||
shift
|
shift
|
Loading…
Reference in New Issue