Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Missing ']'
[simgrid.git] / tools / jenkins / Flags.sh
1 #!/usr/bin/env sh
2
3 set -e
4
5 echo "Starting Flags.sh $*"
6
7 die() {
8     echo "$@"
9     exit 1
10 }
11
12 # Get an ON/OFF string from a command:
13 onoff() {
14   if "$@" > /dev/null ; then
15     echo ON
16   else
17     echo OFF
18   fi
19 }
20
21 [ $# -eq 3 ] || die "Needs 3 arguments : MC SMPI DEBUG"
22
23 ### Cleanup previous runs
24
25 [ -n "$WORKSPACE" ] || die "No WORKSPACE"
26 [ -d "$WORKSPACE" ] || die "WORKSPACE ($WORKSPACE) does not exist"
27
28 do_cleanup() {
29   for d
30   do
31     if [ -d "$d" ]
32     then
33       rm -rf "$d" || die "Could not remove $d"
34     fi
35     mkdir "$d" || die "Could not create $d"
36   done
37 }
38
39 do_cleanup "$WORKSPACE/build"
40
41 NUMPROC="$(nproc)" || NUMPROC=1
42
43 cd "$WORKSPACE"/build
44
45 #we can't just receive ON or OFF as values as display is bad in the resulting jenkins matrix
46
47 if [ "$1" = "MC" ]
48 then
49   buildmc="ON"
50 else
51   buildmc="OFF"
52 fi
53
54 if [ "$2" = "SMPI" ]
55 then
56   buildsmpi="ON"
57 else
58   buildsmpi="OFF"
59 fi
60
61 if [ "$3" = "DEBUG" ]
62 then
63   builddebug="ON"
64 else
65   builddebug="OFF"
66 fi
67
68 echo "Step ${STEP}/${NSTEPS} - Building with debug=${builddebug}, SMPI=${buildsmpi}, MC=${buildmc}"
69
70 if [ "${builddebug}/${buildsmpi}/${buildmc}" = "ON/ON/ON" ]; then
71     # ${buildmc}=ON because "why not", and especially because it doesn't
72     # compile with -D_GLIBCXX_DEBUG and -Denable_ns3=ON together
73     export CXXFLAGS=-D_GLIBCXX_DEBUG
74     runtests="ON"
75 else
76     runtests="OFF"
77 fi
78
79 cmake -Denable_documentation=OFF \
80       -Denable_compile_optimizations=OFF -Denable_compile_warnings=ON \
81       -Denable_mallocators=ON -Denable_debug=${builddebug} \
82       -Denable_smpi=${buildsmpi} -Denable_smpi_MPICH3_testsuite=${buildsmpi} -Denable_model-checking=${buildmc} \
83       -Denable_memcheck=OFF -Denable_memcheck_xml=OFF -Denable_smpi_MBI_testsuite=OFF \
84       -Denable_ns3=$(onoff test "$buildmc" != "ON") -DNS3_HINT=/builds/ns-3-dev/build/ \
85       -Denable_coverage=OFF -DLTO_EXTRA_FLAG="auto" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
86       "$WORKSPACE"
87
88 make -j$NUMPROC tests
89
90 if [ "$runtests" = "ON" ]; then
91     # exclude tests known to fail with _GLIBCXX_DEBUG
92     ctest -j$NUMPROC -E '^[ps]thread-|mc-bugged1-liveness'
93 fi
94
95 cd ..
96 rm -rf build