3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 2016-2020 Michael Jeanson <mjeanson@efficios.com>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # Version compare functions
24 if [[ "$1" == "$2" ]]; then
28 local i ver1
=($1) ver2
=($2)
29 # fill empty fields in ver1 with zeros
30 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
33 for ((i
=0; i
<${#ver1[@]}; i
++)); do
34 if [[ -z ${ver2[i]} ]]; then
35 # fill empty fields in ver2 with zeros
38 if ((10#${ver1[i]} > 10#${ver2[i]})); then
41 if ((10#${ver1[i]} < 10#${ver2[i]})); then
50 vercomp
"$1" "$2"; local res
="$?"
51 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
55 vercomp
"$1" "$2"; local res
="$?"
60 vercomp
"$1" "$2"; local res
="$?"
61 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
65 vercomp
"$1" "$2"; local res
="$?"
70 vercomp
"$1" "$2"; local res
="$?"
75 # Assume we are in the configured build directory
76 echo "#################### BEGIN config.log ####################"
78 echo "#################### END config.log ####################"
84 WORKSPACE
=${WORKSPACE:-}
92 SRCDIR
="$WORKSPACE/src/babeltrace"
93 TMPDIR
="$WORKSPACE/tmp"
96 # Create tmp directory
101 export CFLAGS
="-g -O2"
103 # Set compiler variables
135 export CXX
=clang
++-3.9
139 export CXX
=clang
++-4.0
143 export CXX
=clang
++-5.0
147 export CXX
=clang
++-6.0
154 if [ "x$cc" != "x" ]; then
160 if [ "x${CC:-}" != "x" ]; then
161 echo "Selected compiler:"
165 # Set platform variables
171 export PATH
="/opt/csw/bin:/usr/ccs/bin:$PATH"
172 export CPPFLAGS
="-I/opt/csw/include"
173 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib"
174 export PKG_CONFIG_PATH
="/opt/csw/lib/pkgconfig"
175 export PYTHON
="python3"
176 export PYTHON_CONFIG
="python3-config"
183 export PATH
="/opt/csw/bin:$PATH:/usr/perl5/bin"
184 export LD_ALTEXEC
=/usr
/bin
/gld
185 export LD
=/usr
/bin
/gld
186 export PYTHON
="python3"
187 export PYTHON_CONFIG
="python3-config"
188 export PKG_CONFIG_PATH
="/usr/lib/pkgconfig"
194 export NPROC
="getconf _NPROCESSORS_ONLN"
195 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
196 export CPPFLAGS
="-I/opt/local/include"
197 export LDFLAGS
="-L/opt/local/lib"
198 export PYTHON
="python3"
199 export PYTHON_CONFIG
="python3-config"
206 export PYTHON
="python3"
207 export PYTHON_CONFIG
="python3-config"
214 export NPROC
="getconf _NPROCESSORS_ONLN"
215 export CPPFLAGS
="-I/usr/local/include"
216 export LDFLAGS
="-L/usr/local/lib"
217 export PYTHON
="python3"
218 export PYTHON_CONFIG
="python3-config"
221 export YACC
="bison -y"
228 export PYTHON
="python3"
229 export PYTHON_CONFIG
="python3-config"
233 # Print build env details
235 print_tooling || true
237 # Enter the source directory
240 # Run bootstrap in the source directory prior to configure
243 # Get source version from configure script
244 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
245 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
247 # Enable dev mode by default for BT 2.0 builds
248 export BABELTRACE_DEBUG_MODE
=1
249 export BABELTRACE_DEV_MODE
=1
250 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
252 # Set configure options and environment variables for each build
254 CONF_OPTS
=("--prefix=$PREFIX")
257 echo "Static lib only configuration"
259 CONF_OPTS
+=("--enable-static" "--disable-shared")
261 if vergte
"$PACKAGE_VERSION" "2.0"; then
262 CONF_OPTS
+=("--enable-built-in-plugins")
267 echo "Python bindings configuration"
269 CONF_OPTS
+=("--enable-python-bindings")
271 if vergte
"$PACKAGE_VERSION" "2.0"; then
272 CONF_OPTS
+=("--enable-python-bindings-doc" "--enable-python-plugins")
277 echo "Production configuration"
279 # Unset the developper variables
280 unset BABELTRACE_DEBUG_MODE
281 unset BABELTRACE_DEV_MODE
282 unset BABELTRACE_MINIMAL_LOG_LEVEL
284 # Enable the python bindings
285 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins")
289 echo "Minimal configuration"
293 echo "Standard configuration"
295 # Enable the python bindings / plugins by default with babeltrace2,
296 # the test suite is mostly useless without it.
297 if vergte
"$PACKAGE_VERSION" "2.0"; then
298 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
304 # oot : out-of-tree build
305 # dist : build via make dist
306 # oot-dist: build via make dist out-of-tree
307 # * : normal tree build
309 # Make sure to move to the build directory and run configure
313 echo "Out of tree build"
315 # Create and enter a temporary build directory
316 builddir
=$
(mktemp
-d)
319 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
323 echo "Distribution in-tree build"
325 # Run configure and generate the tar file
326 # in the source directory
327 .
/configure || failed_configure
330 # Create and enter a temporary build directory
331 builddir
=$
(mktemp
-d)
334 # Extract the distribution tar in the build directory,
335 # ignore the first directory level
336 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
338 # Build in extracted source tree
339 .
/configure
"${CONF_OPTS[@]}" || failed_configure
343 echo "Distribution out of tree build"
345 # Create and enter a temporary build directory
346 builddir
=$
(mktemp
-d)
349 # Run configure out of tree and generate the tar file
350 "$SRCDIR/configure" || failed_configure
353 dist_srcdir
="$(mktemp -d)"
356 # Extract the distribution tar in the new source directory,
357 # ignore the first directory level
358 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
360 # Create and enter a second temporary build directory
361 builddir
="$(mktemp -d)"
364 # Run configure from the extracted distribution tar,
365 # out of the source tree
366 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
370 echo "Standard in-tree build"
371 .
/configure
"${CONF_OPTS[@]}" || failed_configure
375 # We are now inside a configured build directory
378 $MAKE -j "$($NPROC)" V
=1
380 # Force rebase DLL address mapping
381 if [ "${rebase_dll:-}" == "1" ]; then
382 find .
-name "*.dll" -print0 |
xargs -0 rebase
-O -v
385 # Install in the workspace
386 $MAKE install DESTDIR
="$WORKSPACE"
388 # Run tests, don't fail now, we want to run the archiving steps
390 $MAKE --keep-going check || failed_tests
=1
392 # Copy tap logs for the jenkins tap parser before cleaning the build dir
393 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
395 # The test suite prior to 1.5 did not produce TAP logs
396 if verlt
"$PACKAGE_VERSION" "1.5"; then
397 mkdir
-p "$WORKSPACE/tap/no-log"
398 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
399 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
402 # Clean the build directory
405 # Cleanup rpath in executables and shared libraries
406 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
407 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
409 # Remove libtool .la files
410 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
412 # Exit with failure if any of the tests failed