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*
16 find /builds/workspace/SimGrid/ -name "hs_err_pid*.log" | xargs rm -f
22 if [ -e /usr/lib/jvm/java-7-openjdk-amd64 ] ;
24 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
27 # usage: die status message...
31 [ $# -gt 0 ] || set -- "Error - Halting"
36 # Get an ON/OFF string from a command:
38 if "$@" > /dev/null ; then
45 # Check that we have what we need, or die quickly.
46 # The paths are not the same on all platforms, unfortunately.
47 #test -e /bin/tar || die 1 "I need tar to compile. Please fix your slave."
48 #test -e /bin/gzip || die 1 "I need gzip to compile. Please fix your slave."
49 #test -e /usr/include/libunwind.h || die 1 "I need libunwind to compile. Please fix your slave."
50 #test -e /usr/include/valgrind/valgrind.h || die 1 "I need valgrind to compile. Please fix your slave."
52 if type lsb_release >/dev/null 2>&1; then
53 if [ -f /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe ]; then
54 #To identify the windows underneath the winbuntu
55 PATH="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:$PATH"
56 major=$(powershell.exe -command "[environment]::OSVersion.Version.Major" | sed 's/\r//g')
57 build=$(powershell.exe -command "[environment]::OSVersion.Version.Build"| sed 's/\r//g')
59 ver="$major v$build - WSL $(lsb_release -sd)"
63 ver="$(lsb_release -sr) ($(lsb_release -sc))"
65 elif [ -f /etc/lsb-release ]; then
66 # For some versions of Debian/Ubuntu without lsb_release command
70 elif [ -f /etc/debian_version ]; then
71 # Older Debian/Ubuntu/etc.
73 ver=$(cat /etc/debian_version)
74 elif [ -f /etc/redhat-release ]; then
75 read -r os ver < /etc/redhat-release
76 elif [ -f /usr/bin/sw_vers ]; then
77 os=$(sw_vers -productName)
78 ver=$(sw_vers -productVersion)
79 elif [ -f /bin/freebsd-version ]; then
81 ver=$(freebsd-version -u)
82 elif [ -f /etc/os-release ]; then
83 # freedesktop.org and systemd, put last as usually missing useful info
88 # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
89 echo "fallback as OS name not found"
104 echo "OS Version : $os $ver $bits"
108 echo "Build mode $build_mode on $(uname -np)" >&2
109 case "$build_mode" in
111 INSTALL="/builds/simgrid_install"
115 INSTALL="/builds/mc_simgrid_install"
123 die 1 "Unknown build_mode $build_mode"
127 if [ "$2" = "" ]; then
128 branch_name="unknown"
132 echo "Branch built is $branch_name"
134 NUMBER_OF_PROCESSORS="$(nproc)" || NUMBER_OF_PROCESSORS=1
135 GENERATOR="Unix Makefiles"
140 echo "XX Get out of the tree"
142 if [ -d $WORKSPACE/build ]
144 # Windows cannot remove the directory if it's still used by the previous build
145 rm -rf $WORKSPACE/build || sleep 10 && rm -rf $WORKSPACE/build || sleep 10 && rm -rf $WORKSPACE/build
147 mkdir $WORKSPACE/build
151 if dpkg -l libns3-dev 2>&1|grep -q "ii libns3-dev" ; then
154 echo "XX have_NS3: ${have_NS3}"
156 # This is for Windows:
157 PATH="$WORKSPACE/build/lib:$PATH"
160 echo "XX Build the archive out of the tree"
161 echo "XX pwd: "$(pwd)
164 cmake -G"$GENERATOR" -Denable_documentation=OFF $WORKSPACE
165 make dist -j $NUMBER_OF_PROCESSORS
166 SIMGRID_VERSION=$(cat VERSION)
169 echo "XX Open the resulting archive"
171 gunzip ${SIMGRID_VERSION}.tar.gz
172 tar xf ${SIMGRID_VERSION}.tar
173 mkdir ${WORKSPACE}/build/${SIMGRID_VERSION}/build
174 cd ${WORKSPACE}/build/${SIMGRID_VERSION}/build
175 SRCFOLDER="${WORKSPACE}/build/${SIMGRID_VERSION}"
178 echo "XX Configure and build SimGrid"
179 echo "XX pwd: "$(pwd)
183 if cmake --version | grep -q 3\.11 ; then
184 # -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
185 # https://gitlab.kitware.com/cmake/cmake/issues/17933
186 MAY_DISABLE_SOURCE_CHANGE=""
188 MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
191 if [ "$os" = "NixOS" -a "$(gcc -dumpversion)" = "7.4.0" ]; then
192 echo "Temporary disable LTO, believed to be broken on this system."
193 MAY_DISABLE_LTO=-Denable_lto=OFF
198 cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
199 -Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
200 -Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
201 -Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
202 -Denable_compile_optimizations=$(onoff test "$build_mode" != "DynamicAnalysis") \
203 -Denable_smpi_MPICH3_testsuite=$(onoff test "$build_mode" = "Debug") \
204 -Denable_mallocators=$(onoff test "$build_mode" != "DynamicAnalysis") \
205 -Denable_memcheck=$(onoff test "$build_mode" = "DynamicAnalysis") \
206 -Denable_compile_warnings=$(onoff test "$GENERATOR" != "MSYS Makefiles") -Denable_smpi=ON \
207 -Denable_ns3=$(onoff test "$have_NS3" = "yes" -a "$build_mode" = "Debug") \
208 -Denable_jedule=OFF -Denable_java=ON -Denable_lua=OFF ${MAY_DISABLE_SOURCE_CHANGE} ${MAY_DISABLE_LTO} \
210 # -Denable_lua=$(onoff test "$build_mode" != "DynamicAnalysis") \
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 || true
221 if [ -f Testing/TAG ] ; then
222 xsltproc $WORKSPACE/tools/jenkins/ctest2junit.xsl Testing/$( head -n 1 < Testing/TAG )/Test.xml > CTestResults.xml
223 mv CTestResults.xml $WORKSPACE
226 if test -n "$INSTALL" && [ ${branch_name} = "origin/master" ] ; then
228 echo "XX Test done. Install everything since it's a regular build, not on a Windows."
237 echo "XX Done. Return the results to cmake"