Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[travis] detect linux as we should
[simgrid.git] / buildtools / jenkins / build.sh
index 37c7867..a853ee3 100755 (executable)
@@ -1,8 +1,11 @@
 #!/bin/sh
 
-set -e
+# This script is used by various build projects on Jenkins
 
-build_mode="$1"
+# See https://ci.inria.fr/simgrid/job/SimGrid-Multi/configure
+# See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
+
+set -e
 
 # usage: die status message...
 die () {
@@ -13,57 +16,109 @@ die () {
   exit $status
 }
 
-ulimit -c 0
-
-if [ -d $WORKSPACE/build ]
-then
-  rm -rf $WORKSPACE/build
-fi
-mkdir $WORKSPACE/build
-cd $WORKSPACE/build
-
-cmake -Denable_documentation=OFF $WORKSPACE
-make dist
-tar xzf `cat VERSION`.tar.gz
-cd `cat VERSION`
+# Get an ON/OFF string from a command:
+onoff() {
+  if "$@" > /dev/null ; then
+    echo ON
+  else
+    echo OFF
+  fi
+}
 
-if [ "$build_mode" = "Debug" ]
-then
-cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=OFF -Denable_lua=ON -Denable_compile_optimizations=ON -Denable_compile_warnings=ON .
+build_mode="$1"
+echo "Build mode $build_mode on $(uname -np)" >&2
+case "$build_mode" in
+  "Debug")
+  ;;
+
+  "ModelChecker")
+  ;;
+
+  "DynamicAnalysis")
+  ;;
+
+  *)
+    die 1 "Unknown build_mode $build_mode"
+  ;;
+esac
+
+if test "$(uname -o)" = "Msys"; then
+  if [ -z "$NUMBER_OF_PROCESSORS" ]; then
+    NUMBER_OF_PROCESSORS=1
+  fi
+  GENERATOR="MSYS Makefiles"
+else
+  NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
+  GENERATOR="Unix Makefiles"
 fi
 
-if [ "$build_mode" = "ModelChecker" ]
-then
-cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON -Denable_lua=ON -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON .
+ulimit -c 0 || true
+
+if test "$(uname -o)" != "Msys"; then
+  echo "XX"
+  echo "XX Get out of the tree"
+  echo "XX"
+  if [ -d $WORKSPACE/build ]
+  then
+    rm -rf $WORKSPACE/build
+  fi
+  mkdir $WORKSPACE/build
+  cd $WORKSPACE/build
+
+  echo "XX"
+  echo "XX Build the archive out of the tree"
+  echo "XX   pwd: `pwd`"
+  echo "XX"
+
+  cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
+  make dist -j$NUMBER_OF_PROCESSORS
+
+  echo "XX"
+  echo "XX Open the resulting archive"
+  echo "XX"
+  tar xzf `cat VERSION`.tar.gz
+  cd `cat VERSION`
 fi
 
-if [ "$build_mode" = "DynamicAnalysis" ]
-then
-cmake -Denable_documentation=OFF -Denable_lua=OFF -Denable_java=ON -Denable_tracing=ON -Denable_smpi=ON -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON -Denable_lib_static=OFF -Denable_model-checking=OFF -Denable_latency_bound_tracking=OFF -Denable_gtnets=OFF -Denable_jedule=OFF -Denable_mallocators=OFF -Denable_memcheck=ON -Denable_smpi_MPICH3_testsuite=OFF .
+echo "XX"
+echo "XX Configure and build SimGrid"
+echo "XX   pwd: `pwd`"
+echo "XX"
+cmake -G"$GENERATOR"\
+  -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
+  -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
+  -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
+  -Denable_compile_optimizations=$(onoff test "$build_mode" = "Debug") \
+  -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" != "DynamicAnalysis") \
+  -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
+  -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
+  -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
+  -Denable_compile_warnings=ON -Denable_smpi=ON -Denable_lib_static=OFF \
+  -Denable_latency_bound_tracking=OFF -Denable_jedule=OFF \
+  -Denable_tracing=ON -Denable_java=ON
+make -j$NUMBER_OF_PROCESSORS VERBOSE=1
+
+if test "$(uname -o)" != "Msys"; then
+  cd $WORKSPACE/build
+  cd `cat VERSION`
 fi
 
-make
-
-cd $WORKSPACE/build
-cd `cat VERSION`
-
 TRES=0
 
-ctest -T test --no-compress-output || true
+echo "XX"
+echo "XX Run the tests"
+echo "XX   pwd: `pwd`"
+echo "XX"
+
+ctest -T test --output-on-failure --no-compress-output || true
 if [ -f Testing/TAG ] ; then
    xsltproc $WORKSPACE/buildtools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
    mv CTestResults.xml $WORKSPACE
 fi
 
-if [ "$build_mode" = "Debug" ]
-then
-cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=OFF -Denable_lua=ON -Denable_compile_optimizations=ON -Denable_compile_warnings=ON .
-fi
-
-if [ "$build_mode" = "ModelChecker" ]
-then
-cmake -Denable_documentation=OFF -Denable_coverage=OFF -Denable_java=ON -Denable_smpi_MPICH3_testsuite=ON -Denable_model-checking=ON -Denable_lua=ON -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON .
-fi
+echo "XX"
+echo "XX Done. Return the results to cmake"
+echo "XX"
 
 if [ "$build_mode" = "DynamicAnalysis" ]
 then