Commit | Line | Data |
---|---|---|
3c85b52d | 1 | #!/bin/bash -exu |
09d45745 | 2 | # shellcheck disable=SC2103 |
b4005bbf | 3 | # |
09d45745 MJ |
4 | # Copyright (C) 2016 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
5 | # 2016-2019 Michael Jeanson <mjeanson@efficios.com> | |
b4005bbf MJ |
6 | # |
7 | # This program is free software: you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation, either version 3 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
0cdaa21c | 20 | # Version compare functions |
b6e62a6a MJ |
21 | vercomp () { |
22 | set +u | |
23 | if [[ "$1" == "$2" ]]; then | |
24 | return 0 | |
25 | fi | |
26 | local IFS=. | |
27 | local i ver1=($1) ver2=($2) | |
28 | # fill empty fields in ver1 with zeros | |
29 | for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do | |
30 | ver1[i]=0 | |
31 | done | |
32 | for ((i=0; i<${#ver1[@]}; i++)); do | |
33 | if [[ -z ${ver2[i]} ]]; then | |
34 | # fill empty fields in ver2 with zeros | |
35 | ver2[i]=0 | |
36 | fi | |
37 | if ((10#${ver1[i]} > 10#${ver2[i]})); then | |
38 | return 1 | |
39 | fi | |
40 | if ((10#${ver1[i]} < 10#${ver2[i]})); then | |
41 | return 2 | |
42 | fi | |
43 | done | |
44 | set -u | |
45 | return 0 | |
46 | } | |
47 | ||
0cdaa21c | 48 | verlte() { |
b6e62a6a MJ |
49 | vercomp "$1" "$2"; local res="$?" |
50 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
0cdaa21c MJ |
51 | } |
52 | ||
53 | verlt() { | |
b6e62a6a MJ |
54 | vercomp "$1" "$2"; local res="$?" |
55 | [ "$res" -eq "2" ] | |
0cdaa21c MJ |
56 | } |
57 | ||
58 | vergte() { | |
b6e62a6a MJ |
59 | vercomp "$1" "$2"; local res="$?" |
60 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
0cdaa21c MJ |
61 | } |
62 | ||
63 | vergt() { | |
b6e62a6a MJ |
64 | vercomp "$1" "$2"; local res="$?" |
65 | [ "$res" -eq "1" ] | |
66 | } | |
67 | ||
68 | verne() { | |
69 | vercomp "$1" "$2"; local res="$?" | |
70 | [ "$res" -ne "0" ] | |
0cdaa21c MJ |
71 | } |
72 | ||
09d45745 MJ |
73 | # Required variables |
74 | WORKSPACE=${WORKSPACE:-} | |
75 | ||
212d2afd MJ |
76 | arch=${arch:-} |
77 | conf=${conf:-} | |
78 | build=${build:-} | |
09d45745 | 79 | cc=${cc:-} |
9699c0e7 | 80 | test_type=${test_type:-} |
b4005bbf | 81 | |
09d45745 MJ |
82 | DEPS_INC="$WORKSPACE/deps/build/include" |
83 | DEPS_LIB="$WORKSPACE/deps/build/lib" | |
84 | DEPS_BIN="$WORKSPACE/deps/build/bin" | |
85 | DEPS_JAVA="$WORKSPACE/deps/build/share/java" | |
86 | ||
87 | export PATH="$DEPS_BIN:$PATH" | |
88 | export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}" | |
89 | export CPPFLAGS="-I$DEPS_INC" | |
90 | export LDFLAGS="-L$DEPS_LIB" | |
91 | ||
212d2afd | 92 | SRCDIR="$WORKSPACE/src/lttng-tools" |
212d2afd | 93 | TAPDIR="$WORKSPACE/tap" |
09d45745 | 94 | PREFIX="/build" |
212d2afd MJ |
95 | |
96 | ||
09d45745 MJ |
97 | # Create tmp directory |
98 | TMPDIR="$WORKSPACE/tmp" | |
99 | mkdir -p "$TMPDIR" | |
212d2afd | 100 | |
09d45745 MJ |
101 | # Use a symlink in /tmp to point to the the tmp directory |
102 | # inside the workspace, this is to work around the path length | |
103 | # limit of unix sockets which are created by the test suite. | |
104 | tmpdir="$(mktemp)" | |
105 | ln -sf "$TMPDIR" "$tmpdir" | |
106 | export TMPDIR="$tmpdir" | |
b4005bbf | 107 | |
09d45745 | 108 | export CFLAGS="-g -O2" |
b4005bbf | 109 | |
09d45745 MJ |
110 | # Set compiler variables |
111 | case "$cc" in | |
112 | gcc) | |
113 | export CC=gcc | |
114 | export CXX=g++ | |
115 | ;; | |
116 | gcc-4.8) | |
117 | export CC=gcc-4.8 | |
118 | export CXX=g++-4.8 | |
119 | ;; | |
120 | gcc-5) | |
121 | export CC=gcc-5 | |
122 | export CXX=g++-5 | |
123 | ;; | |
124 | gcc-6) | |
125 | export CC=gcc-6 | |
126 | export CXX=g++-6 | |
127 | ;; | |
128 | gcc-7) | |
129 | export CC=gcc-7 | |
130 | export CXX=g++-7 | |
131 | ;; | |
132 | gcc-8) | |
133 | export CC=gcc-8 | |
134 | export CXX=g++-8 | |
135 | ;; | |
136 | clang) | |
137 | export CC=clang | |
138 | export CXX=clang++ | |
139 | ;; | |
140 | clang-3.9) | |
141 | export CC=clang-3.9 | |
142 | export CXX=clang++-3.9 | |
143 | ;; | |
144 | clang-4.0) | |
145 | export CC=clang-4.0 | |
146 | export CXX=clang++-4.0 | |
147 | ;; | |
148 | clang-5.0) | |
149 | export CC=clang-5.0 | |
150 | export CXX=clang++-5.0 | |
151 | ;; | |
152 | clang-6.0) | |
153 | export CC=clang-6.0 | |
154 | export CXX=clang++-6.0 | |
155 | ;; | |
156 | clang-7) | |
157 | export CC=clang-7 | |
158 | export CXX=clang++-7 | |
159 | ;; | |
160 | *) | |
161 | if [ "x$cc" != "x" ]; then | |
162 | export CC="$cc" | |
163 | fi | |
164 | ;; | |
165 | esac | |
b4005bbf | 166 | |
09d45745 MJ |
167 | if [ "x${CC:-}" != "x" ]; then |
168 | echo "Selected compiler:" | |
169 | "$CC" -v | |
170 | fi | |
b4005bbf | 171 | |
0cdaa21c MJ |
172 | # Set platform variables |
173 | case "$arch" in | |
995ac8f2 | 174 | sol10-i386) |
09d45745 MJ |
175 | export MAKE=gmake |
176 | export TAR=gtar | |
177 | export NPROC=gnproc | |
ad11244c | 178 | export PATH="/opt/csw/bin:/usr/ccs/bin:$PATH" |
09d45745 MJ |
179 | export CPPFLAGS="-I/opt/csw/include -D_XOPEN_SOURCE=500 $CPPFLAGS" |
180 | export LDFLAGS="-L/opt/csw/lib -R/opt/csw/lib $LDFLAGS" | |
181 | export PKG_CONFIG_PATH="/opt/csw/lib/pkgconfig" | |
182 | export PYTHON="python3" | |
183 | export PYTHON_CONFIG="python3-config" | |
0cdaa21c | 184 | |
0cdaa21c | 185 | RUN_TESTS="no" |
09d45745 | 186 | ;; |
0cdaa21c | 187 | |
09d45745 MJ |
188 | sol11-i386) |
189 | export MAKE=gmake | |
190 | export TAR=gtar | |
191 | export NPROC=nproc | |
0cdaa21c | 192 | export PATH="$PATH:/usr/perl5/bin" |
09d45745 MJ |
193 | export CPPFLAGS="-I/opt/csw/include -D_XOPEN_SOURCE=500 $CPPFLAGS" |
194 | export LDFLAGS="-L/opt/csw/lib -R/opt/csw/lib $LDFLAGS" | |
195 | export PYTHON="python3" | |
196 | export PYTHON_CONFIG="python3-config" | |
197 | ||
198 | RUN_TESTS="no" | |
0cdaa21c MJ |
199 | ;; |
200 | ||
b6e62a6a | 201 | macosx) |
09d45745 MJ |
202 | export MAKE=make |
203 | export TAR=tar | |
204 | export NPROC="getconf _NPROCESSORS_ONLN" | |
205 | export PATH="/opt/local/bin:/opt/local/sbin:$PATH" | |
206 | export CPPFLAGS="-I/opt/local/include $CPPFLAGS" | |
207 | export LDFLAGS="-L/opt/local/lib $LDFLAGS" | |
208 | export PYTHON="python3" | |
209 | export PYTHON_CONFIG="python3-config" | |
b6e62a6a | 210 | |
09d45745 | 211 | RUN_TESTS="no" |
b6e62a6a MJ |
212 | ;; |
213 | ||
61afb3c3 | 214 | cygwin|cygwin64|msys32|msys64) |
09d45745 MJ |
215 | export MAKE=make |
216 | export TAR=tar | |
217 | export NPROC=nproc | |
218 | ||
61afb3c3 MJ |
219 | RUN_TESTS="no" |
220 | ;; | |
221 | ||
0cdaa21c | 222 | *) |
09d45745 MJ |
223 | export MAKE=make |
224 | export TAR=tar | |
225 | export NPROC=nproc | |
226 | ||
0cdaa21c MJ |
227 | RUN_TESTS="yes" |
228 | ||
229 | PYTHON2=python2 | |
230 | PYTHON3=python3 | |
231 | ||
232 | P2_VERSION=$($PYTHON2 -c "import sys;print(sys.version[:3])") | |
233 | P3_VERSION=$($PYTHON3 -c "import sys;print(sys.version[:3])") | |
234 | ||
09d45745 MJ |
235 | DEPS_PYTHON2="$WORKSPACE/deps/build/lib/python$P2_VERSION/site-packages" |
236 | DEPS_PYTHON3="$WORKSPACE/deps/build/lib/python$P3_VERSION/site-packages" | |
0cdaa21c MJ |
237 | ;; |
238 | esac | |
239 | ||
9699c0e7 | 240 | case "$test_type" in |
9699c0e7 | 241 | full) |
09d45745 MJ |
242 | RUN_TESTS_LONG_REGRESSION="yes" |
243 | ;; | |
9699c0e7 | 244 | *) |
09d45745 MJ |
245 | RUN_TESTS_LONG_REGRESSION="no" |
246 | ;; | |
9699c0e7 | 247 | esac |
0cdaa21c | 248 | |
212d2afd MJ |
249 | # Enter the source directory |
250 | cd "$SRCDIR" | |
251 | ||
252 | # Run bootstrap in the source directory prior to configure | |
0cdaa21c MJ |
253 | ./bootstrap |
254 | ||
255 | # Get source version from configure script | |
212d2afd | 256 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" |
09d45745 | 257 | PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/} |
0cdaa21c | 258 | |
b4005bbf | 259 | |
0cdaa21c MJ |
260 | # The switch to build without UST changed in 2.8 |
261 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
262 | NO_UST="--without-lttng-ust" | |
263 | else | |
264 | NO_UST="--disable-lttng-ust" | |
265 | fi | |
b4005bbf | 266 | |
6c3ec80e | 267 | # Most build configs require the python bindings |
09d45745 | 268 | CONF_OPTS=("--prefix=$PREFIX" "--enable-python-bindings") |
6c3ec80e | 269 | |
09d45745 MJ |
270 | # Set configure options and environment variables for each build |
271 | # configuration. | |
b4005bbf | 272 | case "$conf" in |
0cdaa21c | 273 | static) |
09d45745 MJ |
274 | echo "Static lib only configuration" |
275 | ||
276 | CONF_OPTS+=("--enable-static" "--disable-shared") | |
0cdaa21c MJ |
277 | ;; |
278 | ||
0cdaa21c MJ |
279 | no-ust) |
280 | echo "Build without UST support" | |
09d45745 | 281 | CONF_OPTS+=("$NO_UST") |
0cdaa21c MJ |
282 | ;; |
283 | ||
67122b96 | 284 | agents) |
09d45745 MJ |
285 | echo "Java and Python agents configuration" |
286 | ||
0cdaa21c | 287 | export JAVA_HOME="/usr/lib/jvm/default-java" |
09d45745 MJ |
288 | export CLASSPATH="$DEPS_JAVA/*:/usr/share/java/*" |
289 | export PYTHONPATH="$DEPS_PYTHON2:$DEPS_PYTHON3" | |
0cdaa21c | 290 | |
09d45745 | 291 | CONF_OPTS+=("--enable-test-java-agent-all" "--enable-test-python-agent-all") |
0cdaa21c MJ |
292 | ;; |
293 | ||
294 | relayd-only) | |
09d45745 MJ |
295 | echo "Relayd only configuration" |
296 | ||
297 | CONF_OPTS=("--prefix=$PREFIX" "--disable-bin-lttng" "--disable-bin-lttng-consumerd" "--disable-bin-lttng-crash" "--disable-bin-lttng-sessiond" "--disable-extras" "--disable-man-pages" "$NO_UST") | |
0cdaa21c MJ |
298 | ;; |
299 | ||
22780fe6 JR |
300 | debug-rcu) |
301 | echo "Enable RCU sanity checks for debugging" | |
09d45745 MJ |
302 | |
303 | export CPPFLAGS="$CPPFLAGS -DDEBUG_RCU" | |
22780fe6 JR |
304 | ;; |
305 | ||
0cdaa21c | 306 | *) |
09d45745 | 307 | echo "Standard configuration" |
0cdaa21c | 308 | ;; |
b4005bbf MJ |
309 | esac |
310 | ||
311 | # Build type | |
67122b96 MJ |
312 | # oot : out-of-tree build |
313 | # dist : build via make dist | |
314 | # oot-dist: build via make dist out-of-tree | |
315 | # * : normal tree build | |
b4005bbf | 316 | # |
09d45745 MJ |
317 | # Make sure to move to the build directory and run configure |
318 | # before continuing. | |
b4005bbf | 319 | case "$build" in |
09d45745 MJ |
320 | oot) |
321 | echo "Out of tree build" | |
322 | ||
323 | # Create and enter a temporary build directory | |
324 | builddir=$(mktemp -d) | |
325 | cd "$builddir" | |
326 | ||
327 | "$SRCDIR/configure" "${CONF_OPTS[@]}" | |
328 | ;; | |
329 | ||
330 | dist) | |
331 | echo "Distribution in-tree build" | |
332 | ||
333 | # Run configure and generate the tar file | |
334 | # in the source directory | |
335 | ./configure | |
336 | $MAKE dist | |
337 | ||
338 | # Create and enter a temporary build directory | |
339 | builddir=$(mktemp -d) | |
340 | cd "$builddir" | |
341 | ||
342 | # Extract the distribution tar in the build directory, | |
343 | # ignore the first directory level | |
344 | $TAR xvf "$SRCDIR"/*.tar.* --strip 1 | |
345 | ||
346 | # Build in extracted source tree | |
347 | ./configure "${CONF_OPTS[@]}" | |
348 | ;; | |
349 | ||
350 | oot-dist) | |
351 | echo "Distribution out of tree build" | |
352 | ||
353 | # Create and enter a temporary build directory | |
354 | builddir=$(mktemp -d) | |
355 | cd "$builddir" | |
356 | ||
357 | # Run configure out of tree and generate the tar file | |
358 | "$SRCDIR/configure" | |
359 | $MAKE dist | |
360 | ||
361 | dist_srcdir="$(mktemp -d)" | |
362 | cd "$dist_srcdir" | |
363 | ||
364 | # Extract the distribution tar in the new source directory, | |
365 | # ignore the first directory level | |
366 | $TAR xvf "$builddir"/*.tar.* --strip 1 | |
367 | ||
368 | # Create and enter a second temporary build directory | |
369 | builddir="$(mktemp -d)" | |
370 | cd "$builddir" | |
371 | ||
372 | # Run configure from the extracted distribution tar, | |
373 | # out of the source tree | |
374 | "$dist_srcdir/configure" "${CONF_OPTS[@]}" | |
375 | ;; | |
376 | ||
377 | *) | |
378 | echo "Standard in-tree build" | |
379 | ./configure "${CONF_OPTS[@]}" | |
380 | ;; | |
b4005bbf MJ |
381 | esac |
382 | ||
09d45745 MJ |
383 | # We are now inside a configured build directory |
384 | ||
0cdaa21c | 385 | # BUILD! |
212d2afd | 386 | $MAKE -j "$($NPROC)" V=1 |
b4005bbf | 387 | |
09d45745 MJ |
388 | # Install in the workspace |
389 | $MAKE install DESTDIR="$WORKSPACE" | |
7671741c | 390 | |
09d45745 MJ |
391 | # Run tests for all configs except 'no-ust' |
392 | failed_tests=0 | |
393 | if [ "$RUN_TESTS" = "yes" ] && [ "$conf" != "no-ust" ]; then | |
0cdaa21c MJ |
394 | # Allow core dumps |
395 | ulimit -c unlimited | |
396 | ||
a4e98cc0 JR |
397 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a |
398 | # lttng-sessiond --daemonize on "lttng create" | |
399 | export LTTNG_SESSIOND_PATH="/bin/true" | |
400 | ||
09d45745 MJ |
401 | # Run 'unit_tests', 2.8 and up has a new test suite |
402 | if vergte "$PACKAGE_VERSION" "2.8"; then | |
403 | make --keep-going check || failed_tests=1 | |
404 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR" | |
0cdaa21c | 405 | else |
09d45745 MJ |
406 | cd tests |
407 | mkdir -p "$TAPDIR/unit" | |
408 | mkdir -p "$TAPDIR/fast_regression" | |
409 | mkdir -p "$TAPDIR/with_bindings_regression" | |
410 | prove --merge -v --exec '' - < unit_tests --archive "$TAPDIR/unit/" || failed_tests=1 | |
411 | prove --merge -v --exec '' - < fast_regression --archive "$TAPDIR/fast_regression/" || failed_tests=1 | |
412 | prove --merge -v --exec '' - < with_bindings_regression --archive "$TAPDIR/with_bindings_regression/" || failed_tests=1 | |
413 | cd .. | |
414 | fi | |
415 | ||
416 | if [ "$RUN_TESTS_LONG_REGRESSION" = "yes" ]; then | |
417 | cd tests | |
418 | mkdir -p "$TAPDIR/long_regression" | |
419 | prove --merge -v --exec '' - < long_regression --archive "$TAPDIR/long_regression/" || failed_tests=1 | |
420 | cd .. | |
0cdaa21c MJ |
421 | fi |
422 | ||
0cdaa21c | 423 | # TAP plugin is having a hard time with .yml files. |
212d2afd | 424 | find "$TAPDIR" -name "meta.yml" -exec rm -f {} \; |
09d45745 MJ |
425 | else |
426 | # The TAP plugin will fail the job if no test logs are present | |
427 | mkdir -p "$TAPDIR/no-tests" | |
428 | echo "1..1" > "$TAPDIR/no-tests/tests.log" | |
429 | echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log" | |
b4005bbf MJ |
430 | fi |
431 | ||
09d45745 | 432 | # Clean the build directory |
0cdaa21c | 433 | $MAKE clean |
b4005bbf | 434 | |
0cdaa21c | 435 | # Cleanup rpath in executables and shared libraries |
09d45745 MJ |
436 | find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \; |
437 | find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath --delete {} \; | |
0cdaa21c MJ |
438 | |
439 | # Remove libtool .la files | |
09d45745 | 440 | find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \; |
b4005bbf | 441 | |
09d45745 MJ |
442 | # Exit with failure if any of the tests failed |
443 | exit $failed_tests | |
95654431 MJ |
444 | |
445 | # EOF |