From b29c32a336eacac8bf67b34f5ff703b64dbf4285 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 31 Oct 2013 09:22:38 +0100 Subject: [PATCH] Fix computation of NUMBER_OF_PROCESSORS. --- buildtools/jenkins/run.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/buildtools/jenkins/run.sh b/buildtools/jenkins/run.sh index deceff5d36..287c1440e1 100755 --- a/buildtools/jenkins/run.sh +++ b/buildtools/jenkins/run.sh @@ -13,13 +13,13 @@ export PATH=./lib/:../../lib:$PATH if test "$(uname -o)" = "Msys" then - - cmake -G "MSYS Makefiles" $WORKSPACE #$NUMBER_OF_PROCESSORS should be already set on win if [ -z "$NUMBER_OF_PROCESSORS" ]; then NUMBER_OF_PROCESSORS=1 fi + cmake -G "MSYS Makefiles" $WORKSPACE + if [ $? -ne 0 ] ; then echo "Failed to do the first cmake - Halting" exit 1 @@ -54,16 +54,11 @@ then fi else - NUMBER_OF_PROCESSORS=0 # Linux: cpuinfo_file="/proc/cpuinfo" - if [ -f "${cpuinfo_file}" ]; then - NUMBER_OF_PROCESSORS=$(grep -c "processor.: " ${cpuinfo_file}) - fi - # grep returns 0 or cpuinfo not found - if [ $NUMBER_OF_PROCESSORS = 0 ]; then - NUMBER_OF_PROCESSORS=1 - fi + NUMBER_OF_PROCESSORS=$(lscpu -p 2>/dev/null | grep -c '^[^#]') || \ + NUMBER_OF_PROCESSORS=$(grep -c "^processor[[:space:]]*:" ${cpuinfo_file} 2>/dev/null) + [ "0$NUMBER_OF_PROCESSORS" -gt 0 ] || NUMBER_OF_PROCESSORS=1 cmake $WORKSPACE -- 2.20.1