Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix computation of NUMBER_OF_PROCESSORS.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 31 Oct 2013 08:22:38 +0000 (09:22 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Thu, 31 Oct 2013 08:28:15 +0000 (09:28 +0100)
buildtools/jenkins/run.sh

index deceff5..287c144 100755 (executable)
@@ -13,13 +13,13 @@ export PATH=./lib/:../../lib:$PATH
 
 if test "$(uname -o)" = "Msys"
 then 
 
 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  
 
     #$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
     if [ $? -ne 0 ] ; then
         echo "Failed to do the first cmake - Halting"
         exit 1
@@ -54,16 +54,11 @@ then
     fi
 
 else
     fi
 
 else
-    NUMBER_OF_PROCESSORS=0
     # Linux:
     cpuinfo_file="/proc/cpuinfo"
     # 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
 
 
     cmake $WORKSPACE