Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
264f755de6a28ee1a17abbf4b8d9d5edd614807f
[simgrid.git] / tools / jenkins / build.sh
1 #!/usr/bin/env 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       INSTALL="/builds/simgrid_install"
57   ;;
58
59   "ModelChecker")
60       INSTALL="/builds/mc_simgrid_install"
61   ;;
62
63   "DynamicAnalysis")
64       INSTALL=""
65   ;;
66
67   *)
68     die 1 "Unknown build_mode $build_mode"
69   ;;
70 esac
71
72 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
73 GENERATOR="Unix Makefiles"
74
75 ulimit -c 0 || true
76
77 echo "XX"
78 echo "XX Get out of the tree"
79 echo "XX"
80 if [ -d $WORKSPACE/build ]
81 then
82   # Windows cannot remove the directory if it's still used by the previous build
83   rm -rf $WORKSPACE/build || sleep 10 && rm -rf $WORKSPACE/build || sleep 10 && rm -rf $WORKSPACE/build
84 fi
85 mkdir $WORKSPACE/build
86 cd $WORKSPACE/build
87
88 have_NS3="no"
89 if dpkg -l libns3-dev 2>&1|grep -q "ii  libns3-dev" ; then
90   have_NS3="yes"
91 fi
92 echo "XX have_NS3: ${have_NS3}"
93
94 # This is for Windows:
95 PATH="$WORKSPACE/build/lib:$PATH"
96
97 echo "XX"
98 echo "XX Build the archive out of the tree"
99 echo "XX   pwd: "$(pwd)
100 echo "XX"
101
102 cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
103 make dist -j$NUMBER_OF_PROCESSORS
104 SIMGRID_VERSION=$(cat VERSION)
105
106 echo "XX"
107 echo "XX Open the resulting archive"
108 echo "XX"
109 gunzip ${SIMGRID_VERSION}.tar.gz
110 tar xf ${SIMGRID_VERSION}.tar
111 mkdir ${WORKSPACE}/build/${SIMGRID_VERSION}/build
112 cd ${WORKSPACE}/build/${SIMGRID_VERSION}/build
113 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
114
115 echo "XX"
116 echo "XX Configure and build SimGrid"
117 echo "XX   pwd: "$(pwd)
118 echo "XX"
119 set -x
120
121 if cmake --version | grep -q 3\.11 ; then
122   # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
123   # https://gitlab.kitware.com/cmake/cmake/issues/17933
124   MAY_DISABLE_SOURCE_CHANGE=""
125 else 
126   MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
127 fi
128
129 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
130   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
131   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
132   -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
133   -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
134   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
135   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
136   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
137   -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
138   -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
139   -Denable_jedule=OFF -Denable_java=ON -Denable_lua=OFF ${MAY_DISABLE_SOURCE_CHANGE} \
140   $SRCFOLDER
141 #  -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
142 set +x
143
144 make -j$NUMBER_OF_PROCESSORS VERBOSE=1
145
146 echo "XX"
147 echo "XX Run the tests"
148 echo "XX   pwd: "$(pwd)
149 echo "XX"
150
151 ctest -T test --output-on-failure --no-compress-output || true
152 if [ -f Testing/TAG ] ; then
153    xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults.xml
154    mv CTestResults.xml $WORKSPACE
155 fi
156
157 if test -n "$INSTALL"; then
158   echo "XX"
159   echo "XX Test done. Install everything since it's a regular build, not on a Windows."
160   echo "XX"
161
162   rm -rf "$INSTALL"
163
164   make install
165 fi
166
167 echo "XX"
168 echo "XX Done. Return the results to cmake"
169 echo "XX"