Logo AND Algorithmique Numérique Distribuée

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