stdenv: refactor default flags without __structuredAttrs use

Instead of checking for __structuredAttrs everywhere, it's easier to
just set the default value via parameter expansion and then hand the
array construction off to "concatTo".

Once more setup-hooks will be made structuredAttrs-aware, this pattern
will reduce the use of this implementation detail even more.
This commit is contained in:
Wolfgang Walther 2024-06-09 12:45:57 +02:00
parent 6bdfef9d2d
commit 8cb51ec38e
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1

View File

@ -1254,12 +1254,8 @@ patchPhase() {
esac esac
local -a flagsArray local -a flagsArray
if [ -n "$__structuredAttrs" ]; then : "${patchFlags:=-p1}"
flagsArray=( "${patchFlags[@]:--p1}" ) concatTo flagsArray patchFlags
else
# shellcheck disable=SC2086,SC2206
flagsArray=( ${patchFlags:--p1} )
fi
# "2>&1" is a hack to make patch fail if the decompressor fails (nonexistent patch, etc.) # "2>&1" is a hack to make patch fail if the decompressor fails (nonexistent patch, etc.)
# shellcheck disable=SC2086 # shellcheck disable=SC2086
$uncompress < "$i" 2>&1 | patch "${flagsArray[@]}" $uncompress < "$i" 2>&1 | patch "${flagsArray[@]}"
@ -1411,16 +1407,8 @@ checkPhase() {
SHELL="$SHELL" SHELL="$SHELL"
) )
concatTo flagsArray makeFlags makeFlagsArray : "${checkFlags:=VERBOSE=y}"
if [ -n "$__structuredAttrs" ]; then concatTo flagsArray makeFlags makeFlagsArray checkFlags checkFlagsArray checkTarget
flagsArray+=( "${checkFlags[@]:-VERBOSE=y}" )
else
# shellcheck disable=SC2206
flagsArray+=( ${checkFlags:-VERBOSE=y} )
fi
concatTo flagsArray checkFlagsArray
# shellcheck disable=SC2206
flagsArray+=( ${checkTarget} )
echoCmd 'check flags' "${flagsArray[@]}" echoCmd 'check flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}" make ${makefile:+-f $makefile} "${flagsArray[@]}"
@ -1453,13 +1441,9 @@ installPhase() {
${enableParallelInstalling:+-j${NIX_BUILD_CORES}} ${enableParallelInstalling:+-j${NIX_BUILD_CORES}}
SHELL="$SHELL" SHELL="$SHELL"
) )
concatTo flagsArray makeFlags makeFlagsArray installFlags installFlagsArray
if [ -n "$__structuredAttrs" ]; then : "${installTargets:=install}"
flagsArray+=( "${installTargets[@]:-install}" ) concatTo flagsArray makeFlags makeFlagsArray installFlags installFlagsArray installTargets
else
# shellcheck disable=SC2206
flagsArray+=( ${installTargets:-install} )
fi
echoCmd 'install flags' "${flagsArray[@]}" echoCmd 'install flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}" make ${makefile:+-f $makefile} "${flagsArray[@]}"
@ -1542,10 +1526,9 @@ installCheckPhase() {
SHELL="$SHELL" SHELL="$SHELL"
) )
: "${installCheckTarget:=installcheck}"
concatTo flagsArray makeFlags makeFlagsArray \ concatTo flagsArray makeFlags makeFlagsArray \
installCheckFlags installCheckFlagsArray installCheckFlags installCheckFlagsArray installCheckTarget
# shellcheck disable=SC2206
flagsArray+=( ${installCheckTarget:-installcheck} )
echoCmd 'installcheck flags' "${flagsArray[@]}" echoCmd 'installcheck flags' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}" make ${makefile:+-f $makefile} "${flagsArray[@]}"
@ -1560,9 +1543,8 @@ distPhase() {
runHook preDist runHook preDist
local flagsArray=() local flagsArray=()
concatTo flagsArray distFlags distFlagsArray : "${distTarget:=dist}"
# shellcheck disable=SC2206 concatTo flagsArray distFlags distFlagsArray distTarget
flagsArray+=( ${distTarget:-dist} )
echo 'dist flags: %q' "${flagsArray[@]}" echo 'dist flags: %q' "${flagsArray[@]}"
make ${makefile:+-f $makefile} "${flagsArray[@]}" make ${makefile:+-f $makefile} "${flagsArray[@]}"