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" echo "Using neovimRequireCheckHook"
preDistPhases+=" neovimRequireCheckHook" appendToVar preDistPhases neovimRequireCheckHook

View File

@ -21,5 +21,5 @@ vimCommandCheckHook () {
} }
echo "Using 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}" ${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... # Yes its a bit long...
if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then if [ -z "${dontWriteRequiredOctavePackagesPhase-}" ]; then
echo "Using octaveWriteRequiredOctavePackagesPhase" echo "Using octaveWriteRequiredOctavePackagesPhase"
preDistPhases+=" octaveWriteRequiredOctavePackagesPhase" appendToVar preDistPhases octaveWriteRequiredOctavePackagesPhase
fi fi

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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