buildGoModule: don't pass buildFlagsArray as file

Store buildFlagsArray as Bash global array variable instead of
creating/sourcing a file containing its declaration.

buildFlagsArray is short enough, and it is not assigned in a sub-shell.
There's no reason to pass it as a file. Storing it as a variable makes
the build more efficient.
This commit is contained in:
Yueh-Shun Li 2024-04-22 12:05:57 +08:00
parent b5769881ca
commit 26baea8388

View File

@ -218,8 +218,7 @@ let
buildGoDir() {
local cmd="$1" dir="$2"
. $TMPDIR/buildFlagsArray
declare -ga buildFlagsArray
declare -a flags
flags+=($buildFlags "''${buildFlagsArray[@]}")
flags+=(''${tags:+-tags=''${tags// /,}})
@ -258,11 +257,6 @@ let
buildFlagsArray+=(-x)
fi
if [ ''${#buildFlagsArray[@]} -ne 0 ]; then
declare -p buildFlagsArray > $TMPDIR/buildFlagsArray
else
touch $TMPDIR/buildFlagsArray
fi
if [ -z "$enableParallelBuilding" ]; then
export NIX_BUILD_CORES=1
fi