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
10 # ensure that the locales are set, so that perl keeps its nerves
13 echo "XXXX Cleanup previous attempts. Remaining content of /tmp:"
14 rm -rf /tmp/simgrid-java*
15 rm -rf /var/tmp/simgrid-java*
17 find /builds/workspace/SimGrid/ -name "hs_err_pid*.log" -exec rm -f {} +
23 if [ -e /usr/lib/jvm/java-7-openjdk-amd64 ] ;
25 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
28 # usage: die status message...
32 [ $# -gt 0 ] || set -- "Error - Halting"
37 # Get an ON/OFF string from a command:
39 if "$@" > /dev/null ; then
46 if type lsb_release >/dev/null 2>&1; then # recent versions of Debian/Ubuntu
49 ver="$(lsb_release -sr) ($(lsb_release -sc))"
50 elif [ -f /etc/lsb-release ]; then # For some versions of Debian/Ubuntu without lsb_release command
54 elif [ -f /etc/debian_version ]; then # Older Debian/Ubuntu/etc.
56 ver=$(cat /etc/debian_version)
57 elif [ -f /etc/redhat-release ]; then #RH, Fedora, Centos
58 read -r os ver < /etc/redhat-release
59 elif [ -f /usr/bin/sw_vers ]; then #osx
60 os=$(sw_vers -productName)
61 ver=$(sw_vers -productVersion)
62 elif [ -f /bin/freebsd-version ]; then #freebsd
64 ver=$(freebsd-version -u)
65 elif [ -f /etc/release ]; then #openindiana
66 read -r os ver < /etc/release
67 elif [ -f /etc/os-release ]; then # freedesktop.org and systemd, put last as usually missing useful info
72 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
73 echo "fallback as OS name not found"
78 # Are we running on wsl ?
79 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
80 #To identify the windows underneath the linux
81 PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
82 major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
83 build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
84 ver="$major v$build - WSL $os $ver"
99 echo "OS Version : $os $ver $bits"
103 echo "Build mode $build_mode on $(uname -np)" >&2
104 case "$build_mode" in
106 INSTALL="/builds/simgrid_install"
110 INSTALL="/builds/mc_simgrid_install"
118 die 1 "Unknown build_mode $build_mode"
122 if [ "$2" = "" ]; then
123 branch_name="unknown"
127 echo "Branch built is $branch_name"
129 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
130 GENERATOR="Unix Makefiles"
135 echo "XX Get out of the tree"
137 if [ -d $WORKSPACE/build ]
139 # Windows cannot remove the directory if it's still used by the previous build
140 rm -rf $WORKSPACE/build || sleep 10 && rm -rf $WORKSPACE/build || sleep 10 && rm -rf $WORKSPACE/build
142 mkdir $WORKSPACE/build
146 if dpkg -l libns3-dev 2>&1|grep -q "ii libns3-dev" ; then
149 echo "XX have_NS3: ${have_NS3}"
151 # This is for Windows:
152 PATH="$WORKSPACE/build/lib:$PATH"
155 echo "XX Build the archive out of the tree"
156 echo "XX pwd: "$(pwd)
159 cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
160 make dist -j $NUMBER_OF_PROCESSORS
161 SIMGRID_VERSION=$(cat VERSION)
164 echo "XX Open the resulting archive"
166 gunzip ${SIMGRID_VERSION}.tar.gz
167 tar xf ${SIMGRID_VERSION}.tar
168 mkdir ${WORKSPACE}/build/${SIMGRID_VERSION}/build
169 cd ${WORKSPACE}/build/${SIMGRID_VERSION}/build
170 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
173 echo "XX Configure and build SimGrid"
174 echo "XX pwd: "$(pwd)
178 if cmake --version | grep -q 3\.11 ; then
179 # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
180 # https://gitlab.kitware.com/cmake/cmake/issues/17933
181 MAY_DISABLE_SOURCE_CHANGE=""
183 MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
186 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
187 -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
188 -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
189 -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
190 -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
191 -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
192 -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
193 -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
194 -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
195 -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
196 -Denable_jedule=OFF -Denable_lua=OFF ${MAY_DISABLE_SOURCE_CHANGE} \
197 -Denable_java=$(onoff test "$build_mode" = "ModelChecker") \
198 -Denable_msg=$(onoff test "$build_mode" = "ModelChecker") \
199 -DLTO_EXTRA_FLAG="auto" \
201 # -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
204 make -j $NUMBER_OF_PROCESSORS VERBOSE=1 tests
207 echo "XX Run the tests"
208 echo "XX pwd: "$(pwd)
211 ctest -T test --output-on-failure --no-compress-output || true
213 if test -n "$INSTALL" && [ ${branch_name} = "origin/master" ] ; then
215 echo "XX Test done. Install everything since it's a regular build, not on a Windows."
224 echo "XX Done. Return the results to cmake"