Commit | Line | Data |
---|---|---|
3c85b52d | 1 | #!/bin/bash -exu |
b4005bbf | 2 | # |
3c85b52d | 3 | # Copyright (C) 2016 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
b4005bbf MJ |
4 | # 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 | ||
0cdaa21c | 19 | # Version compare functions |
b6e62a6a MJ |
20 | vercomp () { |
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 | ||
0cdaa21c | 47 | verlte() { |
b6e62a6a MJ |
48 | vercomp "$1" "$2"; local res="$?" |
49 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
0cdaa21c MJ |
50 | } |
51 | ||
52 | verlt() { | |
b6e62a6a MJ |
53 | vercomp "$1" "$2"; local res="$?" |
54 | [ "$res" -eq "2" ] | |
0cdaa21c MJ |
55 | } |
56 | ||
57 | vergte() { | |
b6e62a6a MJ |
58 | vercomp "$1" "$2"; local res="$?" |
59 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
0cdaa21c MJ |
60 | } |
61 | ||
62 | vergt() { | |
b6e62a6a MJ |
63 | vercomp "$1" "$2"; local res="$?" |
64 | [ "$res" -eq "1" ] | |
65 | } | |
66 | ||
67 | verne() { | |
68 | vercomp "$1" "$2"; local res="$?" | |
69 | [ "$res" -ne "0" ] | |
0cdaa21c MJ |
70 | } |
71 | ||
212d2afd MJ |
72 | # Required parameters |
73 | arch=${arch:-} | |
74 | conf=${conf:-} | |
75 | build=${build:-} | |
b4005bbf | 76 | |
212d2afd | 77 | SRCDIR="$WORKSPACE/src/lttng-tools" |
67122b96 | 78 | #TMPDIR="$WORKSPACE/tmp" |
212d2afd MJ |
79 | PREFIX="$WORKSPACE/build" |
80 | TAPDIR="$WORKSPACE/tap" | |
81 | ||
82 | ||
83 | # Create build and tmp directories | |
67122b96 MJ |
84 | rm -rf "$PREFIX" "$TAPDIR" |
85 | mkdir -p "$PREFIX" "$TAPDIR" | |
212d2afd | 86 | |
67122b96 | 87 | #export TMPDIR |
72d087d4 | 88 | CFLAGS="-g -O2" |
b4005bbf MJ |
89 | |
90 | # liburcu | |
91 | URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" | |
92 | URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" | |
93 | ||
94 | # lttng-ust | |
95 | UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/" | |
96 | UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/" | |
95654431 | 97 | UST_JAVA="$WORKSPACE/deps/lttng-ust/build/share/java/" |
b4005bbf MJ |
98 | |
99 | # babeltrace | |
212d2afd | 100 | #BABEL_INCS="$WORKSPACE/deps/babeltrace/build/include/" |
b4005bbf MJ |
101 | BABEL_LIBS="$WORKSPACE/deps/babeltrace/build/lib/" |
102 | BABEL_BINS="$WORKSPACE/deps/babeltrace/build/bin/" | |
103 | ||
b4005bbf | 104 | |
0cdaa21c MJ |
105 | # Set platform variables |
106 | case "$arch" in | |
995ac8f2 | 107 | sol10-i386) |
0cdaa21c MJ |
108 | MAKE=gmake |
109 | TAR=gtar | |
110 | NPROC=gnproc | |
111 | BISON="bison" | |
112 | YACC="$BISON -y" | |
72d087d4 | 113 | CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500" |
0cdaa21c | 114 | RUN_TESTS="no" |
ad11244c MJ |
115 | |
116 | export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH" | |
0cdaa21c MJ |
117 | ;; |
118 | ||
995ac8f2 | 119 | sol11-i386) |
0cdaa21c MJ |
120 | MAKE=gmake |
121 | TAR=gtar | |
122 | NPROC=nproc | |
123 | BISON="/opt/csw/bin/bison" | |
124 | YACC="$BISON -y" | |
72d087d4 | 125 | CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500" |
0cdaa21c MJ |
126 | RUN_TESTS="no" |
127 | ||
128 | export PATH="$PATH:/usr/perl5/bin" | |
67acca04 MJ |
129 | CFLAGS="$CFLAGS -I/opt/csw/include" |
130 | LDFLAGS="-L/opt/csw/lib" | |
0cdaa21c MJ |
131 | ;; |
132 | ||
b6e62a6a MJ |
133 | macosx) |
134 | MAKE=make | |
135 | TAR=tar | |
136 | NPROC="getconf _NPROCESSORS_ONLN" | |
137 | BISON="bison" | |
138 | YACC="$BISON -y" | |
139 | RUN_TESTS="no" | |
140 | ||
141 | export PATH="/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" | |
72d087d4 | 142 | CFLAGS="$CFLAGS -I/opt/local/include" |
e6a2206f | 143 | LDFLAGS="-L/opt/local/lib" |
b6e62a6a MJ |
144 | ;; |
145 | ||
61afb3c3 MJ |
146 | cygwin|cygwin64|msys32|msys64) |
147 | MAKE=make | |
148 | TAR=tar | |
149 | NPROC=nproc | |
150 | BISON="bison" | |
151 | YACC="$BISON -y" | |
72d087d4 | 152 | #CFLAGS="" |
61afb3c3 MJ |
153 | RUN_TESTS="no" |
154 | ;; | |
155 | ||
0cdaa21c MJ |
156 | *) |
157 | MAKE=make | |
158 | TAR=tar | |
159 | NPROC=nproc | |
160 | BISON="bison" | |
161 | YACC="$BISON -y" | |
72d087d4 | 162 | #CFLAGS="" |
0cdaa21c MJ |
163 | RUN_TESTS="yes" |
164 | ||
165 | PYTHON2=python2 | |
166 | PYTHON3=python3 | |
167 | ||
168 | P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])") | |
169 | P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])") | |
170 | ||
171 | UST_PYTHON2="$WORKSPACE/deps/lttng-ust/build/lib/python$P2_VERSION/site-packages" | |
172 | UST_PYTHON3="$WORKSPACE/deps/lttng-ust/build/lib/python$P3_VERSION/site-packages" | |
173 | ;; | |
174 | esac | |
175 | ||
176 | ||
212d2afd MJ |
177 | # Enter the source directory |
178 | cd "$SRCDIR" | |
179 | ||
180 | # Run bootstrap in the source directory prior to configure | |
0cdaa21c MJ |
181 | ./bootstrap |
182 | ||
183 | # Get source version from configure script | |
212d2afd MJ |
184 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" |
185 | PACKAGE_VERSION=$(echo "$PACKAGE_VERSION"| sed 's/\-pre$//') | |
0cdaa21c MJ |
186 | |
187 | ||
188 | # Export build flags | |
189 | case "$conf" in | |
190 | no-ust) | |
e6a2206f JR |
191 | CPPFLAGS="${CPPFLAGS:-} -I$URCU_INCS" |
192 | LDFLAGS="${LDFLAGS:-} -L$URCU_LIBS" | |
b4005bbf | 193 | export LD_LIBRARY_PATH="$URCU_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}" |
0cdaa21c MJ |
194 | ;; |
195 | ||
196 | *) | |
e6a2206f JR |
197 | CPPFLAGS="${CPPFLAGS:-} -I$URCU_INCS -I$UST_INCS" |
198 | LDFLAGS="${LDFLAGS:-} -L$URCU_LIBS -L$UST_LIBS" | |
b4005bbf | 199 | export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:$BABEL_LIBS:${LD_LIBRARY_PATH:-}" |
0cdaa21c MJ |
200 | ;; |
201 | esac | |
b4005bbf | 202 | |
0cdaa21c MJ |
203 | # The switch to build without UST changed in 2.8 |
204 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
205 | NO_UST="--without-lttng-ust" | |
206 | else | |
207 | NO_UST="--disable-lttng-ust" | |
208 | fi | |
b4005bbf | 209 | |
0cdaa21c | 210 | # Set configure options for each build configuration |
b4005bbf MJ |
211 | CONF_OPTS="" |
212 | case "$conf" in | |
0cdaa21c MJ |
213 | static) |
214 | echo "Static build" | |
215 | CONF_OPTS="--enable-static --disable-shared" | |
216 | ;; | |
217 | ||
0cdaa21c MJ |
218 | no-ust) |
219 | echo "Build without UST support" | |
220 | CONF_OPTS="$NO_UST" | |
221 | ;; | |
222 | ||
67122b96 MJ |
223 | agents) |
224 | echo "Enable Java Agents" | |
0cdaa21c MJ |
225 | export JAVA_HOME="/usr/lib/jvm/default-java" |
226 | export CLASSPATH="$UST_JAVA/*:/usr/share/java/*" | |
67122b96 | 227 | CONF_OPTS+=" --enable-test-java-agent-all" |
0cdaa21c | 228 | |
67122b96 | 229 | echo "Enable Python agents" |
0cdaa21c | 230 | export PYTHONPATH="$UST_PYTHON2:$UST_PYTHON3" |
67122b96 MJ |
231 | CONF_OPTS+=" --enable-test-python-agent-all" |
232 | ||
233 | echo "Enable Python bindings" | |
234 | # We only support bindings built with Python 3 | |
235 | export PYTHON="python3" | |
236 | export PYTHON_CONFIG="/usr/bin/python3-config" | |
237 | CONF_OPTS+=" --enable-python-bindings" | |
0cdaa21c MJ |
238 | ;; |
239 | ||
240 | relayd-only) | |
241 | echo "Build relayd only" | |
b6e62a6a | 242 | CONF_OPTS="--disable-bin-lttng --disable-bin-lttng-consumerd --disable-bin-lttng-crash --disable-bin-lttng-sessiond --disable-extras --disable-man-pages $NO_UST" |
0cdaa21c MJ |
243 | ;; |
244 | ||
22780fe6 JR |
245 | debug-rcu) |
246 | echo "Enable RCU sanity checks for debugging" | |
247 | CPPFLAGS="${CPPFLAGS:-} -DDEBUG_RCU" | |
248 | ;; | |
249 | ||
0cdaa21c MJ |
250 | *) |
251 | echo "Standard build" | |
252 | CONF_OPTS="" | |
253 | ;; | |
b4005bbf MJ |
254 | esac |
255 | ||
0cdaa21c | 256 | |
b4005bbf | 257 | # Build type |
67122b96 MJ |
258 | # oot : out-of-tree build |
259 | # dist : build via make dist | |
260 | # oot-dist: build via make dist out-of-tree | |
261 | # * : normal tree build | |
b4005bbf | 262 | # |
0cdaa21c | 263 | # Make sure to move to the build_path and run configure |
b4005bbf | 264 | # before continuing |
212d2afd | 265 | BUILD_PATH=$SRCDIR |
b4005bbf | 266 | case "$build" in |
95654431 MJ |
267 | oot) |
268 | echo "Out of tree build" | |
269 | BUILD_PATH=$WORKSPACE/oot | |
b6e62a6a MJ |
270 | mkdir -p "$BUILD_PATH" |
271 | cd "$BUILD_PATH" | |
e6a2206f | 272 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" "$SRCDIR/configure" --prefix="$PREFIX" $CONF_OPTS |
95654431 MJ |
273 | ;; |
274 | ||
275 | dist) | |
67122b96 | 276 | echo "Distribution tarball in-tree build" |
95654431 MJ |
277 | |
278 | # Initial configure and generate tarball | |
e6a2206f | 279 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" "$SRCDIR/configure" $CONF_OPTS --enable-build-man-pages |
0cdaa21c | 280 | $MAKE dist |
95654431 | 281 | |
67122b96 | 282 | BUILD_PATH="$(mktemp -d)" |
b6e62a6a MJ |
283 | cp ./*.tar.* "$BUILD_PATH/" |
284 | cd "$BUILD_PATH" | |
95654431 MJ |
285 | |
286 | # Ignore level 1 of tar | |
b6e62a6a | 287 | $TAR xvf ./*.tar.* --strip 1 |
95654431 | 288 | |
67122b96 | 289 | # Build in extracted source tree |
e6a2206f | 290 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
95654431 MJ |
291 | ;; |
292 | ||
67122b96 MJ |
293 | oot-dist) |
294 | echo "Distribution tarball out of tree build" | |
295 | BUILD_PATH="$(mktemp -d)" | |
296 | cd "$BUILD_PATH" | |
297 | ||
298 | # Initial configure and generate tarball | |
e6a2206f | 299 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" "$SRCDIR/configure" $CONF_OPTS --enable-build-man-pages |
67122b96 MJ |
300 | $MAKE dist |
301 | ||
302 | NEWSRC_PATH="$(mktemp -d)" | |
303 | cp ./*.tar.* "$NEWSRC_PATH/" | |
304 | cd "$NEWSRC_PATH" | |
305 | ||
306 | # Ignore level 1 of tar | |
307 | $TAR xvf ./*.tar.* --strip 1 | |
308 | ||
309 | BUILD_PATH="$(mktemp -d)" | |
310 | cd "$BUILD_PATH" | |
311 | ||
312 | # Build oot from extracted sources | |
e6a2206f | 313 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" "$NEWSRC_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
67122b96 MJ |
314 | ;; |
315 | ||
95654431 | 316 | *) |
95654431 | 317 | echo "Standard tree build" |
e6a2206f | 318 | MAKE=$MAKE BISON="$BISON" YACC="$YACC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CPPFLAGS="$CPPFLAGS" "$BUILD_PATH/configure" --prefix="$PREFIX" $CONF_OPTS |
95654431 | 319 | ;; |
b4005bbf MJ |
320 | esac |
321 | ||
0cdaa21c | 322 | # BUILD! |
212d2afd | 323 | $MAKE -j "$($NPROC)" V=1 |
0cdaa21c | 324 | $MAKE install |
b4005bbf MJ |
325 | |
326 | # Run tests | |
0cdaa21c | 327 | if [ "$RUN_TESTS" = "yes" ]; then |
212d2afd | 328 | cd tests || exit 1 |
7671741c | 329 | |
0cdaa21c MJ |
330 | # Allow core dumps |
331 | ulimit -c unlimited | |
332 | ||
333 | # Add 'babeltrace' binary to PATH | |
7671741c | 334 | chmod +x "$BABEL_BINS/babeltrace" |
0cdaa21c MJ |
335 | export PATH="$PATH:$BABEL_BINS" |
336 | ||
337 | # Prepare tap output dirs | |
212d2afd MJ |
338 | rm -rf "$TAPDIR" |
339 | mkdir -p "$TAPDIR" | |
340 | mkdir -p "$TAPDIR/unit" | |
341 | mkdir -p "$TAPDIR/fast_regression" | |
342 | mkdir -p "$TAPDIR/with_bindings_regression" | |
0cdaa21c | 343 | |
a4e98cc0 JR |
344 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a |
345 | # lttng-sessiond --daemonize on "lttng create" | |
346 | export LTTNG_SESSIOND_PATH="/bin/true" | |
347 | ||
0cdaa21c MJ |
348 | # Run 'unit_tests' and 'fast_regression' test suites for all configs except 'no-ust' |
349 | if [ "$conf" != "no-ust" ]; then | |
3c85b52d MJ |
350 | # Run 'unit_tests', 2.8 and up has a new test suite |
351 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
6827c67a | 352 | make --keep-going check |
212d2afd | 353 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*'" $BUILD_PATH/tests/" "$TAPDIR" |
3c85b52d | 354 | else |
212d2afd MJ |
355 | prove --merge -v --exec '' - < "$BUILD_PATH/tests/unit_tests" --archive "$TAPDIR/unit/" || true |
356 | prove --merge -v --exec '' - < "$BUILD_PATH/tests/fast_regression" --archive "$TAPDIR/fast_regression/" || true | |
3c85b52d | 357 | fi |
0cdaa21c MJ |
358 | else |
359 | # Regression is disabled for now, we need to adjust the testsuite for no ust builds. | |
3c85b52d | 360 | echo "Tests disabled for 'no-ust'." |
0cdaa21c MJ |
361 | fi |
362 | ||
363 | # Run 'with_bindings_regression' test suite for 'python-bindings' config | |
364 | if [ "$conf" = "python-bindings" ]; then | |
212d2afd | 365 | prove --merge -v --exec '' - < "$BUILD_PATH/tests/with_bindings_regression" --archive "$TAPDIR/with_bindings_regression/" || true |
0cdaa21c MJ |
366 | fi |
367 | ||
368 | # TAP plugin is having a hard time with .yml files. | |
212d2afd | 369 | find "$TAPDIR" -name "meta.yml" -exec rm -f {} \; |
0cdaa21c MJ |
370 | |
371 | # And also with files without extension, so rename all result to *.tap | |
212d2afd | 372 | find "$TAPDIR/" -type f -exec mv {} {}.tap \; |
7671741c MJ |
373 | |
374 | cd - | |
b4005bbf MJ |
375 | fi |
376 | ||
b4005bbf | 377 | # Cleanup |
0cdaa21c | 378 | $MAKE clean |
b4005bbf | 379 | |
0cdaa21c | 380 | # Cleanup rpath in executables and shared libraries |
212d2afd MJ |
381 | find "$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \; |
382 | find "$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; | |
0cdaa21c MJ |
383 | |
384 | # Remove libtool .la files | |
212d2afd | 385 | find "$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
b4005bbf MJ |
386 | |
387 | # Clean temp dir for dist build | |
0cdaa21c | 388 | if [ "$build" = "dist" ]; then |
212d2afd | 389 | cd "$SRCDIR" |
7671741c | 390 | rm -rf "$BUILD_PATH" |
b4005bbf | 391 | fi |
95654431 MJ |
392 | |
393 | # EOF |