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