treewide: handle preDistPhases __structuredAttrs-agnostically

Always specify the preDistPhases attribute as a list instead of a string.

Append elements to the preDistPhases Bash variable using appendToVar
instead of string or Bash array concatenation.

Handle element insertion before a specific element using string
substitution as before, but handle both structured and unstructured
attributes.
This commit is contained in:
Yueh-Shun Li 2024-09-03 04:14:28 +08:00
parent 385d523a8e
commit 054c5f0e10
17 changed files with 40 additions and 26 deletions

View File

@ -16,6 +16,6 @@ neovimRequireCheckHook () {
}
echo "Using neovimRequireCheckHook"
preDistPhases+=" neovimRequireCheckHook"
appendToVar preDistPhases neovimRequireCheckHook

View File

@ -21,5 +21,5 @@ vimCommandCheckHook () {
}
echo "Using vimCommandCheckHook"
preDistPhases+=" vimCommandCheckHook"
appendToVar preDistPhases vimCommandCheckHook

View File

@ -22,5 +22,5 @@ writeShellScript "make-darwin-bundle-${name}" (''
${writeDarwinBundle}/bin/write-darwin-bundle "''${!outputBin}" "${name}" "${exec}"
}
preDistPhases+=" makeDarwinBundlePhase"
appendToVar preDistPhases makeDarwinBundlePhase
'')

View File

@ -13,5 +13,5 @@ octaveWriteRequiredOctavePackagesPhase() {
# Yes its a bit long...
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
echo "Using octaveWriteRequiredOctavePackagesPhase"
preDistPhases+=" octaveWriteRequiredOctavePackagesPhase"
appendToVar preDistPhases octaveWriteRequiredOctavePackagesPhase
fi

View File

@ -13,5 +13,5 @@ writeRequiredOctavePackagesPhase() {
# Yes its a bit long...
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
echo "Using writeRequiredOctavePackagesPhase"
preDistPhases+=" writeRequiredOctavePackagesPhase"
appendToVar preDistPhases writeRequiredOctavePackagesPhase
fi

View File

@ -58,5 +58,5 @@ function pytestCheckPhase() {
if [ -z "${dontUsePytestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
echo "Using pytestCheckPhase"
preDistPhases+=" pytestCheckPhase"
appendToVar preDistPhases pytestCheckPhase
fi

View File

@ -6,5 +6,5 @@ pythonCatchConflictsPhase() {
}
if [ -z "${dontUsePythonCatchConflicts-}" ]; then
preDistPhases+=" pythonCatchConflictsPhase"
appendToVar preDistPhases pythonCatchConflictsPhase
fi

View File

@ -18,5 +18,5 @@ pythonImportsCheckPhase () {
if [ -z "${dontUsePythonImportsCheck-}" ]; then
echo "Using pythonImportsCheckPhase"
preDistPhases+=" pythonImportsCheckPhase"
appendToVar preDistPhases pythonImportsCheckPhase
fi

View File

@ -13,5 +13,5 @@ pythonRemoveBinBytecodePhase () {
}
if [ -z "${dontUsePythonRemoveBinBytecode-}" ]; then
preDistPhases+=" pythonRemoveBinBytecodePhase"
appendToVar preDistPhases pythonRemoveBinBytecodePhase
fi

View File

@ -69,4 +69,4 @@ installSphinxPhase() {
runHook postInstallSphinx
}
preDistPhases+=" buildSphinxPhase installSphinxPhase"
appendToVar preDistPhases buildSphinxPhase installSphinxPhase

View File

@ -13,5 +13,5 @@ unittestCheckPhase() {
if [ -z "${dontUseUnittestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
echo "Using unittestCheckPhase"
preDistPhases+=" unittestCheckPhase"
appendToVar preDistPhases unittestCheckPhase
fi

View File

@ -16,10 +16,17 @@ pytestForkedHook() {
# until we have dependency mechanism in generic builder, we need to use this ugly hack.
if [ -z "${dontUsePytestForked-}" ] && [ -z "${dontUsePytestCheck-}" ]; then
if [[ " ${preDistPhases:-} " =~ " pytestCheckPhase " ]]; then
preDistPhases+=" "
preDistPhases="${preDistPhases/ pytestCheckPhase / pytestForkedHook pytestCheckPhase }"
if [[ " ${preDistPhases[*]:-} " =~ " pytestCheckPhase " ]]; then
_preDistPhases="${preDistPhases[*]} "
_preDistPhases="${_preDistPhases/ pytestCheckPhase / pytestForkedHook pytestCheckPhase }"
if [[ -n "${__structuredAttrs-}" ]]; then
preDistPhases=()
else
preDistPhases=""
fi
appendToVar preDistPhases $_preDistPhases
unset _preDistPhases
else
preDistPhases+=" pytestForkedHook"
appendToVar preDistPhases pytestForkedHook
fi
fi

View File

@ -8,10 +8,17 @@ pytestXdistHook() {
# until we have dependency mechanism in generic builder, we need to use this ugly hack.
if [ -z "${dontUsePytestXdist-}" ] && [ -z "${dontUsePytestCheck-}" ]; then
if [[ " ${preDistPhases:-} " =~ " pytestCheckPhase " ]]; then
preDistPhases+=" "
preDistPhases="${preDistPhases/ pytestCheckPhase / pytestXdistHook pytestCheckPhase }"
if [[ " ${preDistPhases[*]:-} " =~ " pytestCheckPhase " ]]; then
_preDistPhases="${preDistPhases[*]} "
_preDistPhases="${_preDistPhases/ pytestCheckPhase / pytestXdistHook pytestCheckPhase }"
if [[ -n "${__structuredAttrs-}" ]]; then
preDistPhases=()
else
preDistPhases=""
fi
appendToVar preDistPhases $_preDistPhases
unset _preDistPhases
else
preDistPhases+=" pytestXdistHook"
appendToVar preDistPhases pytestXdistHook
fi
fi

View File

@ -87,7 +87,7 @@ let
pytestcachePhase() {
find $out -name .pytest_cache -type d -exec rm -rf {} +
}
preDistPhases+=" pytestcachePhase"
appendToVar preDistPhases pytestcachePhase
# pytest generates it's own bytecode files to improve assertion messages.
# These files similar to cpython's bytecode files but are never laoded
@ -100,7 +100,7 @@ let
# https://github.com/pytest-dev/pytest/blob/7.2.1/src/_pytest/assertion/rewrite.py#L51-L53
find $out -name "*-pytest-*.py[co]" -delete
}
preDistPhases+=" pytestRemoveBytecodePhase"
appendToVar preDistPhases pytestRemoveBytecodePhase
'';
pythonImportsCheck = [ "pytest" ];

View File

@ -84,7 +84,7 @@ buildPythonPackage rec {
pytestcachePhase() {
find $out -name .pytest_cache -type d -exec rm -rf {} +
}
preDistPhases+=" pytestcachePhase"
appendToVar preDistPhases pytestcachePhase
# pytest generates it's own bytecode files to improve assertion messages.
# These files similar to cpython's bytecode files but are never laoded
@ -97,7 +97,7 @@ buildPythonPackage rec {
# https://github.com/pytest-dev/pytest/blob/7.2.1/src/_pytest/assertion/rewrite.py#L51-L53
find $out -name "*-pytest-*.py[co]" -delete
}
preDistPhases+=" pytestRemoveBytecodePhase"
appendToVar preDistPhases pytestRemoveBytecodePhase
'';
pythonImportsCheck = [ "pytest" ];

View File

@ -42,7 +42,7 @@ buildPythonPackage rec {
find $out -name .pytest_cache -type d -exec rm -rf {} +
}
preDistPhases+=" pytestcachePhase"
appendToVar preDistPhases pytestcachePhase
# pytest generates it's own bytecode files to improve assertion messages.
# These files similar to cpython's bytecode files but are never laoded
@ -55,7 +55,7 @@ buildPythonPackage rec {
# https://github.com/pytest-dev/pytest/blob/4.6.11/src/_pytest/assertion/rewrite.py#L32-L47
find $out -name "*-PYTEST.py[co]" -delete
}
preDistPhases+=" pytestRemoveBytecodePhase"
appendToVar preDistPhases pytestRemoveBytecodePhase
'';
meta = with lib; {

View File

@ -21,5 +21,5 @@ function manifestCheckPhase() {
if [ -z "${dontCheckManifest-}" ] && [ -z "${installCheckPhase-}" ]; then
echo "Using manifestCheckPhase"
preDistPhases+=" manifestCheckPhase"
appendToVar preDistPhases manifestCheckPhase
fi