3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # 2016-2019 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/>.
19 # Version compare functions
22 if [[ "$1" == "$2" ]]; then
26 local i ver1
=($1) ver2
=($2)
27 # fill empty fields in ver1 with zeros
28 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
31 for ((i
=0; i
<${#ver1[@]}; i
++)); do
32 if [[ -z ${ver2[i]} ]]; then
33 # fill empty fields in ver2 with zeros
36 if ((10#${ver1[i]} > 10#${ver2[i]})); then
39 if ((10#${ver1[i]} < 10#${ver2[i]})); then
48 vercomp
"$1" "$2"; local res
="$?"
49 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
53 vercomp
"$1" "$2"; local res
="$?"
58 vercomp
"$1" "$2"; local res
="$?"
59 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
63 vercomp
"$1" "$2"; local res
="$?"
68 vercomp
"$1" "$2"; local res
="$?"
79 SRCDIR
="$WORKSPACE/src/babeltrace"
80 TMPDIR
="$WORKSPACE/tmp"
81 PREFIX
="$WORKSPACE/build"
83 # The build dir defaults to the source dir
86 # Create install and tmp directories
87 rm -rf "$PREFIX" "$TMPDIR"
88 mkdir
-p "$PREFIX" "$TMPDIR"
91 export CFLAGS
="-g -O2"
93 # Set compiler variables
125 export CXX
=clang
++-3.9
129 export CXX
=clang
++-4.0
133 export CXX
=clang
++-5.0
137 export CXX
=clang
++-6.0
144 if [ "x$cc" != "x" ]; then
150 if [ "x${CC:-}" != "x" ]; then
151 echo "Selected compiler:"
155 # Set platform variables
162 export YACC
="$BISON -y"
163 export PATH
="/opt/csw/bin:/usr/ccs/bin:$PATH"
164 export CPPFLAGS
="-I/opt/csw/include"
165 export LDFLAGS
="-L/opt/csw/lib -R/opt/csw/lib"
166 export PKG_CONFIG_PATH
="/opt/csw/lib/pkgconfig"
167 export PYTHON
="python3"
168 export PYTHON_CONFIG
="python3-config"
174 export PATH
="$PATH:/usr/perl5/bin"
175 export LD_ALTEXEC
=/usr
/bin
/gld
176 export LD
=/usr
/bin
/gld
177 export PYTHON
="python3"
178 export PYTHON_CONFIG
="python3-config"
183 export NPROC
="getconf _NPROCESSORS_ONLN"
185 export YACC
="$BISON -y"
186 export PATH
="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
187 export CFLAGS
="$CFLAGS -I/opt/local/include"
188 export LDFLAGS
="-L/opt/local/lib"
189 export PYTHON
="python3"
190 export PYTHON_CONFIG
="python3-config"
196 export PYTHON
="python3"
197 export PYTHON_CONFIG
="python3-config"
201 # Enter the source directory
204 # Run bootstrap in the source directory prior to configure
207 # Get source version from configure script
208 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
210 # Enable dev mode by default for BT 2.0 builds
211 export BABELTRACE_DEBUG_MODE
=1
212 export BABELTRACE_DEV_MODE
=1
213 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
215 # Set configure options for each build configuration
219 echo "Static lib only configuration"
221 CONF_OPTS
+=("--enable-static" "--disable-shared")
223 if vergte
"$PACKAGE_VERSION" "2.0"; then
224 CONF_OPTS
+=("--enable-built-in-plugins")
229 echo "Python bindings configuration"
231 CONF_OPTS
+=("--enable-python-bindings")
233 if vergte
"$PACKAGE_VERSION" "2.0"; then
234 CONF_OPTS
+=("--enable-python-bindings-doc" "--enable-python-plugins")
239 echo "Production configuration"
241 # Unset the developper variables
242 unset BABELTRACE_DEBUG_MODE
243 unset BABELTRACE_DEV_MODE
244 unset BABELTRACE_MINIMAL_LOG_LEVEL
246 # Enable the python bindings
247 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-bindings-doc" "--enable-python-plugins")
251 echo "Minimal configuration"
255 echo "Standard configuration"
257 # Enable the python bindings / plugins by default with babeltrace2,
258 # the test suite is mostly useless without it.
259 if vergte
"$PACKAGE_VERSION" "2.0"; then
260 CONF_OPTS
+=("--enable-python-bindings" "--enable-python-plugins")
266 # oot : out-of-tree build
267 # dist: build via make dist
268 # * : normal tree build
270 # Make sure to move to the build dir and run configure
274 echo "Out of tree build"
276 BUILDDIR
="$WORKSPACE/oot"
280 "$SRCDIR/configure" --prefix="$PREFIX" "${CONF_OPTS[@]}"
284 echo "Distribution out of tree build"
285 BUILDDIR
="$(mktemp -d)"
287 # Initial configure and generate tarball
292 cp .
/*.
tar.
* "$BUILDDIR/"
295 # Ignore level 1 of tar
296 $TAR xvf .
/*.
tar.
* --strip 1
298 .
/configure
--prefix="$PREFIX" "${CONF_OPTS[@]}"
302 echo "Standard in-tree build"
303 .
/configure
--prefix="$PREFIX" "${CONF_OPTS[@]}"
307 # We are now inside a configured build directory
310 $MAKE -j "$($NPROC)" V
=1
313 # Run tests, don't fail now, we want to run the archiving steps
315 $MAKE --keep-going check
319 # Copy tap logs for the jenkins tap parser before cleaning the build dir
320 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
322 # Clean the build directory
325 # Cleanup rpath in executables and shared libraries
326 find "$PREFIX/bin" -type f
-perm -0500 -exec chrpath
--delete {} \
;
327 find "$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
329 # Remove libtool .la files
330 find "$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
332 # Clean temp dir for dist build
333 if [ "$build" = "dist" ]; then
338 # Exit with the return code of the test suite