Logo AND Algorithmique Numérique Distribuée

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