Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
63bb5835db1dae4c7d4ac6e7ceb0b2de26bb12db
[simgrid.git] / tools / jenkins / build.sh
1 #!/bin/sh
2
3 # This script is used by various build projects on Jenkins
4
5 # See https://ci.inria.fr/simgrid/job/SimGrid-Multi/configure
6 # See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
7
8 set -e
9
10 # Cleanup previous attempts
11 rm -rf /tmp/simgrid*tmp
12 rm -rf /tmp/surf-java*tmp
13
14 # usage: die status message...
15 die () {
16   local status=${1:-1}
17   shift
18   [ $# -gt 0 ] || set -- "Error - Halting"
19   echo "$@" >&2
20   exit $status
21 }
22
23 # Get an ON/OFF string from a command:
24 onoff() {
25   if "$@" > /dev/null ; then
26     echo ON
27   else
28     echo OFF
29   fi
30 }
31
32 build_mode="$1"
33 echo "Build mode $build_mode on $(uname -np)" >&2
34 case "$build_mode" in
35   "Debug")
36   ;;
37
38   "ModelChecker")
39   ;;
40
41   "DynamicAnalysis")
42   ;;
43
44   *)
45     die 1 "Unknown build_mode $build_mode"
46   ;;
47 esac
48
49 if test "$(uname -o)" = "Msys"; then
50   if [ -z "$NUMBER_OF_PROCESSORS" ]; then
51     NUMBER_OF_PROCESSORS=1
52   fi
53   GENERATOR="MSYS Makefiles"
54 else
55   NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
56   GENERATOR="Unix Makefiles"
57 fi
58
59 ulimit -c 0 || true
60
61 if test "$(uname -o)" != "Msys"; then
62   echo "XX"
63   echo "XX Get out of the tree"
64   echo "XX"
65   if [ -d $WORKSPACE/build ]
66   then
67     rm -rf $WORKSPACE/build
68   fi
69   mkdir $WORKSPACE/build
70   cd $WORKSPACE/build
71
72   echo "XX"
73   echo "XX Build the archive out of the tree"
74   echo "XX   pwd: `pwd`"
75   echo "XX"
76
77   cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
78   make dist -j$NUMBER_OF_PROCESSORS
79
80   echo "XX"
81   echo "XX Open the resulting archive"
82   echo "XX"
83   tar xzf `cat VERSION`.tar.gz
84   cd `cat VERSION`
85 fi
86
87 echo "XX"
88 echo "XX Configure and build SimGrid"
89 echo "XX   pwd: `pwd`"
90 echo "XX"
91 cmake -G"$GENERATOR"\
92   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
93   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
94   -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
95   -Denable_compile_optimizations=$(onoff test "$build_mode" = "Debug") \
96   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" != "DynamicAnalysis") \
97   -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
98   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
99   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
100   -Denable_compile_warnings=ON -Denable_smpi=ON -Denable_lib_static=OFF \
101   -Denable_latency_bound_tracking=OFF -Denable_jedule=OFF \
102   -Denable_tracing=ON -Denable_java=ON
103 make -j$NUMBER_OF_PROCESSORS VERBOSE=1
104
105 if test "$(uname -o)" != "Msys"; then
106   cd $WORKSPACE/build
107   cd `cat VERSION`
108 fi
109
110 TRES=0
111
112 echo "XX"
113 echo "XX Run the tests"
114 echo "XX   pwd: `pwd`"
115 echo "XX"
116
117 ctest -T test --output-on-failure --no-compress-output || true
118 if [ -f Testing/TAG ] ; then
119    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
120    mv CTestResults.xml $WORKSPACE
121 fi
122
123 echo "XX"
124 echo "XX Done. Return the results to cmake"
125 echo "XX"
126
127 if [ "$build_mode" = "DynamicAnalysis" ]
128 then
129   ctest -D ContinuousStart
130   ctest -D ContinuousConfigure
131   ctest -D ContinuousBuild
132   ctest -D ContinuousMemCheck
133   ctest -D ContinuousSubmit
134 fi
135
136 ctest -D ContinuousStart
137 ctest -D ContinuousConfigure
138 ctest -D ContinuousBuild
139 ctest -D ContinuousTest
140 ctest -D ContinuousSubmit
141
142 rm -rf `cat VERSION`