{bintools,cc}-wrapper: Factor out role accumulation logic

This commit is contained in:
John Ericson 2018-05-07 13:15:34 -04:00
parent 2110c0bd30
commit 8b0fce8cb1
7 changed files with 23 additions and 28 deletions

View file

@ -11,16 +11,7 @@ var_templates_bool=(
NIX+DONT_SET_RPATH
)
declare -a role_infixes=()
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
accumulateRoles
for var in "${var_templates_list[@]}"; do
mangleVarList "$var" "${role_infixes[@]}"

View file

@ -294,7 +294,7 @@ stdenv.mkDerivation {
set +u
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.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
@ -305,7 +305,7 @@ stdenv.mkDerivation {
inherit dynamicLinker expand-response-params;
# for substitution in utils.sh
# for substitution in utils.bash
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
meta =

View file

@ -14,7 +14,7 @@ if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin"
fi
source @out@/nix-support/utils.sh
source @out@/nix-support/utils.bash
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh

View file

@ -14,18 +14,7 @@ var_templates_bool=(
NIX+ENFORCE_NO_NATIVE
)
# Accumulate infixes for taking in the right input parameters. See setup-hook
# 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
accumulateRoles
# We need to mangle names for hygiene, but also take parameters/overrides
# from the environment.

View file

@ -15,7 +15,7 @@ if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then
PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin"
fi
source @out@/nix-support/utils.sh
source @out@/nix-support/utils.bash
# Flirting with a layer violation here.
if [ -z "${NIX_BINTOOLS_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then

View file

@ -282,7 +282,7 @@ stdenv.mkDerivation {
+ ''
substituteAll ${./add-flags.sh} $out/nix-support/add-flags.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
@ -293,7 +293,7 @@ stdenv.mkDerivation {
inherit expand-response-params;
# for substitution in utils.sh
# for substitution in utils.bash
expandResponseParams = "${expand-response-params}/bin/expand-response-params";
meta =

View file

@ -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() {
local var="$1"
shift