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:"
21 # usage: die status message...
25 [ $# -gt 0 ] || set -- "Error - Halting"
30 # Get an ON/OFF string from a command:
32 if "$@" > /dev/null ; then
39 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
42 ver="$(lsb_release -sr) ($(lsb_release -sc))"
43 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
47 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
49 ver=$(cat /etc/debian_version)
50 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
51 read -r os ver < /etc/redhat-release
52 elif [ -f /usr/bin/sw_vers ]; then #osx
53 os=$(sw_vers -productName)
54 ver=$(sw_vers -productVersion)
55 elif [ -f /bin/freebsd-version ]; then #freebsd
57 ver=$(freebsd-version -u)
58 elif [ -f /etc/release ]; then #openindiana
59 read -r os ver < /etc/release
60 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
65 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
66 echo "fallback as OS name not found"
71 # Are we running on wsl ?
72 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
73 #To identify the windows underneath the linux
74 PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
75 major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
76 build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
77 ver="$major v$build - WSL $os $ver"
92 echo "OS Version : $os $ver $bits"
96 echo "Build mode $build_mode on $(uname -np)" >&2
99 INSTALL="$HOME/simgrid_install"
103 INSTALL="$HOME/mc_simgrid_install"
111 die 1 "Unknown build_mode $build_mode"
115 if [ "$2" = "" ]; then
116 branch_name="unknown"
120 echo "Branch built is $branch_name"
122 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
123 GENERATOR="Unix Makefiles"
128 echo "XX Get out of the tree"
130 if [ -d "$WORKSPACE"/build ]
132 # Windows cannot remove the directory if it's still used by the previous build
133 rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build
135 mkdir "$WORKSPACE"/build
136 cd "$WORKSPACE"/build
139 if [ "$os" = "Debian" ] ; then
140 if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.28; then
144 if [ "$os" = "nixos" ] ; then
147 echo "XX have_NS3: ${have_NS3}"
149 SIMGRID_PYTHON_LIBDIR=""
150 if [ "$os" = "nixos" ] ; then
151 SIMGRID_PYTHON_LIBDIR="/home/ci/simgrid_install/lib64"
153 echo "XX SIMGRID_PYTHON_LIBDIR: ${SIMGRID_PYTHON_LIBDIR}"
155 # This is for Windows:
156 PATH="$WORKSPACE/build/lib:$PATH"
159 echo "XX Build the archive out of the tree"
160 echo "XX pwd: $(pwd)"
163 cmake -G"$GENERATOR" -Denable_documentation=OFF "$WORKSPACE"
164 make dist -j $NUMBER_OF_PROCESSORS
165 SIMGRID_VERSION=$(cat VERSION)
168 echo "XX Open the resulting archive"
170 gunzip "${SIMGRID_VERSION}".tar.gz
171 tar xf "${SIMGRID_VERSION}".tar
172 mkdir "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
173 cd "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
174 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
177 echo "XX Configure and build SimGrid"
178 echo "XX pwd: $(pwd)"
182 if [ "$os" = "CentOS" ]; then
183 if [ "$(ld -v | cut -d\ -f4 | cut -c1-4)" = "2.30" ]; then
184 echo "Temporary disable LTO, believed to be broken on this system."
185 MAY_DISABLE_LTO=-Denable_lto=OFF
191 if [ $NODE_NAME = "armv8" ]; then
192 echo "disable LTO, believed to be too heavy for this particular system"
193 MAY_DISABLE_LTO=-Denable_lto=OFF
196 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
197 -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
198 -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
199 -Denable_smpi_MBI_testsuite=OFF \
200 -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
201 -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
202 -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
203 -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
204 -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
205 -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
206 -DSIMGRID_PYTHON_LIBDIR=${SIMGRID_PYTHON_LIBDIR} \
207 -DCMAKE_DISABLE_SOURCE_CHANGES=ON ${MAY_DISABLE_LTO} \
208 -DLTO_EXTRA_FLAG="auto" \
209 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
213 make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests
216 echo "XX Run the tests"
217 echo "XX pwd: "$(pwd)
220 ctest -T test --output-on-failure --no-compress-output -j $NUMBER_OF_PROCESSORS || true
222 if test -n "$INSTALL" && [ "${branch_name}" = "origin/master" ] ; then
224 echo "XX Test done. Install everything since it's a regular build, not on a Windows."
233 echo "XX Done. Return the results to cmake"