scripts: make git-update.sh build with all cores available
authorDanilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk>
Thu, 19 May 2016 14:27:36 +0000 (11:27 -0300)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 20 May 2016 10:57:25 +0000 (11:57 +0100)
The git-update.sh now builds with all cores available. In case of
failure it defaults to 1

The developer can still override this by setting -j to something else
in MAKEFLAGS, as stated by 299605dfe2f97fca330161ff01a392e1a85fe422.

https://bugzilla.gnome.org/show_bug.cgi?id=766666

scripts/git-update.sh

index aaa738f..d02e0f7 100755 (executable)
@@ -29,6 +29,8 @@ tmp=$tmp/git-update.$(date +%Y%m%d-%H%M-).$RANDOM.$RANDOM.$RANDOM.$$
 ERROR_LOG="$tmp/failures.log"
 ERROR_RETURN=255
 
+CPUCORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu  2>/dev/null || echo "1")
+
 for m in $CORE $MODULES $EXTRA_MODULES; do
   if test -d $m; then
     echo "+ updating $m"
@@ -91,7 +93,7 @@ build()
     fi
 
     echo "+ $1: make"
-    make > "$tmp/$1-make.log" 2>&1
+    MAKEFLAGS="-j$CPUCORES $MAKEFLAGS" make > "$tmp/$1-make.log" 2>&1
     if test $? -ne 0
     then
       echo "$1: make [$tmp/$1-make.log]" >> $ERROR_LOG