jjb: Use bt stable-1.5 for all lttng-tools jobs
[lttng-ci.git] / scripts / babeltrace / build.sh
... / ...
CommitLineData
1#!/bin/bash -exu
2#
3# Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4# 2016 - Michael Jeanson <mjeanson@efficios.com>
5#
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.
10#
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.
15#
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/>.
18
19# Version compare functions
20vercomp () {
21 set +u
22 if [[ "$1" == "$2" ]]; then
23 return 0
24 fi
25 local IFS=.
26 local i ver1=($1) ver2=($2)
27 # fill empty fields in ver1 with zeros
28 for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
29 ver1[i]=0
30 done
31 for ((i=0; i<${#ver1[@]}; i++)); do
32 if [[ -z ${ver2[i]} ]]; then
33 # fill empty fields in ver2 with zeros
34 ver2[i]=0
35 fi
36 if ((10#${ver1[i]} > 10#${ver2[i]})); then
37 return 1
38 fi
39 if ((10#${ver1[i]} < 10#${ver2[i]})); then
40 return 2
41 fi
42 done
43 set -u
44 return 0
45}
46
47verlte() {
48 vercomp "$1" "$2"; local res="$?"
49 [ "$res" -eq "0" ] || [ "$res" -eq "2" ]
50}
51
52verlt() {
53 vercomp "$1" "$2"; local res="$?"
54 [ "$res" -eq "2" ]
55}
56
57vergte() {
58 vercomp "$1" "$2"; local res="$?"
59 [ "$res" -eq "0" ] || [ "$res" -eq "1" ]
60}
61
62vergt() {
63 vercomp "$1" "$2"; local res="$?"
64 [ "$res" -eq "1" ]
65}
66
67verne() {
68 vercomp "$1" "$2"; local res="$?"
69 [ "$res" -ne "0" ]
70}
71
72# Required parameters
73arch=${arch:-}
74conf=${conf:-}
75build=${build:-}
76
77
78SRCDIR="$WORKSPACE/src/babeltrace"
79TMPDIR="$WORKSPACE/tmp"
80PREFIX="$WORKSPACE/build"
81
82# Create build and tmp directories
83rm -rf "$PREFIX" "$TMPDIR"
84mkdir -p "$PREFIX" "$TMPDIR"
85
86export TMPDIR
87export CFLAGS="-g -O2"
88
89# Set platform variables
90case "$arch" in
91sol10-i386)
92 export MAKE=gmake
93 export TAR=gtar
94 export NPROC=gnproc
95 export BISON=bison
96 export YACC="$BISON -y"
97 export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH"
98 export CPPFLAGS="-I/opt/csw/include"
99 export LDFLAGS="-L/opt/csw/lib -R/opt/csw/lib"
100 export PKG_CONFIG_PATH="/opt/csw/lib/pkgconfig"
101 ;;
102sol11-i386)
103 export MAKE=gmake
104 export TAR=gtar
105 export NPROC=nproc
106 export BISON="/opt/csw/bin/bison"
107 export YACC="$BISON -y"
108 export PATH="$PATH:/usr/perl5/bin"
109 export LD_ALTEXEC=/usr/sfw/bin/gld
110 export LD=/usr/sfw/bin/gld
111 ;;
112macosx)
113 export MAKE=make
114 export TAR=tar
115 export NPROC="getconf _NPROCESSORS_ONLN"
116 export BISON="bison"
117 export YACC="$BISON -y"
118 export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
119 export CFLAGS="$CFLAGS -I/opt/local/include"
120 export LDFLAGS="-L/opt/local/lib"
121 ;;
122*)
123 export MAKE=make
124 export TAR=tar
125 export NPROC=nproc
126 ;;
127esac
128
129# Enter the source directory
130cd "$SRCDIR"
131
132# Run bootstrap in the source directory prior to configure
133./bootstrap
134
135# Get source version from configure script
136eval "$(grep '^PACKAGE_VERSION=' ./configure)"
137
138# Set configure options for each build configuration
139CONF_OPTS=""
140case "$conf" in
141static)
142 echo "Static build"
143 CONF_OPTS="--enable-static --disable-shared"
144 if vergte "$PACKAGE_VERSION" "2.0"; then
145 CONF_OPTS="${CONF_OPTS} --enable-built-in-plugins"
146 fi
147 ;;
148python-bindings)
149 echo "Build with python bindings"
150 # We only support bindings built with Python 3
151 export PYTHON="python3"
152 export PYTHON_CONFIG="/usr/bin/python3-config"
153 CONF_OPTS="--enable-python-bindings"
154
155 if vergte "$PACKAGE_VERSION" "2.0"; then
156 CONF_OPTS="${CONF_OPTS} --enable-python-bindings-doc --enable-python-bindings-tests --enable-python-plugins"
157 fi
158 ;;
159*)
160 echo "Standard build"
161 CONF_OPTS=""
162 ;;
163esac
164
165# Build type
166# oot : out-of-tree build
167# dist: build via make dist
168# * : normal tree build
169#
170# Make sure to move to the build_path and configure
171# before continuing
172BUILD_PATH="$SRCDIR"
173case "$build" in
174 oot)
175 echo "Out of tree build"
176 BUILD_PATH="$WORKSPACE/oot"
177 mkdir -p "$BUILD_PATH"
178 cd "$BUILD_PATH"
179 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
180 ;;
181
182 dist)
183 echo "Distribution out of tree build"
184 BUILD_PATH="$(mktemp -d)"
185
186 # Initial configure and generate tarball
187 "$SRCDIR/configure"
188 $MAKE dist
189
190 mkdir -p "$BUILD_PATH"
191 cp ./*.tar.* "$BUILD_PATH/"
192 cd "$BUILD_PATH"
193
194 # Ignore level 1 of tar
195 $TAR xvf ./*.tar.* --strip 1
196
197 "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS
198 ;;
199
200 clang)
201 echo "LLVM clang build"
202 export CC=clang
203 clang -v
204 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
205 ;;
206 *)
207 echo "Standard in-tree build"
208 "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS
209 ;;
210esac
211
212# BUILD!
213$MAKE -j "$($NPROC)" V=1
214$MAKE install
215
216# Run tests
217$MAKE --keep-going check
218
219# Copy tap logs for the jenkins tap parser
220rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$WORKSPACE/tap"
221
222# Clean the build directory
223$MAKE clean
224
225# Cleanup rpath in executables and shared libraries
226find "$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
227find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \;
228
229# Remove libtool .la files
230find "$PREFIX/lib" -name "*.la" -exec rm -f {} \;
231
232# Clean temp dir for dist build
233if [ "$build" = "dist" ]; then
234 cd "$SRCDIR"
235 rm -rf "$BUILD_PATH"
236fi
237
238# EOF
This page took 0.025248 seconds and 4 git commands to generate.