depot/third_party/nixpkgs/pkgs/by-name/ha/haredo/setup-hook.sh
Default email 504525a148 Project import generated by Copybara.
GitOrigin-RevId: bd645e8668ec6612439a9ee7e71f7eac4099d4f6
2024-01-02 12:29:13 +01:00

69 lines
1.9 KiB
Bash

haredoBuildPhase() {
runHook preBuild
local buildTargets jobs
read -ra buildTargets <<<"${haredoBuildTargets-}"
echoCmd "haredo build targets" "${buildTargets[@]}"
if [[ ! -v enableParallelBuilding || -n "${enableParallelBuilding-}" ]]; then
jobs="${NIX_BUILD_CORES}"
fi
haredo ${jobs:+"-j${jobs}"} "${buildTargets[@]}"
runHook postBuild
}
haredoCheckPhase() {
runHook preCheck
local checkTargets jobs
if [[ -n "${haredoCheckTargets:-}" ]]; then
read -ra checkTargets <<<"${haredoCheckTargets}"
else
for dofile in "check.do" "test.do"; do
[[ -r "${dofile}" ]] && {
checkTargets=("${dofile%".do"}")
break
}
done
fi
if [[ -z "${checkTargets:-}" ]]; then
printf -- 'haredoCheckPhase ERROR: no check targets were found' 1>&2
exit 1
else
echoCmd "haredo check targets" "${checkTargets[@]}"
if [[ ! -v enableParallelChecking || -n "${enableParallelChecking-}" ]]; then
jobs="${NIX_BUILD_CORES}"
fi
haredo ${jobs:+"-j${jobs}"} "${checkTargets[@]}"
fi
runHook postCheck
}
haredoInstallPhase() {
runHook preInstall
local installTargets jobs
read -ra installTargets <<<"${haredoInstallTargets:-"install"}"
echoCmd "haredo install targets" "${installTargets[@]}"
if [[ ! -v enableParallelInstalling || -n "${enableParallelInstalling-}" ]]; then
jobs="${NIX_BUILD_CORES}"
fi
haredo ${jobs:+"-j${jobs}"} "${installTargets[@]}"
runHook postInstall
}
if [[ -z "${dontUseHaredoBuild-}" && -z "${buildPhase-}" ]]; then
buildPhase="haredoBuildPhase"
fi
if [[ -z "${dontUseHaredoCheck-}" && -z "${checkPhase-}" ]]; then
checkPhase="haredoCheckPhase"
fi
if [[ -z "${dontUseHaredoInstall-}" && -z "${installPhase-}" ]]; then
installPhase="haredoInstallPhase"
fi