Logo AND Algorithmique Numérique Distribuée

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