summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorJonghyun Park <parjong@gmail.com>2017-06-09 15:47:07 (GMT)
committerJan Vorlicek <janvorli@microsoft.com>2017-06-09 15:47:07 (GMT)
commita2235dcc5711bde70f16a846ce88c622d18ae63d (patch)
treefee731b2b59f887703b4e0ac15492169e4a257e6 /build.sh
parent8c5977560b5124680c3b1032a0702fd72fadb3fc (diff)
downloadcoreclr-a2235dcc5711bde70f16a846ce88c622d18ae63d.zip
coreclr-a2235dcc5711bde70f16a846ce88c622d18ae63d.tar.gz
coreclr-a2235dcc5711bde70f16a846ce88c622d18ae63d.tar.bz2
Allow users to set the number of build processes (#12188)
* Allow users to set the number of build processes * Add a command-line option * Use common initialization style (use __NumProc and extract initialization from build_native) * Set __NumProc before argument parsing (and replace NumProc with __NumProc)
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh36
1 files changed, 23 insertions, 13 deletions
diff --git a/build.sh b/build.sh
index a85b137..f337ae2 100755
--- a/build.sh
+++ b/build.sh
@@ -52,6 +52,7 @@ usage()
echo "bindir - output directory (defaults to $__ProjectRoot/bin)"
echo "buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"."
echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported."
+ echo "numproc - set the number of build processes."
exit 1
}
@@ -311,17 +312,6 @@ build_native()
exit 1
fi
- # Get the number of processors available to the scheduler
- # Other techniques such as `nproc` only get the number of
- # processors available to a single process.
- if [ `uname` = "FreeBSD" ]; then
- NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
- elif [ `uname` = "NetBSD" ]; then
- NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
- else
- NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
- fi
-
# Build
if [ $__ConfigureOnly == 1 ]; then
echo "Finish configuration & skipping $message build."
@@ -331,9 +321,9 @@ build_native()
# Check that the makefiles were created.
pushd "$intermediatesForBuild"
- echo "Executing $buildTool install -j $NumProc"
+ echo "Executing $buildTool install -j $__NumProc"
- $buildTool install -j $NumProc
+ $buildTool install -j $__NumProc
if [ $? != 0 ]; then
echo "Failed to build $message."
exit 1
@@ -627,6 +617,17 @@ __msbuildonunsupportedplatform=0
__PgoOptDataVersion=""
__IbcOptDataVersion=""
+# Get the number of processors available to the scheduler
+# Other techniques such as `nproc` only get the number of
+# processors available to a single process.
+if [ `uname` = "FreeBSD" ]; then
+ __NumProc=`sysctl hw.ncpu | awk '{ print $2+1 }'`
+elif [ `uname` = "NetBSD" ]; then
+ __NumProc=$(($(getconf NPROCESSORS_ONLN)+1))
+else
+ __NumProc=$(($(getconf _NPROCESSORS_ONLN)+1))
+fi
+
while :; do
if [ $# -le 0 ]; then
break
@@ -816,6 +817,15 @@ while :; do
msbuildonunsupportedplatform)
__msbuildonunsupportedplatform=1
;;
+ numproc)
+ if [ -n "$2" ]; then
+ __NumProc="$2"
+ shift
+ else
+ echo "ERROR: 'numproc' requires a non-empty option argument"
+ exit 1
+ fi
+ ;;
*)
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
;;