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
# from the environment.
for var in "${var_templates[@]}"; do
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
mangleVarList "$var" "${role_infixes[@]}"
done
# `-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"
fi
source @out@/nix-support/utils.sh
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh
fi
source @out@/nix-support/utils.sh
# Parse command line options and set several variables.
# 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"
fi
source @out@/nix-support/utils.sh
if [ -z "${NIX_@infixSalt@_GNAT_WRAPPER_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh
fi
source @out@/nix-support/utils.sh
# Figure out if linker flags should be passed. GCC prints annoying
# warnings when they are not needed.

View file

@ -10,12 +10,12 @@ if [ -n "@coreutils_bin@" ]; then
PATH="@coreutils_bin@/bin"
fi
source @out@/nix-support/utils.sh
if [ -z "${NIX_CC_WRAPPER_@infixSalt@_FLAGS_SET:-}" ]; then
source @out@/nix-support/add-flags.sh
fi
source @out@/nix-support/utils.sh
# Optionally filter out paths not refering to the store.
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 () {
if [ -n "${NIX_DEBUG:-}" ]; then
echo "skipping impure path $1" >&2