setup.sh: avoid running the same hook twice

In strictDeps=false, we don’t want the same package hook to be run
twice, otherwise we get duplicates in some flags.

Fixes #41340
This commit is contained in:
Matthew Bauer 2018-10-31 14:26:54 -05:00
parent e3e1a53118
commit 9172c1eee2

View File

@ -562,6 +562,10 @@ _addToEnv() {
(( "$depHostOffset" <= "$depTargetOffset" )) || continue
local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"
if [[ -z "${strictDeps-}" ]]; then
# Keep track of which packages we have visited before.
local visitedPkgs=""
# Apply environment hooks to all packages during native
# compilation to ease the transition.
#
@ -574,7 +578,11 @@ _addToEnv() {
${pkgsHostTarget+"${pkgsHostTarget[@]}"} \
${pkgsTargetTarget+"${pkgsTargetTarget[@]}"}
do
if [[ "$visitedPkgs" = *"$pkg"* ]]; then
continue
fi
runHook "${!hookRef}" "$pkg"
visitedPkgs+=" $pkg"
done
else
local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"