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 # Ignore the shellcheck warning, we want splitting to happen based on IFS.
29 # shellcheck disable=SC2206
30 local i ver1
=($1) ver2
=($2)
31 # fill empty fields in ver1 with zeros
32 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
35 for ((i
=0; i
<${#ver1[@]}; i
++)); do
36 if [[ -z ${ver2[i]} ]]; then
37 # fill empty fields in ver2 with zeros
40 if ((10#${ver1[i]} > 10#${ver2[i]})); then
43 if ((10#${ver1[i]} < 10#${ver2[i]})); then
51 # Shellcheck flags the following functions that are unused as "unreachable",
54 # shellcheck disable=SC2317
58 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
61 # shellcheck disable=SC2317
63 vercomp
"$1" "$2"; local res
="$?"
67 # shellcheck disable=SC2317
69 vercomp
"$1" "$2"; local res
="$?"
70 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
73 # shellcheck disable=SC2317
75 vercomp
"$1" "$2"; local res
="$?"
79 # shellcheck disable=SC2317
81 vercomp
"$1" "$2"; local res
="$?"
86 # Assume we are in the configured build directory
87 echo "#################### BEGIN config.log ####################"
89 echo "#################### END config.log ####################"
95 WORKSPACE
=${WORKSPACE:-}
97 platform
=${platform:-}
102 # Controls if the tests are run
103 BABELTRACE_RUN_TESTS
="${BABELTRACE_RUN_TESTS:=yes}"
105 SRCDIR
="$WORKSPACE/src/babeltrace"
106 TMPDIR
="$WORKSPACE/tmp"
109 LIBDIR_ARCH
="$LIBDIR"
111 # RHEL and SLES both use lib64 but don't bother shipping a default autoconf
112 # site config that matches this.
113 if [[ ( -f /etc
/redhat-release ||
-f /etc
/products.d
/SLES.prod ||
-f /etc
/yocto-release
) ]]; then
114 # Detect the userspace bitness in a distro agnostic way
115 if file -L /bin
/bash |
grep '64-bit' >/dev
/null
2>&1; then
116 LIBDIR_ARCH
="${LIBDIR}64"
120 # Create tmp directory
125 export CFLAGS
="-g -O2"
127 # Set compiler variables
134 export CC
=gcc-
${cc#gcc-}
135 export CXX
=g
++-${cc#gcc-}
142 export CC
=clang-
${cc#clang-}
143 export CXX
=clang
++-${cc#clang-}
146 if [ "x$cc" != "x" ]; then
152 if [ "x${CC:-}" != "x" ]; then
153 echo "Selected compiler:"
157 # Set platform variables
162 export NPROC
="getconf _NPROCESSORS_ONLN"
163 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
164 export CPPFLAGS
="-I/opt/local/include"
165 export LDFLAGS
="-L/opt/local/lib"
166 export PYTHON
="python3"
167 export PYTHON_CONFIG
="python3-config"
173 export NPROC
="getconf _NPROCESSORS_ONLN"
174 export CPPFLAGS
="-I/usr/local/include"
175 export LDFLAGS
="-L/usr/local/lib"
176 export PYTHON
="python3"
177 export PYTHON_CONFIG
="python3-config"
180 export YACC
="bison -y"
187 export PYTHON
="python3"
188 export PYTHON_CONFIG
="python3-config"
192 # Print build env details
194 print_tooling || true
196 # Enter the source directory
199 # Run bootstrap in the source directory prior to configure
202 # Get source version from configure script
203 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
204 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
206 # Enable dev mode by default for BT 2.0 builds
207 export BABELTRACE_DEBUG_MODE
=1
208 export BABELTRACE_DEV_MODE
=1
209 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
211 # Set configure options and environment variables for each build
213 CONF_OPTS
=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH")
215 # -Werror is enabled by default in stable-2.0 but won't be in 2.1
216 # Explicitly disable it for consistency.
217 if vergte
"$PACKAGE_VERSION" "2.0"; then
218 CONF_OPTS
+=("--disable-Werror")
223 echo "Static lib only configuration"
225 CONF_OPTS
+=("--enable-static" "--disable-shared")
227 if vergte
"$PACKAGE_VERSION" "2.0"; then
228 CONF_OPTS
+=("--enable-built-in-plugins")
233 echo "Python bindings configuration"
235 CONF_OPTS
+=("--enable-python-bindings")
237 if vergte
"$PACKAGE_VERSION" "2.0"; then
238 CONF_OPTS
+=("--enable-python-bindings-doc" "--enable-python-plugins")
243 echo "Production configuration"
245 # Unset the developper variables
246 unset BABELTRACE_DEBUG_MODE
247 unset BABELTRACE_DEV_MODE
248 unset BABELTRACE_MINIMAL_LOG_LEVEL
250 # Enable the python bindings
251 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
255 echo "Documentation configuration"
257 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins" "--enable-api-doc")
261 echo "Address Sanitizer configuration"
263 # --enable-asan was introduced after 2.0 but don't check the version, we
264 # want this configuration to fail if ASAN is unavailable.
265 CONF_OPTS
+=("--enable-asan" "--enable-python-bindings" "--enable-python-plugins")
269 echo "Minimal configuration"
273 echo "Standard configuration"
275 # Enable the python bindings / plugins by default with babeltrace2,
276 # the test suite is mostly useless without it.
277 if vergte
"$PACKAGE_VERSION" "2.0"; then
278 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
281 # Something is broken in docbook-xml on yocto
282 if [[ "$platform" = yocto
* ]]; then
283 CONF_OPTS
+=("--disable-man-pages")
289 # oot : out-of-tree build
290 # dist : build via make dist
291 # oot-dist: build via make dist out-of-tree
292 # * : normal tree build
294 # Make sure to move to the build directory and run configure
298 echo "Out of tree build"
300 # Create and enter a temporary build directory
301 builddir
=$
(mktemp
-d)
304 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
308 echo "Distribution in-tree build"
310 # Run configure and generate the tar file
311 # in the source directory
312 .
/configure || failed_configure
315 # Create and enter a temporary build directory
316 builddir
=$
(mktemp
-d)
319 # Extract the distribution tar in the build directory,
320 # ignore the first directory level
321 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
323 # Build in extracted source tree
324 .
/configure
"${CONF_OPTS[@]}" || failed_configure
328 echo "Distribution out of tree build"
330 # Create and enter a temporary build directory
331 builddir
=$
(mktemp
-d)
334 # Run configure out of tree and generate the tar file
335 "$SRCDIR/configure" || failed_configure
338 dist_srcdir
="$(mktemp -d)"
341 # Extract the distribution tar in the new source directory,
342 # ignore the first directory level
343 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
345 # Create and enter a second temporary build directory
346 builddir
="$(mktemp -d)"
349 # Run configure from the extracted distribution tar,
350 # out of the source tree
351 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
355 echo "Standard in-tree build"
356 .
/configure
"${CONF_OPTS[@]}" || failed_configure
360 # We are now inside a configured build directory
363 $MAKE -j "$($NPROC)" V
=1
365 # Install in the workspace
366 $MAKE install DESTDIR
="$WORKSPACE"
368 # Run tests, don't fail now, we want to run the archiving steps
370 if [ "$BABELTRACE_RUN_TESTS" = "yes" ]; then
371 $MAKE --keep-going check || failed_tests
=1
373 # Copy tap logs for the jenkins tap parser before cleaning the build dir
374 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
376 # Copy the test suites top-level log which includes all tests failures
377 rsync
-a --include 'test-suite.log' --include '*/' --exclude='*' tests
/ "$WORKSPACE/log"
379 # The test suite prior to 1.5 did not produce TAP logs
380 if verlt
"$PACKAGE_VERSION" "1.5"; then
381 mkdir
-p "$WORKSPACE/tap/no-log"
382 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
383 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
387 # Clean the build directory
390 # Cleanup rpath in executables and shared libraries
391 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
392 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.so" -exec chrpath
--delete {} \
;
394 # Remove libtool .la files
395 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.la" -exec rm -f {} \
;
397 # Exit with failure if any of the tests failed