stdenv: implement checkTarget
and installCheckTarget
autodetection
This commit is contained in:
parent
e9e06888ed
commit
50af975d85
@ -971,6 +971,8 @@ buildPhase() {
|
|||||||
if [[ -z "$makeFlags" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
|
if [[ -z "$makeFlags" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
|
||||||
echo "no Makefile, doing nothing"
|
echo "no Makefile, doing nothing"
|
||||||
else
|
else
|
||||||
|
foundMakefile=1
|
||||||
|
|
||||||
# See https://github.com/NixOS/nixpkgs/pull/1354#issuecomment-31260409
|
# See https://github.com/NixOS/nixpkgs/pull/1354#issuecomment-31260409
|
||||||
makeFlags="SHELL=$SHELL $makeFlags"
|
makeFlags="SHELL=$SHELL $makeFlags"
|
||||||
|
|
||||||
@ -994,18 +996,38 @@ buildPhase() {
|
|||||||
checkPhase() {
|
checkPhase() {
|
||||||
runHook preCheck
|
runHook preCheck
|
||||||
|
|
||||||
# Old bash empty array hack
|
if [[ -z "${foundMakefile:-}" ]]; then
|
||||||
# shellcheck disable=SC2086
|
echo "no Makefile or custom buildPhase, doing nothing"
|
||||||
local flagsArray=(
|
runHook postCheck
|
||||||
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
return
|
||||||
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
fi
|
||||||
${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
|
|
||||||
${checkTarget:-check}
|
|
||||||
)
|
|
||||||
|
|
||||||
echoCmd 'check flags' "${flagsArray[@]}"
|
if [[ -z "${checkTarget:-}" ]]; then
|
||||||
make ${makefile:+-f $makefile} "${flagsArray[@]}"
|
#TODO(@oxij): should flagsArray influence make -n?
|
||||||
unset flagsArray
|
if make -n ${makefile:+-f $makefile} check >/dev/null 2>&1; then
|
||||||
|
checkTarget=check
|
||||||
|
elif make -n ${makefile:+-f $makefile} test >/dev/null 2>&1; then
|
||||||
|
checkTarget=test
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${checkTarget:-}" ]]; then
|
||||||
|
echo "no check/test target in ${makefile:-Makefile}, doing nothing"
|
||||||
|
else
|
||||||
|
# Old bash empty array hack
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
local flagsArray=(
|
||||||
|
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
||||||
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
||||||
|
${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"}
|
||||||
|
${checkTarget}
|
||||||
|
)
|
||||||
|
|
||||||
|
echoCmd 'check flags' "${flagsArray[@]}"
|
||||||
|
make ${makefile:+-f $makefile} "${flagsArray[@]}"
|
||||||
|
|
||||||
|
unset flagsArray
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postCheck
|
runHook postCheck
|
||||||
}
|
}
|
||||||
@ -1104,18 +1126,26 @@ fixupPhase() {
|
|||||||
installCheckPhase() {
|
installCheckPhase() {
|
||||||
runHook preInstallCheck
|
runHook preInstallCheck
|
||||||
|
|
||||||
# Old bash empty array hack
|
if [[ -z "${foundMakefile:-}" ]]; then
|
||||||
# shellcheck disable=SC2086
|
echo "no Makefile or custom buildPhase, doing nothing"
|
||||||
local flagsArray=(
|
#TODO(@oxij): should flagsArray influence make -n?
|
||||||
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
elif [[ -z "${installCheckTarget:-}" ]] \
|
||||||
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
&& ! make -n ${makefile:+-f $makefile} ${installCheckTarget:-installcheck} >/dev/null 2>&1; then
|
||||||
$installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"}
|
echo "no installcheck target in ${makefile:-Makefile}, doing nothing"
|
||||||
${installCheckTarget:-installcheck}
|
else
|
||||||
)
|
# Old bash empty array hack
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
local flagsArray=(
|
||||||
|
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}}
|
||||||
|
$makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"}
|
||||||
|
$installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"}
|
||||||
|
${installCheckTarget:-installcheck}
|
||||||
|
)
|
||||||
|
|
||||||
echoCmd 'installcheck flags' "${flagsArray[@]}"
|
echoCmd 'installcheck flags' "${flagsArray[@]}"
|
||||||
make ${makefile:+-f $makefile} "${flagsArray[@]}"
|
make ${makefile:+-f $makefile} "${flagsArray[@]}"
|
||||||
unset flagsArray
|
unset flagsArray
|
||||||
|
fi
|
||||||
|
|
||||||
runHook postInstallCheck
|
runHook postInstallCheck
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user