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 {} +
26 if [ -e /usr/lib/jvm/java-7-openjdk-amd64 ] ;
28 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
31 # usage: die status message...
35 [ $# -gt 0 ] || set -- "Error - Halting"
40 # Get an ON/OFF string from a command:
42 if "$@" > /dev/null ; then
49 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
52 ver="$(lsb_release -sr) ($(lsb_release -sc))"
53 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
57 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
59 ver=$(cat /etc/debian_version)
60 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
61 read -r os ver < /etc/redhat-release
62 elif [ -f /usr/bin/sw_vers ]; then #osx
63 os=$(sw_vers -productName)
64 ver=$(sw_vers -productVersion)
65 elif [ -f /bin/freebsd-version ]; then #freebsd
67 ver=$(freebsd-version -u)
68 elif [ -f /etc/release ]; then #openindiana
69 read -r os ver < /etc/release
70 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
75 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
76 echo "fallback as OS name not found"
81 # Are we running on wsl ?
82 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
83 #To identify the windows underneath the linux
84 PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
85 major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
86 build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
87 ver="$major v$build - WSL $os $ver"
102 echo "OS Version : $os $ver $bits"
106 echo "Build mode $build_mode on $(uname -np)" >&2
107 case "$build_mode" in
109 INSTALL="$HOME/simgrid_install"
113 INSTALL="$HOME/mc_simgrid_install"
121 die 1 "Unknown build_mode $build_mode"
125 if [ "$2" = "" ]; then
126 branch_name="unknown"
130 echo "Branch built is $branch_name"
132 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
133 GENERATOR="Unix Makefiles"
138 echo "XX Get out of the tree"
140 if [ -d "$WORKSPACE"/build ]
142 # Windows cannot remove the directory if it's still used by the previous build
143 rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build || sleep 10 && rm -rf "$WORKSPACE"/build
145 mkdir "$WORKSPACE"/build
146 cd "$WORKSPACE"/build
149 if [ "$os" = "Debian" ] || [ "$os" = "Ubuntu" ] ; then
150 if dpkg --compare-versions "$(dpkg-query -f '${Version}' -W libns3-dev)" ge 3.28; then
154 if [ "$os" = "NixOS" ] ; then
157 echo "XX have_NS3: ${have_NS3}"
159 SIMGRID_PYTHON_LIBDIR=""
160 if [ "$os" = "NixOS" ] ; then
161 SIMGRID_PYTHON_LIBDIR="/home/ci/simgrid_install/lib64"
163 echo "XX SIMGRID_PYTHON_LIBDIR: ${SIMGRID_PYTHON_LIBDIR}"
165 # This is for Windows:
166 PATH="$WORKSPACE/build/lib:$PATH"
169 echo "XX Build the archive out of the tree"
170 echo "XX pwd: $(pwd)"
173 cmake -G"$GENERATOR" -Denable_documentation=OFF "$WORKSPACE"
174 make dist -j $NUMBER_OF_PROCESSORS
175 SIMGRID_VERSION=$(cat VERSION)
178 echo "XX Open the resulting archive"
180 gunzip "${SIMGRID_VERSION}".tar.gz
181 tar xf "${SIMGRID_VERSION}".tar
182 mkdir "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
183 cd "${WORKSPACE}"/build/"${SIMGRID_VERSION}"/build
184 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
187 echo "XX Configure and build SimGrid"
188 echo "XX pwd: $(pwd)"
192 if cmake --version | grep -q 3\.11 ; then
193 # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
194 # https://gitlab.kitware.com/cmake/cmake/issues/17933
195 MAY_DISABLE_SOURCE_CHANGE=""
197 MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
200 if [ "$os" = "CentOS" ] && [ "$(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
207 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
208 -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
209 -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
210 -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
211 -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
212 -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
213 -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
214 -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
215 -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
216 -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
217 -DSIMGRID_PYTHON_LIBDIR=${SIMGRID_PYTHON_LIBDIR} \
218 ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} \
219 -Denable_java=$(onoff test "$build_mode" = "ModelChecker") \
220 -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \
221 -DLTO_EXTRA_FLAG="auto" \
225 make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests
228 echo "XX Run the tests"
229 echo "XX pwd: "$(pwd)
232 ctest -T test --output-on-failure --no-compress-output -j $NUMBER_OF_PROCESSORS || true
234 if test -n "$INSTALL" && [ "${branch_name}" = "origin/master" ] ; then
236 echo "XX Test done. Install everything since it's a regular build, not on a Windows."
245 echo "XX Done. Return the results to cmake"