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:-}
91 # Controls if the tests are run
92 BABELTRACE_RUN_TESTS
="${BABELTRACE_RUN_TESTS:=yes}"
94 SRCDIR
="$WORKSPACE/src/babeltrace"
95 TMPDIR
="$WORKSPACE/tmp"
98 # Create tmp directory
103 export CFLAGS
="-g -O2"
105 # Set compiler variables
137 export CXX
=clang
++-3.9
141 export CXX
=clang
++-4.0
145 export CXX
=clang
++-5.0
149 export CXX
=clang
++-6.0
156 if [ "x$cc" != "x" ]; then
162 if [ "x${CC:-}" != "x" ]; then
163 echo "Selected compiler:"
167 # Set platform variables
173 export PATH
="/opt/csw/bin:/usr/ccs/bin:$PATH"
174 export CPPFLAGS
="-I/opt/csw/include"
175 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib"
176 export PKG_CONFIG_PATH
="/opt/csw/lib/pkgconfig"
177 export PYTHON
="python3"
178 export PYTHON_CONFIG
="python3-config"
185 export PATH
="/opt/csw/bin:$PATH:/usr/perl5/bin"
186 export LD_ALTEXEC
=/usr
/bin
/gld
187 export LD
=/usr
/bin
/gld
188 export PYTHON
="python3"
189 export PYTHON_CONFIG
="python3-config"
190 export PKG_CONFIG_PATH
="/usr/lib/pkgconfig"
196 export NPROC
="getconf _NPROCESSORS_ONLN"
197 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
198 export CPPFLAGS
="-I/opt/local/include"
199 export LDFLAGS
="-L/opt/local/lib"
200 export PYTHON
="python3.9"
201 export PYTHON_CONFIG
="python3.9-config"
208 export PYTHON
="python3"
209 export PYTHON_CONFIG
="python3-config"
216 export NPROC
="getconf _NPROCESSORS_ONLN"
217 export CPPFLAGS
="-I/usr/local/include"
218 export LDFLAGS
="-L/usr/local/lib"
219 export PYTHON
="python3"
220 export PYTHON_CONFIG
="python3-config"
223 export YACC
="bison -y"
230 export PYTHON
="python3"
231 export PYTHON_CONFIG
="python3-config"
235 # Print build env details
237 print_tooling || true
239 # Enter the source directory
242 # Run bootstrap in the source directory prior to configure
245 # Get source version from configure script
246 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
247 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
249 # Enable dev mode by default for BT 2.0 builds
250 export BABELTRACE_DEBUG_MODE
=1
251 export BABELTRACE_DEV_MODE
=1
252 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
254 # Set configure options and environment variables for each build
256 CONF_OPTS
=("--prefix=$PREFIX")
258 # -Werror is enabled by default in stable-2.0 but won't be in 2.1
259 # Explicitly disable it for consistency.
260 if vergte
"$PACKAGE_VERSION" "2.0"; then
261 CONF_OPTS
+=("--disable-Werror")
266 echo "Static lib only configuration"
268 CONF_OPTS
+=("--enable-static" "--disable-shared")
270 if vergte
"$PACKAGE_VERSION" "2.0"; then
271 CONF_OPTS
+=("--enable-built-in-plugins")
276 echo "Python bindings configuration"
278 CONF_OPTS
+=("--enable-python-bindings")
280 if vergte
"$PACKAGE_VERSION" "2.0"; then
281 CONF_OPTS
+=("--enable-python-bindings-doc" "--enable-python-plugins")
286 echo "Production configuration"
288 # Unset the developper variables
289 unset BABELTRACE_DEBUG_MODE
290 unset BABELTRACE_DEV_MODE
291 unset BABELTRACE_MINIMAL_LOG_LEVEL
293 # Enable the python bindings
294 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins")
298 echo "Minimal configuration"
302 echo "Standard configuration"
304 # Enable the python bindings / plugins by default with babeltrace2,
305 # the test suite is mostly useless without it.
306 if vergte
"$PACKAGE_VERSION" "2.0"; then
307 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
313 # oot : out-of-tree build
314 # dist : build via make dist
315 # oot-dist: build via make dist out-of-tree
316 # * : normal tree build
318 # Make sure to move to the build directory and run configure
322 echo "Out of tree build"
324 # Create and enter a temporary build directory
325 builddir
=$
(mktemp
-d)
328 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
332 echo "Distribution in-tree build"
334 # Run configure and generate the tar file
335 # in the source directory
336 .
/configure || failed_configure
339 # Create and enter a temporary build directory
340 builddir
=$
(mktemp
-d)
343 # Extract the distribution tar in the build directory,
344 # ignore the first directory level
345 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
347 # Build in extracted source tree
348 .
/configure
"${CONF_OPTS[@]}" || failed_configure
352 echo "Distribution out of tree build"
354 # Create and enter a temporary build directory
355 builddir
=$
(mktemp
-d)
358 # Run configure out of tree and generate the tar file
359 "$SRCDIR/configure" || failed_configure
362 dist_srcdir
="$(mktemp -d)"
365 # Extract the distribution tar in the new source directory,
366 # ignore the first directory level
367 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
369 # Create and enter a second temporary build directory
370 builddir
="$(mktemp -d)"
373 # Run configure from the extracted distribution tar,
374 # out of the source tree
375 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
379 echo "Standard in-tree build"
380 .
/configure
"${CONF_OPTS[@]}" || failed_configure
384 # We are now inside a configured build directory
387 $MAKE -j "$($NPROC)" V
=1
389 # Force rebase DLL address mapping
390 if [ "${rebase_dll:-}" == "1" ]; then
391 find .
-name "*.dll" -print0 |
xargs -0 rebase
-O -v
394 # Install in the workspace
395 $MAKE install DESTDIR
="$WORKSPACE"
397 # Run tests, don't fail now, we want to run the archiving steps
399 if [ "$BABELTRACE_RUN_TESTS" = "yes" ]; then
400 $MAKE --keep-going check || failed_tests
=1
402 # Copy tap logs for the jenkins tap parser before cleaning the build dir
403 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
405 # The test suite prior to 1.5 did not produce TAP logs
406 if verlt
"$PACKAGE_VERSION" "1.5"; then
407 mkdir
-p "$WORKSPACE/tap/no-log"
408 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
409 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
413 # Clean the build directory
416 # Cleanup rpath in executables and shared libraries
417 find "$WORKSPACE/$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
418 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
420 # Remove libtool .la files
421 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
423 # Exit with failure if any of the tests failed