nixpkgs-suyu/pkgs/development/tools/build-managers/ninja/setup-hook.sh
Orivej Desh 2c7cd2455e ninja: support disabling parallel building
but keep it enabled by default
2017-12-07 08:52:42 +00:00

50 lines
1.2 KiB
Bash

ninjaBuildPhase() {
runHook preBuild
if [[ -z "$ninjaFlags" && ! ( -e build.ninja ) ]]; then
echo "no build.ninja, doing nothing"
else
local buildCores=1
# Parallel building is enabled by default.
if [ "${enableParallelBuilding-1}" ]; then
buildCores="$NIX_BUILD_CORES"
fi
# shellcheck disable=SC2086
local flagsArray=( \
-j"$buildCores" -l"$NIX_BUILD_CORES" \
$ninjaFlags "${ninjaFlagsArray[@]}" \
$buildFlags "${buildFlagsArray[@]}")
echoCmd 'build flags' "${flagsArray[@]}"
ninja "${flagsArray[@]}"
unset flagsArray
fi
runHook postBuild
}
if [ -z "$dontUseNinjaBuild" -a -z "$buildPhase" ]; then
buildPhase=ninjaBuildPhase
fi
ninjaInstallPhase() {
runHook preInstall
installTargets="${installTargets:-install}"
# shellcheck disable=SC2086
local flagsArray=( $installTargets \
$ninjaFlags "${ninjaFlagsArray[@]}")
echoCmd 'install flags' "${flagsArray[@]}"
ninja "${flagsArray[@]}"
unset flagsArray
runHook postInstall
}
if [ -z "$dontUseNinjaInstall" -a -z "$installPhase" ]; then
installPhase=ninjaInstallPhase
fi