Logo AND Algorithmique Numérique Distribuée

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