setup-hook.sh: use eval for dynamic variable export

This commit is contained in:
happysalada 2021-06-28 22:44:01 +09:00 committed by Raphael Megzari
parent 06688b73ca
commit 6d52db43d4

View File

@ -1,3 +1,4 @@
# shellcheck shell=bash
# Binutils Wrapper hygiene
#
# See comments in cc-wrapper's setup hook. This works exactly the same way.
@ -14,7 +15,9 @@ bintoolsWrapper_addLDVars () {
getHostRoleEnvHook
if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then
export NIX_LDFLAGS${role_post}+=" -L$1/lib64"
varName=NIX_LDFLAGS${role_post}
eval "$varName=\"${!varName:-} -L$1/lib64\""
export "${varName?}"
fi
if [[ -d "$1/lib" ]]; then
@ -24,7 +27,9 @@ bintoolsWrapper_addLDVars () {
# directories and bloats the size of the environment variable space.
local -a glob=( $1/lib/lib* )
if [ "${#glob[*]}" -gt 0 ]; then
export NIX_LDFLAGS${role_post}+=" -L$1/lib"
varName=NIX_LDFLAGS${role_post}
eval "$varName=\"${!varName:-} -L$1/lib\""
export "${varName?}"
fi
fi
}