Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[jenkins] that was a bad idea
[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 # The paths are not the same on all platforms, unfortunately.
44 #test -e /bin/tar  || die 1 "I need tar to compile. Please fix your slave."
45 #test -e /bin/gzip || die 1 "I need gzip to compile. Please fix your slave."
46 #test -e /usr/include/libunwind.h || die 1 "I need libunwind to compile. Please fix your slave."
47 #test -e /usr/include/valgrind/valgrind.h || die 1 "I need valgrind to compile. Please fix your slave."
48
49 build_mode="$1"
50 echo "Build mode $build_mode on $(uname -np)" >&2
51 case "$build_mode" in
52   "Debug")
53   ;;
54
55   "ModelChecker")
56   ;;
57
58   "DynamicAnalysis")
59   ;;
60
61   *)
62     die 1 "Unknown build_mode $build_mode"
63   ;;
64 esac
65
66 if test "$(uname -o)" = "Msys"; then
67   if [ -z "$NUMBER_OF_PROCESSORS" ]; then
68     NUMBER_OF_PROCESSORS=1
69   fi
70   GENERATOR="MSYS Makefiles"
71 else
72   NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
73   GENERATOR="Unix Makefiles"
74 fi
75
76 ulimit -c 0 || true
77
78 if test "$(uname -o)" != "Msys"; then
79   echo "XX"
80   echo "XX Get out of the tree"
81   echo "XX"
82   if [ -d $WORKSPACE/build ]
83   then
84     rm -rf $WORKSPACE/build
85   fi
86   mkdir $WORKSPACE/build
87   cd $WORKSPACE/build
88
89   echo "XX"
90   echo "XX Build the archive out of the tree"
91   echo "XX   pwd: `pwd`"
92   echo "XX"
93
94   cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
95   make dist -j$NUMBER_OF_PROCESSORS
96
97   echo "XX"
98   echo "XX Open the resulting archive"
99   echo "XX"
100   tar xzf `cat VERSION`.tar.gz
101   cd `cat VERSION`
102 fi
103
104 echo "XX"
105 echo "XX Configure and build SimGrid"
106 echo "XX   pwd: `pwd`"
107 echo "XX"
108 cmake -G"$GENERATOR"\
109   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
110   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
111   -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
112   -Denable_compile_optimizations=$(onoff test "$build_mode" = "Debug") \
113   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" != "DynamicAnalysis") \
114   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
115   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
116   -Denable_compile_warnings=ON -Denable_smpi=ON \
117   -Denable_latency_bound_tracking=OFF -Denable_jedule=OFF \
118   -Denable_tracing=ON -Denable_java=ON -Denable_lua=OFF
119 #  -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
120
121
122 make -j$NUMBER_OF_PROCESSORS VERBOSE=1
123
124 if test "$(uname -o)" != "Msys"; then
125   cd $WORKSPACE/build
126   cd `cat VERSION`
127 fi
128
129 TRES=0
130
131 echo "XX"
132 echo "XX Run the tests"
133 echo "XX   pwd: `pwd`"
134 echo "XX"
135
136 ctest -T test --output-on-failure --no-compress-output || true
137 if [ -f Testing/TAG ] ; then
138    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/`head -n 1 < Testing/TAG`/Test.xml > CTestResults.xml
139    mv CTestResults.xml $WORKSPACE
140 fi
141
142 echo "XX"
143 echo "XX Done. Return the results to cmake"
144 echo "XX"
145
146 if [ "$build_mode" = "DynamicAnalysis" ]
147 then
148   ctest -D ContinuousStart
149   ctest -D ContinuousConfigure
150   ctest -D ContinuousBuild
151   ctest -D ContinuousMemCheck
152   ctest -D ContinuousSubmit
153 fi
154
155 ctest -D ContinuousStart
156 ctest -D ContinuousConfigure
157 ctest -D ContinuousBuild
158 ctest -D ContinuousTest
159 ctest -D ContinuousSubmit
160
161 rm -rf `cat VERSION`