Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0ad4f199967bfa5dd8cf1682d6c2599e0f33ed32
[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 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
11 rm -rf /tmp/simgrid-java*
12 rm -rf /tmp/jvm-* 
13 find /builds/workspace/SimGrid-Multi/ -name "hs_err_pid*.log" | xargs rm -f
14 ls /tmp
15 df -h
16 echo "XXXX Let's go"
17
18 # Help older cmakes
19 if [ -e /usr/lib/jvm/java-7-openjdk-amd64 ] ; 
20 then
21   export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
22 fi
23
24 # usage: die status message...
25 die () {
26   local status=${1:-1}
27   shift
28   [ $# -gt 0 ] || set -- "Error - Halting"
29   echo "$@" >&2
30   exit $status
31 }
32
33 # Get an ON/OFF string from a command:
34 onoff() {
35   if "$@" > /dev/null ; then
36     echo ON
37   else
38     echo OFF
39   fi
40 }
41
42 # Check that we have what we need, or die quickly
43 test -e /bin/tar  || die 1 "I need tar to compile. Please fix your slave."
44 test -e /bin/gzip || die 1 "I need gzip to compile. Please fix your slave."
45 #test -e /usr/include/libunwind.h || die 1 "I need libunwind to compile. Please fix your slave."
46 #test -e /usr/include/valgrind/valgrind.h || die 1 "I need valgrind to compile. Please fix your slave."
47
48 build_mode="$1"
49 echo "Build mode $build_mode on $(uname -np)" >&2
50 case "$build_mode" in
51   "Debug")
52   ;;
53
54   "ModelChecker")
55   ;;
56
57   "DynamicAnalysis")
58   ;;
59
60   *)
61     die 1 "Unknown build_mode $build_mode"
62   ;;
63 esac
64
65 if test "$(uname -o)" = "Msys"; then
66   if [ -z "$NUMBER_OF_PROCESSORS" ]; then
67     NUMBER_OF_PROCESSORS=1
68   fi
69   GENERATOR="MSYS Makefiles"
70 else
71   NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
72   GENERATOR="Unix Makefiles"
73 fi
74
75 ulimit -c 0 || true
76
77 if test "$(uname -o)" != "Msys"; then
78   echo "XX"
79   echo "XX Get out of the tree"
80   echo "XX"
81   if [ -d $WORKSPACE/build ]
82   then
83     rm -rf $WORKSPACE/build
84   fi
85   mkdir $WORKSPACE/build
86   cd $WORKSPACE/build
87
88   echo "XX"
89   echo "XX Build the archive out of the tree"
90   echo "XX   pwd: `pwd`"
91   echo "XX"
92
93   cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
94   make dist -j$NUMBER_OF_PROCESSORS
95
96   echo "XX"
97   echo "XX Open the resulting archive"
98   echo "XX"
99   tar xzf `cat VERSION`.tar.gz
100   cd `cat VERSION`
101 fi
102
103 echo "XX"
104 echo "XX Configure and build SimGrid"
105 echo "XX   pwd: `pwd`"
106 echo "XX"
107 cmake -G"$GENERATOR"\
108   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
109   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
110   -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
111   -Denable_compile_optimizations=$(onoff test "$build_mode" = "Debug") \
112   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" != "DynamicAnalysis") \
113   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
114   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
115   -Denable_compile_warnings=ON -Denable_smpi=ON \
116   -Denable_latency_bound_tracking=OFF -Denable_jedule=OFF \
117   -Denable_tracing=ON -Denable_java=ON -Denable_lua=OFF
118 #  -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
119
120
121 make -j$NUMBER_OF_PROCESSORS VERBOSE=1
122
123 if test "$(uname -o)" != "Msys"; then
124   cd $WORKSPACE/build
125   cd `cat VERSION`
126 fi
127
128 TRES=0
129
130 echo "XX"
131 echo "XX Run the tests"
132 echo "XX   pwd: `pwd`"
133 echo "XX"
134
135 ctest -T test --output-on-failure --no-compress-output || true
136 if [ -f Testing/TAG ] ; then
137    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
138    mv CTestResults.xml $WORKSPACE
139 fi
140
141 echo "XX"
142 echo "XX Done. Return the results to cmake"
143 echo "XX"
144
145 if [ "$build_mode" = "DynamicAnalysis" ]
146 then
147   ctest -D ContinuousStart
148   ctest -D ContinuousConfigure
149   ctest -D ContinuousBuild
150   ctest -D ContinuousMemCheck
151   ctest -D ContinuousSubmit
152 fi
153
154 ctest -D ContinuousStart
155 ctest -D ContinuousConfigure
156 ctest -D ContinuousBuild
157 ctest -D ContinuousTest
158 ctest -D ContinuousSubmit
159
160 rm -rf `cat VERSION`