Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Jenkins: sh syntax error when speaking to windows
[simgrid.git] / buildtools / jenkins / build.sh
1 #!/bin/sh
2
3 set -e
4
5 echo "Running $0 with arguments:" >&2
6 for arg in "$@"; do
7   echo "- $arg"
8 done
9
10 build_mode="$1"
11 echo "Build mode $build_mode on $(uname -np)" >&2
12 case "$build_mode" in
13   "Debug")
14   ;;
15
16   "ModelChecker")
17   ;;
18
19   "DynamicAnalysis")
20   ;;
21
22   *)
23     if test "$(uname -o)" = "Msys"; then
24       echo "On Windows, jenkins is not willing to expand variables for some reason" >&2
25       echo "Force use Debug mode" >&2
26     else
27       echo "Unknown build_mode $build_mode"
28       exit 1
29     fi
30   ;;
31 esac
32
33 if test "$(uname -o)" = "Msys"; then
34   if [ -z "$NUMBER_OF_PROCESSORS" ]; then
35     NUMBER_OF_PROCESSORS=1
36   fi
37   GENERATOR="MSYS Makefiles"
38 else
39   NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
40   GENERATOR="Unix Makefiles"
41 fi
42
43 # usage: die status message...
44 die () {
45   local status=${1:-1}
46   shift
47   [ $# -gt 0 ] || set -- "Error - Halting"
48   echo "$@" >&2
49   exit $status
50 }
51
52 # Get an ON/OFF string from a command:
53 onoff() {
54   if "$@" > /dev/null ; then
55     echo ON
56   else
57     echo OFF
58   fi
59 }
60
61 ulimit -c 0 || true
62
63 if [ -d $WORKSPACE/build ]
64 then
65   rm -rf $WORKSPACE/build
66 fi
67 mkdir $WORKSPACE/build
68 cd $WORKSPACE/build
69
70 cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
71 make dist -j$NUMBER_OF_PROCESSORS
72 tar xzf `cat VERSION`.tar.gz
73 cd `cat VERSION`
74
75 cmake -G"$GENERATOR"\
76   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
77   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
78   -Denable_compile_optimization=$(onoff test "$build_mode" = "Debug") \
79   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" != "DynamicAnalysis") \
80   -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
81   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
82   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
83   -Denable_compile_warnings=ON -Denable_smpi=ON -Denable_lib_static=OFF \
84   -Denable_latency_bound_tracking=OFF -Denable_gtnets=OFF -Denable_jedule=OFF \
85   -Denable_tracing=ON -Denable_java=ON
86 make -j$NUMBER_OF_PROCESSORS
87
88 cd $WORKSPACE/build
89 cd `cat VERSION`
90
91 TRES=0
92
93 ctest -T test --output-on-failure --no-compress-output || true
94 if [ -f Testing/TAG ] ; then
95    xsltproc $WORKSPACE/buildtools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
96    mv CTestResults.xml $WORKSPACE
97 fi
98
99 if [ "$build_mode" = "DynamicAnalysis" ]
100 then
101   ctest -D ContinuousStart
102   ctest -D ContinuousConfigure
103   ctest -D ContinuousBuild
104   ctest -D ContinuousMemCheck
105   ctest -D ContinuousSubmit
106 fi
107
108 ctest -D ContinuousStart
109 ctest -D ContinuousConfigure
110 ctest -D ContinuousBuild
111 ctest -D ContinuousTest
112 ctest -D ContinuousSubmit
113
114 rm -rf `cat VERSION`