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"
110 # RHEL and SLES both use lib64 but don't bother shipping a default autoconf
111 # site config that matches this.
112 if [[ ( -f /etc
/redhat-release ||
-f /etc
/SuSE-release
) && ( "$(uname -m)" == "x86_64" ) ]]; then
113 LIBDIR_ARCH
="${LIBDIR}64"
115 LIBDIR_ARCH
="$LIBDIR"
118 # Create tmp directory
123 export CFLAGS
="-g -O2"
125 # Set compiler variables
132 export CC
=gcc-
${cc#gcc-}
133 export CXX
=g
++-${cc#gcc-}
140 export CC
=clang-
${cc#clang-}
141 export CXX
=clang
++-${cc#clang-}
144 if [ "x$cc" != "x" ]; then
150 if [ "x${CC:-}" != "x" ]; then
151 echo "Selected compiler:"
155 # Set platform variables
160 export NPROC
="getconf _NPROCESSORS_ONLN"
161 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
162 export CPPFLAGS
="-I/opt/local/include"
163 export LDFLAGS
="-L/opt/local/lib"
164 export PYTHON
="python3"
165 export PYTHON_CONFIG
="python3-config"
171 export NPROC
="getconf _NPROCESSORS_ONLN"
172 export CPPFLAGS
="-I/usr/local/include"
173 export LDFLAGS
="-L/usr/local/lib"
174 export PYTHON
="python3"
175 export PYTHON_CONFIG
="python3-config"
178 export YACC
="bison -y"
185 export PYTHON
="python3"
186 export PYTHON_CONFIG
="python3-config"
190 # Print build env details
192 print_tooling || true
194 # Enter the source directory
197 # Run bootstrap in the source directory prior to configure
200 # Get source version from configure script
201 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
202 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
204 # Enable dev mode by default for BT 2.0 builds
205 export BABELTRACE_DEBUG_MODE
=1
206 export BABELTRACE_DEV_MODE
=1
207 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
209 # Set configure options and environment variables for each build
211 CONF_OPTS
=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH")
213 # -Werror is enabled by default in stable-2.0 but won't be in 2.1
214 # Explicitly disable it for consistency.
215 if vergte
"$PACKAGE_VERSION" "2.0"; then
216 CONF_OPTS
+=("--disable-Werror")
221 echo "Static lib only configuration"
223 CONF_OPTS
+=("--enable-static" "--disable-shared")
225 if vergte
"$PACKAGE_VERSION" "2.0"; then
226 CONF_OPTS
+=("--enable-built-in-plugins")
231 echo "Python bindings configuration"
233 CONF_OPTS
+=("--enable-python-bindings")
235 if vergte
"$PACKAGE_VERSION" "2.0"; then
236 CONF_OPTS
+=("--enable-python-bindings-doc" "--enable-python-plugins")
241 echo "Production configuration"
243 # Unset the developper variables
244 unset BABELTRACE_DEBUG_MODE
245 unset BABELTRACE_DEV_MODE
246 unset BABELTRACE_MINIMAL_LOG_LEVEL
248 # Enable the python bindings
249 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
253 echo "Documentation configuration"
255 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins" "--enable-api-doc")
259 echo "Address Sanitizer configuration"
261 # --enable-asan was introduced after 2.0 but don't check the version, we
262 # want this configuration to fail if ASAN is unavailable.
263 CONF_OPTS
+=("--enable-asan" "--enable-python-bindings" "--enable-python-plugins")
267 echo "Minimal configuration"
271 echo "Standard configuration"
273 # Enable the python bindings / plugins by default with babeltrace2,
274 # the test suite is mostly useless without it.
275 if vergte
"$PACKAGE_VERSION" "2.0"; then
276 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
282 # oot : out-of-tree build
283 # dist : build via make dist
284 # oot-dist: build via make dist out-of-tree
285 # * : normal tree build
287 # Make sure to move to the build directory and run configure
291 echo "Out of tree build"
293 # Create and enter a temporary build directory
294 builddir
=$
(mktemp
-d)
297 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
301 echo "Distribution in-tree build"
303 # Run configure and generate the tar file
304 # in the source directory
305 .
/configure || failed_configure
308 # Create and enter a temporary build directory
309 builddir
=$
(mktemp
-d)
312 # Extract the distribution tar in the build directory,
313 # ignore the first directory level
314 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
316 # Build in extracted source tree
317 .
/configure
"${CONF_OPTS[@]}" || failed_configure
321 echo "Distribution out of tree build"
323 # Create and enter a temporary build directory
324 builddir
=$
(mktemp
-d)
327 # Run configure out of tree and generate the tar file
328 "$SRCDIR/configure" || failed_configure
331 dist_srcdir
="$(mktemp -d)"
334 # Extract the distribution tar in the new source directory,
335 # ignore the first directory level
336 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
338 # Create and enter a second temporary build directory
339 builddir
="$(mktemp -d)"
342 # Run configure from the extracted distribution tar,
343 # out of the source tree
344 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
348 echo "Standard in-tree build"
349 .
/configure
"${CONF_OPTS[@]}" || failed_configure
353 # We are now inside a configured build directory
356 $MAKE -j "$($NPROC)" V
=1
358 # Install in the workspace
359 $MAKE install DESTDIR
="$WORKSPACE"
361 # Run tests, don't fail now, we want to run the archiving steps
363 if [ "$BABELTRACE_RUN_TESTS" = "yes" ]; then
364 $MAKE --keep-going check || failed_tests
=1
366 # Copy tap logs for the jenkins tap parser before cleaning the build dir
367 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
369 # The test suite prior to 1.5 did not produce TAP logs
370 if verlt
"$PACKAGE_VERSION" "1.5"; then
371 mkdir
-p "$WORKSPACE/tap/no-log"
372 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
373 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
377 # Clean the build directory
380 # Cleanup rpath in executables and shared libraries
381 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
382 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.so" -exec chrpath
--delete {} \
;
384 # Remove libtool .la files
385 find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.la" -exec rm -f {} \
;
387 # Exit with failure if any of the tests failed