[llvm-build] Add -j option
Allow the user to override the number of CPUs used for building LLVM. The
default remains unchanged, so if you're not going to use the -j flag it won't
affect you.
Change-Id: I2491274a629a505744a80625381fb2c47bafd4da
diff --git a/helpers/llvm-build b/helpers/llvm-build
index 7e00b2b..5ef0662 100755
--- a/helpers/llvm-build
+++ b/helpers/llvm-build
@@ -11,14 +11,14 @@
safe_run verify_env
## CMD line options and defaults
-CPUs=`grep -c proc /proc/cpuinfo`
+PARALLEL=-j`grep -c proc /proc/cpuinfo`
build_dir=$LLVM_BLD
install_dir=$LLVM_INSTALL
build_type=Release
shared=
targets=
prog=`basename $0`
-syntax="Syntax: $prog [targets]"
+syntax="Syntax: $prog [-jN] [targets]"
update=false
check=false
master=false
@@ -62,14 +62,20 @@
$targets $shared
fi
+## Allow the user to override the number of CPUs used with -jN
+if [[ $1 =~ -j[0-9]+ ]]; then
+ PARALLEL=$1
+ shift
+fi
+
## Build
if [ "$1" == "" ]; then
echo " + Building LLVM"
- safe_run $make -j$CPUs
+ safe_run $make $PARALLEL
else
for target in "$@"; do
echo " + Running $target"
- safe_run $make -j$CPUs $target
+ safe_run $make $PARALLEL $target
done
fi