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 # Create tmp directory
114 export CFLAGS
="-g -O2"
116 # Set compiler variables
123 export CC
=gcc-
${cc#gcc-}
124 export CXX
=g
++-${cc#gcc-}
131 export CC
=clang-
${cc#clang-}
132 export CXX
=clang
++-${cc#clang-}
135 if [ "x$cc" != "x" ]; then
141 if [ "x${CC:-}" != "x" ]; then
142 echo "Selected compiler:"
146 # Set platform variables
151 export NPROC
="getconf _NPROCESSORS_ONLN"
152 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
153 export CPPFLAGS
="-I/opt/local/include"
154 export LDFLAGS
="-L/opt/local/lib"
155 export PYTHON
="python3"
156 export PYTHON_CONFIG
="python3-config"
162 export NPROC
="getconf _NPROCESSORS_ONLN"
163 export CPPFLAGS
="-I/usr/local/include"
164 export LDFLAGS
="-L/usr/local/lib"
165 export PYTHON
="python3"
166 export PYTHON_CONFIG
="python3-config"
169 export YACC
="bison -y"
176 export PYTHON
="python3"
177 export PYTHON_CONFIG
="python3-config"
181 # Print build env details
183 print_tooling || true
185 # Enter the source directory
188 # Run bootstrap in the source directory prior to configure
191 # Get source version from configure script
192 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
193 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
195 # Enable dev mode by default for BT 2.0 builds
196 export BABELTRACE_DEBUG_MODE
=1
197 export BABELTRACE_DEV_MODE
=1
198 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
200 # Set configure options and environment variables for each build
202 CONF_OPTS
=("--prefix=$PREFIX")
204 # -Werror is enabled by default in stable-2.0 but won't be in 2.1
205 # Explicitly disable it for consistency.
206 if vergte
"$PACKAGE_VERSION" "2.0"; then
207 CONF_OPTS
+=("--disable-Werror")
212 echo "Static lib only configuration"
214 CONF_OPTS
+=("--enable-static" "--disable-shared")
216 if vergte
"$PACKAGE_VERSION" "2.0"; then
217 CONF_OPTS
+=("--enable-built-in-plugins")
222 echo "Python bindings configuration"
224 CONF_OPTS
+=("--enable-python-bindings")
226 if vergte
"$PACKAGE_VERSION" "2.0"; then
227 CONF_OPTS
+=("--enable-python-bindings-doc" "--enable-python-plugins")
232 echo "Production configuration"
234 # Unset the developper variables
235 unset BABELTRACE_DEBUG_MODE
236 unset BABELTRACE_DEV_MODE
237 unset BABELTRACE_MINIMAL_LOG_LEVEL
239 # Enable the python bindings
240 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
244 echo "Documentation configuration"
246 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins" "--enable-api-doc")
250 echo "Minimal configuration"
254 echo "Standard configuration"
256 # Enable the python bindings / plugins by default with babeltrace2,
257 # the test suite is mostly useless without it.
258 if vergte
"$PACKAGE_VERSION" "2.0"; then
259 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
265 # oot : out-of-tree build
266 # dist : build via make dist
267 # oot-dist: build via make dist out-of-tree
268 # * : normal tree build
270 # Make sure to move to the build directory and run configure
274 echo "Out of tree build"
276 # Create and enter a temporary build directory
277 builddir
=$
(mktemp
-d)
280 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
284 echo "Distribution in-tree build"
286 # Run configure and generate the tar file
287 # in the source directory
288 .
/configure || failed_configure
291 # Create and enter a temporary build directory
292 builddir
=$
(mktemp
-d)
295 # Extract the distribution tar in the build directory,
296 # ignore the first directory level
297 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
299 # Build in extracted source tree
300 .
/configure
"${CONF_OPTS[@]}" || failed_configure
304 echo "Distribution out of tree build"
306 # Create and enter a temporary build directory
307 builddir
=$
(mktemp
-d)
310 # Run configure out of tree and generate the tar file
311 "$SRCDIR/configure" || failed_configure
314 dist_srcdir
="$(mktemp -d)"
317 # Extract the distribution tar in the new source directory,
318 # ignore the first directory level
319 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
321 # Create and enter a second temporary build directory
322 builddir
="$(mktemp -d)"
325 # Run configure from the extracted distribution tar,
326 # out of the source tree
327 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
331 echo "Standard in-tree build"
332 .
/configure
"${CONF_OPTS[@]}" || failed_configure
336 # We are now inside a configured build directory
339 $MAKE -j "$($NPROC)" V
=1
341 # Install in the workspace
342 $MAKE install DESTDIR
="$WORKSPACE"
344 # Run tests, don't fail now, we want to run the archiving steps
346 if [ "$BABELTRACE_RUN_TESTS" = "yes" ]; then
347 $MAKE --keep-going check || failed_tests
=1
349 # Copy tap logs for the jenkins tap parser before cleaning the build dir
350 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
352 # The test suite prior to 1.5 did not produce TAP logs
353 if verlt
"$PACKAGE_VERSION" "1.5"; then
354 mkdir
-p "$WORKSPACE/tap/no-log"
355 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
356 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
360 # Clean the build directory
363 # Cleanup rpath in executables and shared libraries
364 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
365 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
367 # Remove libtool .la files
368 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
370 # Exit with failure if any of the tests failed