pkgs/stdenv/generic/setup.sh: added support for enableParallelBuilding variable

If a build expressions has set "enableParallelBuilding = true", then the
generic builder may utilize more than one CPU core to build that particular
expression. This feature works out of the box for GNU Make. Expressions that
use other build drivers like Boost.Jam or SCons have to specify appropriate
flags such as "-j${NIX_BUILD_CORES}" themselves.

svn path=/nixpkgs/branches/stdenv-updates/; revision=22399
This commit is contained in:
Peter Simons 2010-06-23 14:34:59 +00:00
parent ce9cc7da1f
commit 226e0c7646

View File

@ -269,6 +269,23 @@ fi
export NIX_INDENT_MAKE=1
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
# means that we're supposed to try and auto-detect the number of
# available CPU cores at run-time.
if test -z "${NIX_BUILD_CORES:-}"; then
NIX_BUILD_CORES="1"
elif test "$NIX_BUILD_CORES" -le 0; then
NIX_BUILD_CORES=$(nproc 2>/dev/null || true)
if expr >/dev/null 2>&1 "$NIX_BUILD_CORES" : "^[0-9][0-9]*$"; then
:
else
NIX_BUILD_CORES="1"
fi
fi
export NIX_BUILD_CORES
######################################################################
# Misc. helper functions.
@ -603,6 +620,7 @@ buildPhase() {
echo "make flags: $makeFlags ${makeFlagsArray[@]} $buildFlags ${buildFlagsArray[@]}"
make ${makefile:+-f $makefile} \
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
$makeFlags "${makeFlagsArray[@]}" \
$buildFlags "${buildFlagsArray[@]}"
@ -615,6 +633,7 @@ checkPhase() {
echo "check flags: $makeFlags ${makeFlagsArray[@]} $checkFlags ${checkFlagsArray[@]}"
make ${makefile:+-f $makefile} \
${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} \
$makeFlags "${makeFlagsArray[@]}" \
$checkFlags "${checkFlagsArray[@]}" ${checkTarget:-check}