3 # This script is used by various build projects on Jenkins
5 case "$JENKINS_HOME" in
7 echo "Build skipped on $JENKINS_HOME."
12 # See https://ci.inria.fr/simgrid/job/SimGrid/configure
13 # See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
15 # ensure that the locales are set, so that perl keeps its nerves
18 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
20 rm -f /tmp/simgrid-mc-*
29 # usage: die status message...
33 [ $# -gt 0 ] || set -- "Error - Halting"
38 # Get an ON/OFF string from a command:
40 if "$@" > /dev/null ; then
47 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
50 ver="$(lsb_release -sr) ($(lsb_release -sc))"
51 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
55 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
57 ver=$(cat /etc/debian_version)
58 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
59 read -r os ver < /etc/redhat-release
60 elif [ -f /usr/bin/sw_vers ]; then #osx
61 os=$(sw_vers -productName)
62 ver=$(sw_vers -productVersion)
63 elif [ -f /bin/freebsd-version ]; then #freebsd
65 ver=$(freebsd-version -u)
66 elif [ -f /etc/release ]; then #openindiana
67 read -r os ver < /etc/release
68 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
73 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
74 echo "fallback as OS name not found"
79 # Are we running on wsl ?
80 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
81 #To identify the windows underneath the linux
82 PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
83 major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
84 build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
85 ver="$major v$build - WSL $os $ver"
100 echo "OS Version : $os $ver $bits"
104 echo "Build mode $build_mode on $(uname -np)" >&2
105 case "$build_mode" in
107 INSTALL="$HOME/simgrid_install"
111 INSTALL="$HOME/mc_simgrid_install"
119 die 1 "Unknown build_mode $build_mode"
123 if [ "$2" = "" ]; then
124 branch_name="unknown"
128 echo "Branch built is $branch_name"
130 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
131 GENERATOR="Unix Makefiles"
133 VERBOSE_BUILD="VERBOSE=1"
134 if which ninja 2>/dev/null >/dev/null ; then
143 echo "XX Get out of the tree"
145 if [ -d "$WORKSPACE"/build ]
147 # Windows cannot remove the directory if it's still used by the previous build
148 rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build
150 mkdir "$WORKSPACE"/build
151 cd "$WORKSPACE"/build
154 if [ "$os" = "Debian" ] ; then
155 if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.28; then
159 if [ "$os" = "nixos" ] ; then
162 echo "XX have_NS3: ${have_NS3}"
164 SIMGRID_PYTHON_LIBDIR=""
165 if [ "$os" = "nixos" ] ; then
166 SIMGRID_PYTHON_LIBDIR="/home/ci/simgrid_install/lib64"
168 echo "XX SIMGRID_PYTHON_LIBDIR: ${SIMGRID_PYTHON_LIBDIR}"
170 # This is for Windows:
171 PATH="$WORKSPACE/build/lib:$PATH"
174 echo "XX Build the archive out of the tree"
175 echo "XX pwd: $(pwd)"
178 cmake -G"$GENERATOR" -Denable_documentation=OFF "$WORKSPACE"
179 ${BUILDER} dist -j $NUMBER_OF_PROCESSORS
180 SIMGRID_VERSION=$(cat VERSION)
183 echo "XX Open the resulting archive"
185 gunzip "${SIMGRID_VERSION}".tar.gz
186 tar xf "${SIMGRID_VERSION}".tar
187 mkdir "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
188 cd "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
189 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
192 echo "XX Configure and build SimGrid"
193 echo "XX pwd: $(pwd)"
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
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
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_testsuite_smpi_MBI=OFF -Denable_testsuite_McMini=ON \
215 -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
216 -Denable_testsuite_smpi_MPICH3=$(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 -DCMAKE_DISABLE_SOURCE_CHANGES=ON ${MAY_DISABLE_LTO} \
223 -DLTO_EXTRA_FLAG="auto" \
224 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
227 ${BUILDER} -j $NUMBER_OF_PROCESSORS ${VERBOSE_BUILD} tests
230 echo "XX Run the tests"
231 echo "XX pwd: "$(pwd)
234 ctest -T test --output-on-failure --no-compress-output -j $NUMBER_OF_PROCESSORS || true
236 if test -n "$INSTALL" && [ "${branch_name}" = "origin/master" ] ; then
238 echo "XX Test done. Install everything since it's a regular build, not on a Windows."
247 echo "XX Done. Return the results to cmake"