From 8ad7ef7624e395d4c9435d456f7a61a1c7933687 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Sun, 16 Jul 2023 14:11:23 -0300 Subject: [PATCH] wafHook: refactor setup-hook.sh - shellcheck - remove local flagsArray self-insertion - split prefix flag insertion --- .../tools/build-managers/waf/setup-hook.sh | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pkgs/development/tools/build-managers/waf/setup-hook.sh b/pkgs/development/tools/build-managers/waf/setup-hook.sh index 4d95c28de1f1..2593b0a9d808 100644 --- a/pkgs/development/tools/build-managers/waf/setup-hook.sh +++ b/pkgs/development/tools/build-managers/waf/setup-hook.sh @@ -1,3 +1,5 @@ +# shellcheck shell=bash disable=SC2206 + wafConfigurePhase() { runHook preConfigure @@ -7,7 +9,7 @@ wafConfigurePhase() { fi if [ -z "${dontAddPrefix:-}" ] && [ -n "$prefix" ]; then - wafConfigureFlags="${prefixKey:---prefix=}$prefix $wafConfigureFlags" + local prefixFlag="${prefixKey:---prefix=}$prefix" fi if [ -n "${PKG_CONFIG}" ]; then @@ -15,13 +17,15 @@ wafConfigurePhase() { fi local flagsArray=( - "${flagsArray[@]}" + $prefixFlag $wafConfigureFlags "${wafConfigureFlagsArray[@]}" ${configureTargets:-configure} ) + if [ -z "${dontAddWafCrossFlags:-}" ]; then flagsArray+=(@crossFlags@) fi + echoCmd 'configure flags' "${flagsArray[@]}" python "$wafPath" "${flagsArray[@]}" @@ -38,15 +42,11 @@ wafConfigurePhase() { runHook postConfigure } -if [ -z "${dontUseWafConfigure-}" -a -z "${configurePhase-}" ]; then - configurePhase=wafConfigurePhase -fi - wafBuildPhase () { runHook preBuild # set to empty if unset - : ${wafFlags=} + : "${wafFlags=}" local flagsArray=( ${enableParallelBuilding:+-j ${NIX_BUILD_CORES}} @@ -61,10 +61,6 @@ wafBuildPhase () { runHook postBuild } -if [ -z "${dontUseWafBuild-}" -a -z "${buildPhase-}" ]; then - buildPhase=wafBuildPhase -fi - wafInstallPhase() { runHook preInstall @@ -85,6 +81,14 @@ wafInstallPhase() { runHook postInstall } -if [ -z "${dontUseWafInstall-}" -a -z "${installPhase-}" ]; then +if [ -z "${dontUseWafConfigure-}" ] && [ -z "${configurePhase-}" ]; then + configurePhase=wafConfigurePhase +fi + +if [ -z "${dontUseWafBuild-}" ] && [ -z "${buildPhase-}" ]; then + buildPhase=wafBuildPhase +fi + +if [ -z "${dontUseWafInstall-}" ] && [ -z "${installPhase-}" ]; then installPhase=wafInstallPhase fi