cc-wrapper: Pull variable mangler into utils.sh

In preparation for splitting out binutils-wrapper
This commit is contained in:
John Ericson 2017-08-31 14:43:09 -04:00
parent 94c0267fc1
commit 1f5807d760
5 changed files with 24 additions and 16 deletions

View File

@ -36,16 +36,7 @@ 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[@]}"; do
outputVar="${var/+/_@infixSalt@_}" mangleVarList "$var" "${role_infixes[@]}"
export ${outputVar}+=''
# For each role we serve, we accumulate the input parameters into our own
# cc-wrapper-derivation-specific environment variables.
for infix in "${role_infixes[@]}"; do
inputVar="${var/+/${infix}}"
if [ -v "$inputVar" ]; then
export ${outputVar}+="${!outputVar:+ }${!inputVar}"
fi
done
done 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.

View File

@ -11,12 +11,12 @@ 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
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
source @out@/nix-support/utils.sh
# Parse command line options and set several variables. # Parse command line options and set several variables.
# For instance, figure out if linker flags should be passed. # For instance, figure out if linker flags should be passed.

View File

@ -13,12 +13,12 @@ if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin" PATH="@coreutils_bin@/bin"
fi fi
source @out@/nix-support/utils.sh
if [ -z "${NIX_@infixSalt@_GNAT_WRAPPER_FLAGS_SET:-}" ]; then if [ -z "${NIX_@infixSalt@_GNAT_WRAPPER_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
source @out@/nix-support/utils.sh
# Figure out if linker flags should be passed. GCC prints annoying # Figure out if linker flags should be passed. GCC prints annoying
# warnings when they are not needed. # warnings when they are not needed.

View File

@ -10,12 +10,12 @@ if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin" PATH="@coreutils_bin@/bin"
fi fi
source @out@/nix-support/utils.sh
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh source @out@/nix-support/add-flags.sh
fi fi
source @out@/nix-support/utils.sh
# Optionally filter out paths not refering to the store. # Optionally filter out paths not refering to the store.
expandResponseParams "$@" expandResponseParams "$@"

View File

@ -1,3 +1,20 @@
mangleVarList() {
declare var="$1"
shift
declare -a role_infixes=("$@")
outputVar="${var/+/_@infixSalt@_}"
export ${outputVar}+=''
# For each role we serve, we accumulate the input parameters into our own
# cc-wrapper-derivation-specific environment variables.
for infix in "${role_infixes[@]}"; do
inputVar="${var/+/${infix}}"
if [ -v "$inputVar" ]; then
export ${outputVar}+="${!outputVar:+ }${!inputVar}"
fi
done
}
skip () { skip () {
if [ -n "${NIX_DEBUG:-}" ]; then if [ -n "${NIX_DEBUG:-}" ]; then
echo "skipping impure path $1" >&2 echo "skipping impure path $1" >&2