Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid looping over single, constant value (codefactor.io/ShellCheck).
[simgrid.git] / tools / jenkins / Flags.sh
index 62d76e3..44ffae8 100755 (executable)
@@ -1,30 +1,12 @@
-#!/bin/sh
+#!/usr/bin/env sh
 
 set -e
 
-if [ $# -lt 4 ]
-  then
-    echo "Needs 4 arguments : JAVA MC SMPI DEBUG"
-    exit -1
-fi
-
-
-
 die() {
     echo "$@"
     exit 1
 }
 
-do_cleanup() {
-  for d in "$WORKSPACE/build"
-  do
-    if [ -d "$d" ]
-    then
-      rm -rf "$d" || die "Could not remote $d"
-    fi
-  done
-}
-
 # Get an ON/OFF string from a command:
 onoff() {
   if "$@" > /dev/null ; then
@@ -34,17 +16,25 @@ onoff() {
   fi
 }
 
-### Cleanup previous runs
+[ $# -eq 4 ] || die "Needs 4 arguments : JAVA MC SMPI DEBUG"
+
+### Cleanup previous runs
 
 ! [ -z "$WORKSPACE" ] || die "No WORKSPACE"
 [ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
 
-do_cleanup
+do_cleanup() {
+  for d
+  do
+    if [ -d "$d" ]
+    then
+      rm -rf "$d" || die "Could not remove $d"
+    fi
+    mkdir "$d" || die "Could not create $d"
+  done
+}
 
-for d in "$WORKSPACE/build"
-do
-  mkdir "$d" || die "Could not create $d"
-done
+do_cleanup "$WORKSPACE/build"
 
 NUMPROC="$(nproc)" || NUMPROC=1
 
@@ -53,35 +43,35 @@ cd $WORKSPACE/build
 #we can't just receive ON or OFF as values as display is bad in the resulting jenkins matrix
 
 if [ $1 = "JAVA" ]
-then 
+then
   buildjava="ON"
 else
   buildjava="OFF"
 fi
 
 if [ $2 = "MC" ]
-then 
+then
   buildmc="ON"
 else
   buildmc="OFF"
 fi
 
 if [ $3 = "SMPI" ]
-then 
+then
   buildsmpi="ON"
 else
   buildsmpi="OFF"
 fi
 
 if [ $4 = "DEBUG" ]
-then 
+then
   builddebug="ON"
 else
   builddebug="OFF"
 fi
 
 
-echo "Step ${STEP}/${NSTEPS} - Building with java=${buildjava}, debug=${builddebug}, SMPI=${buildsmpi}, MC=${buildmc}" 
+echo "Step ${STEP}/${NSTEPS} - Building with java=${buildjava}, debug=${builddebug}, SMPI=${buildsmpi}, MC=${buildmc}"
 cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=${buildjava} \
       -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
       -Denable_jedule=ON -Denable_mallocators=ON -Denable_debug=${builddebug} \
@@ -89,7 +79,7 @@ cmake -Denable_documentation=OFF -Denable_lua=ON -Denable_java=${buildjava} \
       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_ISP_testsuite=OFF \
       -Denable_ns3=$(onoff test "$buildmc" != "ON") -Denable_coverage=OFF $WORKSPACE
 
-make -j$NUMPROC
+make -j$NUMPROC tests
 make clean