Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove Java bindings. They are not updated since maybe 10 years
[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/configure
6 # See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
7
8 # ensure that the locales are set, so that perl keeps its nerves
9 export LC_ALL=C
10
11 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
12 rm -f /tmp/cc*
13 rm -f /tmp/*.so
14 rm -f /tmp/*.so.*
15 rm -rf /tmp/jvm-*
16 find $WORKSPACE -name "hs_err_pid*.log" -exec rm -f {} +
17 ls /tmp
18 df -h
19 echo "XXXX Let's go"
20
21 set -e
22
23 # usage: die status message...
24 die () {
25   status=${1:-1}
26   shift
27   [ $# -gt 0 ] || set -- "Error - Halting"
28   echo "$@" >&2
29   exit "$status"
30 }
31
32 # Get an ON/OFF string from a command:
33 onoff() {
34   if "$@" > /dev/null ; then
35     echo ON
36   else
37     echo OFF
38   fi
39 }
40
41 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
42     # linuxbase.org
43     os=$(lsb_release -si)
44     ver="$(lsb_release -sr) ($(lsb_release -sc))"
45 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
46     . /etc/lsb-release
47     os=$DISTRIB_ID
48     ver=$DISTRIB_RELEASE
49 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
50     os=Debian
51     ver=$(cat /etc/debian_version)
52 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
53     read -r os ver < /etc/redhat-release
54 elif [ -f /usr/bin/sw_vers ]; then #osx
55     os=$(sw_vers -productName)
56     ver=$(sw_vers -productVersion)
57 elif [ -f /bin/freebsd-version ]; then #freebsd
58     os=$(uname -s)
59     ver=$(freebsd-version -u)
60 elif [ -f /etc/release ]; then #openindiana
61     read -r os ver < /etc/release
62 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
63     . /etc/os-release
64     os=$NAME
65     ver=$VERSION_ID
66 else
67     # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
68     echo "fallback as OS name not found"
69     os=$(uname -s)
70     ver=$(uname -r)
71 fi
72
73 # Are we running on wsl ?
74 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
75     #To identify the windows underneath the linux
76     PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
77     major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
78     build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
79     ver="$major v$build - WSL $os $ver"
80     os=Windows
81 fi
82
83 case $(uname -m) in
84 x86_64)
85     bits="64 bits"
86     ;;
87 i*86)
88     bits="32 bits"
89     ;;
90 *)
91     bits=""
92     ;;
93 esac
94 echo "OS Version : $os $ver $bits"
95
96
97 build_mode="$1"
98 echo "Build mode $build_mode on $(uname -np)" >&2
99 case "$build_mode" in
100   "Debug")
101       INSTALL="$HOME/simgrid_install"
102   ;;
103
104   "ModelChecker")
105       INSTALL="$HOME/mc_simgrid_install"
106   ;;
107
108   "DynamicAnalysis")
109       INSTALL=""
110   ;;
111
112   *)
113     die 1 "Unknown build_mode $build_mode"
114   ;;
115 esac
116
117 if [ "$2" = "" ]; then
118   branch_name="unknown"
119 else
120   branch_name="$2"
121 fi
122 echo "Branch built is $branch_name"
123
124 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
125 GENERATOR="Unix Makefiles"
126
127 ulimit -c 0 || true
128
129 echo "XX"
130 echo "XX Get out of the tree"
131 echo "XX"
132 if [ -d "$WORKSPACE"/build ]
133 then
134   # Windows cannot remove the directory if it's still used by the previous build
135   rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build
136 fi
137 mkdir "$WORKSPACE"/build
138 cd "$WORKSPACE"/build
139
140 have_NS3="no"
141 if [ "$os" = "Debian" ] ; then
142   if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.28; then
143     have_NS3="yes"
144   fi
145 fi
146 MAY_HINT_AT_NS3=""
147 if [ $NODE_NAME = "ubuntu-lts" ] ; then
148   MAY_HINT_AT_NS3="-DNS3_HINT=/builds/ns-3-dev/build/"
149   have_NS3="yes"
150 fi
151 if [ "$os" = "nixos" ] ; then
152   have_NS3="yes"
153 fi
154 echo "XX have_NS3: ${have_NS3}"
155
156 SIMGRID_PYTHON_LIBDIR=""
157 if [ "$os" = "nixos" ] ; then
158   SIMGRID_PYTHON_LIBDIR="/home/ci/simgrid_install/lib64"
159 fi
160 echo "XX SIMGRID_PYTHON_LIBDIR: ${SIMGRID_PYTHON_LIBDIR}"
161
162 # This is for Windows:
163 PATH="$WORKSPACE/build/lib:$PATH"
164
165 echo "XX"
166 echo "XX Build the archive out of the tree"
167 echo "XX   pwd: $(pwd)"
168 echo "XX"
169
170 cmake -G"$GENERATOR" -Denable_documentation=OFF "$WORKSPACE"
171 make dist -j $NUMBER_OF_PROCESSORS
172 SIMGRID_VERSION=$(cat VERSION)
173
174 echo "XX"
175 echo "XX Open the resulting archive"
176 echo "XX"
177 gunzip "${SIMGRID_VERSION}".tar.gz
178 tar xf "${SIMGRID_VERSION}".tar
179 mkdir "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
180 cd "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
181 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
182
183 echo "XX"
184 echo "XX Configure and build SimGrid"
185 echo "XX   pwd: $(pwd)"
186 echo "XX"
187 set -x
188
189 if cmake --version | grep -q 3\.11 ; then
190   # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
191   # https://gitlab.kitware.com/cmake/cmake/issues/17933
192   MAY_DISABLE_SOURCE_CHANGE=""
193 else
194   MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
195 fi
196
197 if [ "$os" = "CentOS" ]; then
198     if [ "$(ld -v | cut -d\  -f4 | cut -c1-4)" = "2.30" ]; then
199         echo "Temporary disable LTO, believed to be broken on this system."
200         MAY_DISABLE_LTO=-Denable_lto=OFF
201     else
202         MAY_DISABLE_LTO=
203     fi
204 fi
205
206 if [ $NODE_NAME = "armv8" ]; then
207     echo "disable LTO, believed to be too heavy for this particular system"
208     MAY_DISABLE_LTO=-Denable_lto=OFF
209 fi
210
211 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
212   -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
213   -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
214   -Denable_smpi_MBI_testsuite=OFF \
215   -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
216   -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
217   -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
218   -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
219   -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
220   -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
221   -DSIMGRID_PYTHON_LIBDIR=${SIMGRID_PYTHON_LIBDIR} \
222   ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} ${MAY_HINT_AT_NS3} \
223   -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \
224   -DLTO_EXTRA_FLAG="auto" \
225   -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
226   "$SRCFOLDER"
227 set +x
228
229 make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests
230
231 echo "XX"
232 echo "XX Run the tests"
233 echo "XX   pwd: "$(pwd)
234 echo "XX"
235
236 ctest -T test --output-on-failure --no-compress-output -j $NUMBER_OF_PROCESSORS || true
237
238 if test -n "$INSTALL" && [ "${branch_name}" = "origin/master" ] ; then
239   echo "XX"
240   echo "XX Test done. Install everything since it's a regular build, not on a Windows."
241   echo "XX"
242
243   rm -rf "$INSTALL"
244
245   make install
246 fi
247
248 echo "XX"
249 echo "XX Done. Return the results to cmake"
250 echo "XX"