3 # This script is used by various build projects on Jenkins
5 # See https://ci.inria.fr/simgrid/job/SimGrid/configure
6 # See https://ci.inria.fr/simgrid/job/Simgrid-Windows/configure
8 # ensure that the locales are set, so that perl keeps its nerves
11 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
15 rm -rf /tmp/simgrid-java*
16 rm -rf /var/tmp/simgrid-java*
18 find $WORKSPACE -name "hs_err_pid*.log" -exec rm -f {} +
25 # usage: die status message...
29 [ $# -gt 0 ] || set -- "Error - Halting"
34 # Get an ON/OFF string from a command:
36 if "$@" > /dev/null ; then
43 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
46 ver="$(lsb_release -sr) ($(lsb_release -sc))"
47 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
51 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
53 ver=$(cat /etc/debian_version)
54 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
55 read -r os ver < /etc/redhat-release
56 elif [ -f /usr/bin/sw_vers ]; then #osx
57 os=$(sw_vers -productName)
58 ver=$(sw_vers -productVersion)
59 elif [ -f /bin/freebsd-version ]; then #freebsd
61 ver=$(freebsd-version -u)
62 elif [ -f /etc/release ]; then #openindiana
63 read -r os ver < /etc/release
64 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
69 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
70 echo "fallback as OS name not found"
75 # Are we running on wsl ?
76 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
77 #To identify the windows underneath the linux
78 PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
79 major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
80 build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
81 ver="$major v$build - WSL $os $ver"
96 echo "OS Version : $os $ver $bits"
100 echo "Build mode $build_mode on $(uname -np)" >&2
101 case "$build_mode" in
103 INSTALL="$HOME/simgrid_install"
107 INSTALL="$HOME/mc_simgrid_install"
115 die 1 "Unknown build_mode $build_mode"
119 if [ "$2" = "" ]; then
120 branch_name="unknown"
124 echo "Branch built is $branch_name"
126 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
127 GENERATOR="Unix Makefiles"
132 echo "XX Get out of the tree"
134 if [ -d "$WORKSPACE"/build ]
136 # Windows cannot remove the directory if it's still used by the previous build
137 rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build
139 mkdir "$WORKSPACE"/build
140 cd "$WORKSPACE"/build
143 if [ "$os" = "Debian" ] ; then
144 if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.28; then
149 if [ $NODE_NAME = "ubuntu-lts" ] ; then
150 MAY_HINT_AT_NS3="-DNS3_HINT=/builds/ns-3-dev/build/"
153 if [ "$os" = "nixos" ] ; then
156 echo "XX have_NS3: ${have_NS3}"
158 SIMGRID_PYTHON_LIBDIR=""
159 if [ "$os" = "nixos" ] ; then
160 SIMGRID_PYTHON_LIBDIR="/home/ci/simgrid_install/lib64"
162 echo "XX SIMGRID_PYTHON_LIBDIR: ${SIMGRID_PYTHON_LIBDIR}"
164 # This is for Windows:
165 PATH="$WORKSPACE/build/lib:$PATH"
168 echo "XX Build the archive out of the tree"
169 echo "XX pwd: $(pwd)"
172 cmake -G"$GENERATOR" -Denable_documentation=OFF "$WORKSPACE"
173 make dist -j $NUMBER_OF_PROCESSORS
174 SIMGRID_VERSION=$(cat VERSION)
177 echo "XX Open the resulting archive"
179 gunzip "${SIMGRID_VERSION}".tar.gz
180 tar xf "${SIMGRID_VERSION}".tar
181 mkdir "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
182 cd "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
183 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
186 echo "XX Configure and build SimGrid"
187 echo "XX pwd: $(pwd)"
191 if cmake --version | grep -q 3\.11 ; then
192 # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
193 # https://gitlab.kitware.com/cmake/cmake/issues/17933
194 MAY_DISABLE_SOURCE_CHANGE=""
196 MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
199 if [ "$os" = "CentOS" ]; then
200 if [ "$(ld -v | cut -d\ -f4 | cut -c1-4)" = "2.30" ]; then
201 echo "Temporary disable LTO, believed to be broken on this system."
202 MAY_DISABLE_LTO=-Denable_lto=OFF
208 if [ $NODE_NAME = "armv8" ]; then
209 echo "disable LTO, believed to be too heavy for this particular system"
210 MAY_DISABLE_LTO=-Denable_lto=OFF
213 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
214 -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
215 -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
216 -Denable_smpi_MBI_testsuite=OFF \
217 -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
218 -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
219 -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
220 -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
221 -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
222 -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
223 -DSIMGRID_PYTHON_LIBDIR=${SIMGRID_PYTHON_LIBDIR} \
224 ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} ${MAY_HINT_AT_NS3} \
225 -Denable_java=$(onoff test "$build_mode" = "ModelChecker") \
226 -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \
227 -DLTO_EXTRA_FLAG="auto" \
228 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
232 make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests
235 echo "XX Run the tests"
236 echo "XX pwd: "$(pwd)
239 ctest -T test --output-on-failure --no-compress-output -j $NUMBER_OF_PROCESSORS || true
241 if test -n "$INSTALL" && [ "${branch_name}" = "origin/master" ] ; then
243 echo "XX Test done. Install everything since it's a regular build, not on a Windows."
252 echo "XX Done. Return the results to cmake"