Commit | Line | Data |
---|---|---|
51c9c62d | 1 | #!/bin/bash |
b4005bbf | 2 | # |
1ad4c3d0 MJ |
3 | # SPDX-FileCopyrightText: 2016 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> |
4 | # SPDX-FileCopyrightText: 2016-2023 Michael Jeanson <mjeanson@efficios.com> | |
5 | # SPDX-License-Identifier: GPL-2.0-or-later | |
b4005bbf | 6 | # |
1ad4c3d0 | 7 | # shellcheck disable=SC2103 |
b4005bbf | 8 | |
51c9c62d MJ |
9 | set -exu |
10 | ||
0cdaa21c | 11 | # Version compare functions |
b6e62a6a MJ |
12 | vercomp () { |
13 | set +u | |
14 | if [[ "$1" == "$2" ]]; then | |
15 | return 0 | |
16 | fi | |
17 | local IFS=. | |
4afa623f MJ |
18 | # Ignore the shellcheck warning, we want splitting to happen based on IFS. |
19 | # shellcheck disable=SC2206 | |
b6e62a6a MJ |
20 | local i ver1=($1) ver2=($2) |
21 | # fill empty fields in ver1 with zeros | |
22 | for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do | |
23 | ver1[i]=0 | |
24 | done | |
25 | for ((i=0; i<${#ver1[@]}; i++)); do | |
26 | if [[ -z ${ver2[i]} ]]; then | |
27 | # fill empty fields in ver2 with zeros | |
28 | ver2[i]=0 | |
29 | fi | |
30 | if ((10#${ver1[i]} > 10#${ver2[i]})); then | |
31 | return 1 | |
32 | fi | |
33 | if ((10#${ver1[i]} < 10#${ver2[i]})); then | |
34 | return 2 | |
35 | fi | |
36 | done | |
37 | set -u | |
38 | return 0 | |
39 | } | |
40 | ||
0cdaa21c | 41 | verlte() { |
b6e62a6a MJ |
42 | vercomp "$1" "$2"; local res="$?" |
43 | [ "$res" -eq "0" ] || [ "$res" -eq "2" ] | |
0cdaa21c MJ |
44 | } |
45 | ||
46 | verlt() { | |
b6e62a6a MJ |
47 | vercomp "$1" "$2"; local res="$?" |
48 | [ "$res" -eq "2" ] | |
0cdaa21c MJ |
49 | } |
50 | ||
51 | vergte() { | |
b6e62a6a MJ |
52 | vercomp "$1" "$2"; local res="$?" |
53 | [ "$res" -eq "0" ] || [ "$res" -eq "1" ] | |
0cdaa21c MJ |
54 | } |
55 | ||
56 | vergt() { | |
b6e62a6a MJ |
57 | vercomp "$1" "$2"; local res="$?" |
58 | [ "$res" -eq "1" ] | |
59 | } | |
60 | ||
61 | verne() { | |
62 | vercomp "$1" "$2"; local res="$?" | |
63 | [ "$res" -ne "0" ] | |
0cdaa21c MJ |
64 | } |
65 | ||
1ad4c3d0 MJ |
66 | print_header() { |
67 | set +x | |
68 | ||
69 | local message=" $1 " | |
70 | local message_len | |
71 | local padding_len | |
72 | ||
73 | message_len="${#message}" | |
74 | padding_len=$(( (80 - (message_len)) / 2 )) | |
75 | ||
76 | ||
77 | printf '\n'; printf -- '#%.0s' {1..80}; printf '\n' | |
78 | printf -- '-%.0s' {1..80}; printf '\n' | |
79 | printf -- '#%.0s' $(seq 1 $padding_len); printf '%s' "$message"; printf -- '#%.0s' $(seq 1 $padding_len); printf '\n' | |
80 | printf -- '-%.0s' {1..80}; printf '\n' | |
81 | printf -- '#%.0s' {1..80}; printf '\n\n' | |
82 | ||
83 | set -x | |
84 | } | |
85 | ||
51c9c62d MJ |
86 | failed_configure() { |
87 | # Assume we are in the configured build directory | |
1ad4c3d0 | 88 | print_header "BEGIN config.log" |
51c9c62d | 89 | cat config.log |
1ad4c3d0 | 90 | print_header "END config.log" |
51c9c62d MJ |
91 | |
92 | # End the build with failure | |
93 | exit 1 | |
94 | } | |
95 | ||
54c3c7ec JR |
96 | set_execute_traversal_bit() |
97 | { | |
98 | path=$1 | |
99 | ||
100 | level="$path" | |
101 | if [ ! -d "$path" ]; then | |
102 | fail "Path is not a directory" | |
103 | fi | |
104 | while level="$(dirname "$level")" | |
105 | do | |
106 | if [ "$level" = / ]; then | |
107 | break | |
108 | fi | |
109 | chmod a+x "$level" | |
110 | done | |
111 | chmod a+x "$path" | |
112 | } | |
113 | ||
1ad4c3d0 MJ |
114 | print_header "LTTng-tools build script starting" |
115 | ||
09d45745 MJ |
116 | # Required variables |
117 | WORKSPACE=${WORKSPACE:-} | |
118 | ||
1ad4c3d0 | 119 | # Axis |
5fcae288 | 120 | platform=${platform:-} |
212d2afd MJ |
121 | conf=${conf:-} |
122 | build=${build:-} | |
09d45745 | 123 | cc=${cc:-} |
1ad4c3d0 MJ |
124 | |
125 | # Build steps that can be overriden by the environment | |
126 | LTTNG_TOOLS_MAKE_INSTALL="${LTTNG_TOOLS_MAKE_INSTALL:-yes}" | |
127 | LTTNG_TOOLS_MAKE_CLEAN="${LTTNG_TOOLS_MAKE_CLEAN:-yes}" | |
128 | LTTNG_TOOLS_GEN_COMPILE_COMMANDS="${LTTNG_TOOLS_GEN_COMPILE_COMMANDS:-no}" | |
129 | LTTNG_TOOLS_RUN_TESTS="${LTTNG_TOOLS_RUN_TESTS:-yes}" | |
130 | LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION="${LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION:-no}" | |
131 | LTTNG_TOOLS_CLANG_TIDY="${LTTNG_TOOLS_CLANG_TIDY:-no}" | |
b4005bbf | 132 | |
4afa623f MJ |
133 | SRCDIR="$WORKSPACE/src/lttng-tools" |
134 | TAPDIR="$WORKSPACE/tap" | |
135 | PREFIX="/build" | |
136 | LIBDIR="lib" | |
32dde2a3 | 137 | LIBDIR_ARCH="$LIBDIR" |
4afa623f MJ |
138 | |
139 | # RHEL and SLES both use lib64 but don't bother shipping a default autoconf | |
140 | # site config that matches this. | |
47ca4354 | 141 | if [[ ( -f /etc/redhat-release || -f /etc/products.d/SLES.prod || -f /etc/yocto-release ) ]]; then |
85322e5d MJ |
142 | # Detect the userspace bitness in a distro agnostic way |
143 | if file -L /bin/bash | grep '64-bit' >/dev/null 2>&1; then | |
144 | LIBDIR_ARCH="${LIBDIR}64" | |
85322e5d | 145 | fi |
4afa623f MJ |
146 | fi |
147 | ||
09d45745 | 148 | DEPS_INC="$WORKSPACE/deps/build/include" |
4afa623f | 149 | DEPS_LIB="$WORKSPACE/deps/build/$LIBDIR_ARCH" |
b8bdba8f | 150 | DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig" |
09d45745 MJ |
151 | DEPS_BIN="$WORKSPACE/deps/build/bin" |
152 | DEPS_JAVA="$WORKSPACE/deps/build/share/java" | |
153 | ||
154 | export PATH="$DEPS_BIN:$PATH" | |
155 | export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}" | |
b8bdba8f | 156 | export PKG_CONFIG_PATH="$DEPS_PKGCONFIG" |
09d45745 MJ |
157 | export CPPFLAGS="-I$DEPS_INC" |
158 | export LDFLAGS="-L$DEPS_LIB" | |
159 | ||
1ad4c3d0 MJ |
160 | exit_status=0 |
161 | ||
162 | # Use bear to generate compile_commands.json when enabled | |
163 | BEAR="" | |
164 | if [ "$LTTNG_TOOLS_GEN_COMPILE_COMMANDS" = "yes" ]; then | |
165 | BEAR="bear" | |
166 | fi | |
212d2afd | 167 | |
09d45745 MJ |
168 | # Create tmp directory |
169 | TMPDIR="$WORKSPACE/tmp" | |
170 | mkdir -p "$TMPDIR" | |
212d2afd | 171 | |
09d45745 MJ |
172 | # Use a symlink in /tmp to point to the the tmp directory |
173 | # inside the workspace, this is to work around the path length | |
174 | # limit of unix sockets which are created by the test suite. | |
175 | tmpdir="$(mktemp)" | |
176 | ln -sf "$TMPDIR" "$tmpdir" | |
177 | export TMPDIR="$tmpdir" | |
b4005bbf | 178 | |
481eadc8 JR |
179 | # Create a symlink to "babeltrace" when the "babeltrace2" executable is found. |
180 | # This is a temporary workaround until lttng-tools either allows the override of | |
181 | # the trace reader in its test suite or that we move to only supporting | |
182 | # babeltrace2 | |
183 | if [ -x "$DEPS_BIN/babeltrace2" ]; then | |
65444f1c | 184 | ln -s "$DEPS_BIN/babeltrace2" "$DEPS_BIN/babeltrace" |
481eadc8 JR |
185 | fi |
186 | ||
187 | # When using babeltrace2 make sure that it finds its plugins and | |
188 | # plugin-providers. | |
189 | export BABELTRACE_PLUGIN_PATH="$DEPS_LIB/babeltrace2/plugins/" | |
190 | export LIBBABELTRACE2_PLUGIN_PROVIDER_DIR="$DEPS_LIB/babeltrace2/plugin-providers/" | |
191 | ||
09d45745 | 192 | export CFLAGS="-g -O2" |
fdb66460 | 193 | export CXXFLAGS="-g -O2" |
b4005bbf | 194 | |
09d45745 MJ |
195 | # Set compiler variables |
196 | case "$cc" in | |
197 | gcc) | |
198 | export CC=gcc | |
199 | export CXX=g++ | |
200 | ;; | |
1ad4c3d0 MJ |
201 | gcc-*) |
202 | export CC=gcc-${cc#gcc-} | |
203 | export CXX=g++-${cc#gcc-} | |
09d45745 MJ |
204 | ;; |
205 | clang) | |
206 | export CC=clang | |
207 | export CXX=clang++ | |
208 | ;; | |
1ad4c3d0 MJ |
209 | clang-*) |
210 | export CC=clang-${cc#clang-} | |
211 | export CXX=clang++-${cc#clang-} | |
09d45745 MJ |
212 | ;; |
213 | *) | |
214 | if [ "x$cc" != "x" ]; then | |
1ad4c3d0 | 215 | export CC="$cc" |
09d45745 MJ |
216 | fi |
217 | ;; | |
218 | esac | |
b4005bbf | 219 | |
0cdaa21c | 220 | # Set platform variables |
5fcae288 | 221 | case "$platform" in |
f0d7e5b1 | 222 | macos*) |
09d45745 MJ |
223 | export MAKE=make |
224 | export TAR=tar | |
225 | export NPROC="getconf _NPROCESSORS_ONLN" | |
226 | export PATH="/opt/local/bin:/opt/local/sbin:$PATH" | |
227 | export CPPFLAGS="-I/opt/local/include $CPPFLAGS" | |
228 | export LDFLAGS="-L/opt/local/lib $LDFLAGS" | |
00f7bb3f MJ |
229 | export PYTHON="python3" |
230 | export PYTHON_CONFIG="python3-config" | |
b6e62a6a MJ |
231 | ;; |
232 | ||
61afb3c3 | 233 | cygwin|cygwin64|msys32|msys64) |
09d45745 MJ |
234 | export MAKE=make |
235 | export TAR=tar | |
236 | export NPROC=nproc | |
61afb3c3 MJ |
237 | ;; |
238 | ||
0cdaa21c | 239 | *) |
09d45745 MJ |
240 | export MAKE=make |
241 | export TAR=tar | |
242 | export NPROC=nproc | |
243 | ||
0cdaa21c MJ |
244 | PYTHON2=python2 |
245 | PYTHON3=python3 | |
246 | ||
b4c6a892 MJ |
247 | if command -v $PYTHON2 >/dev/null 2>&1; then |
248 | P2_VERSION=$($PYTHON2 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))') | |
4afa623f MJ |
249 | DEPS_PYTHON2="$WORKSPACE/deps/build/$LIBDIR/python$P2_VERSION/site-packages" |
250 | if [ "$LIBDIR" != "$LIBDIR_ARCH" ]; then | |
251 | DEPS_PYTHON2="$DEPS_PYTHON2:$WORKSPACE/deps/build/$LIBDIR_ARCH/python$P2_VERSION/site-packages" | |
252 | fi | |
b4c6a892 | 253 | fi |
0cdaa21c | 254 | |
b4c6a892 | 255 | P3_VERSION=$($PYTHON3 -c 'import sys;v = sys.version.split()[0].split("."); print("{}.{}".format(v[0], v[1]))') |
05615fb2 MJ |
256 | |
257 | # Temporary fix for an issue on debian python >= 3.10, add the 'local' prefix | |
258 | DEPS_PYTHON3="$WORKSPACE/deps/build/$LIBDIR/python$P3_VERSION/site-packages:$WORKSPACE/deps/build/local/$LIBDIR/python$P3_VERSION/dist-packages" | |
4afa623f MJ |
259 | if [ "$LIBDIR" != "$LIBDIR_ARCH" ]; then |
260 | DEPS_PYTHON3="$DEPS_PYTHON3:$WORKSPACE/deps/build/$LIBDIR_ARCH/python$P3_VERSION/site-packages" | |
261 | fi | |
de7e8d55 JG |
262 | |
263 | # Most build configs require access to the babeltrace 2 python bindings. | |
264 | # This also makes the lttngust python agent available for `agents` builds. | |
265 | export PYTHONPATH="${DEPS_PYTHON2:-}${DEPS_PYTHON2:+:}$DEPS_PYTHON3" | |
0cdaa21c MJ |
266 | ;; |
267 | esac | |
268 | ||
6843e673 MJ |
269 | # Some warning flags are very dumb in GCC 4.8 on SLES12 / EL7, disable them |
270 | # even if they are available. | |
29d9c2b2 | 271 | if [[ $platform = sles12sp5* ]] || [[ $platform = el7* ]]; then |
6843e673 MJ |
272 | CFLAGS="$CFLAGS -Wno-missing-field-initializers -Wno-shadow" |
273 | CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers -Wno-shadow" | |
fdb66460 MJ |
274 | fi |
275 | ||
7361d941 MJ |
276 | # If we have modules, build them |
277 | if [ -d "$WORKSPACE/src/lttng-modules" ]; then | |
1ad4c3d0 | 278 | print_header "Build and install LTTng-modules" |
7361d941 MJ |
279 | cd "$WORKSPACE/src/lttng-modules" |
280 | $MAKE -j"$($NPROC)" V=1 | |
281 | $MAKE modules_install V=1 | |
282 | depmod | |
283 | fi | |
284 | ||
51c9c62d | 285 | # Print build env details |
1ad4c3d0 | 286 | print_header "Build environment details" |
51c9c62d MJ |
287 | print_os || true |
288 | print_tooling || true | |
289 | ||
212d2afd MJ |
290 | # Enter the source directory |
291 | cd "$SRCDIR" | |
292 | ||
293 | # Run bootstrap in the source directory prior to configure | |
1ad4c3d0 | 294 | print_header "Bootstrap autotools" |
0cdaa21c MJ |
295 | ./bootstrap |
296 | ||
297 | # Get source version from configure script | |
212d2afd | 298 | eval "$(grep '^PACKAGE_VERSION=' ./configure)" |
09d45745 | 299 | PACKAGE_VERSION=${PACKAGE_VERSION//\-pre*/} |
0cdaa21c | 300 | |
1ad4c3d0 MJ |
301 | CONF_OPTS=("--prefix=$PREFIX" "--libdir=$PREFIX/$LIBDIR_ARCH" "--disable-maintainer-mode") |
302 | DIST_CONF_OPTS=("--disable-maintainer-mode") | |
edb933dd | 303 | |
09d45745 MJ |
304 | # Set configure options and environment variables for each build |
305 | # configuration. | |
b4005bbf | 306 | case "$conf" in |
0cdaa21c | 307 | static) |
1ad4c3d0 | 308 | print_header "Conf: Static lib only" |
09d45745 | 309 | |
1ad4c3d0 | 310 | CONF_OPTS+=("--enable-static" "--disable-shared" "--enable-python-bindings") |
0cdaa21c MJ |
311 | ;; |
312 | ||
0cdaa21c | 313 | no-ust) |
1ad4c3d0 | 314 | print_header "Conf: Without UST support" |
2c34ea14 | 315 | |
1ad4c3d0 MJ |
316 | CONF_OPTS+=("--without-lttng-ust") |
317 | DIST_CONF_OPTS+=("--without-lttng-ust") | |
0cdaa21c MJ |
318 | ;; |
319 | ||
67122b96 | 320 | agents) |
1ad4c3d0 | 321 | print_header "Conf: Java and Python agents" |
09d45745 | 322 | |
0cdaa21c | 323 | export JAVA_HOME="/usr/lib/jvm/default-java" |
61c5ba32 | 324 | export CLASSPATH="$DEPS_JAVA/lttng-ust-agent-all.jar:/usr/share/java/log4j-api.jar:/usr/share/java/log4j-core.jar:/usr/share/java/log4j-1.2.jar" |
0cdaa21c | 325 | |
1ad4c3d0 | 326 | CONF_OPTS+=("--enable-python-bindings" "--enable-test-java-agent-all") |
d51c467a MJ |
327 | |
328 | # Explicitly add '--enable-test-java-agent-log4j2', it's not part of '-all' in stable 2.12/2.13 | |
329 | if verlt "$PACKAGE_VERSION" "2.14"; then | |
330 | CONF_OPTS+=("--enable-test-java-agent-log4j2") | |
331 | fi | |
b7b61fcb MJ |
332 | |
333 | # Some distros don't ship python2 anymore | |
334 | if command -v $PYTHON2 >/dev/null 2>&1; then | |
335 | CONF_OPTS+=("--enable-test-python-agent-all") | |
336 | else | |
337 | CONF_OPTS+=("--enable-test-python3-agent") | |
338 | fi | |
0cdaa21c MJ |
339 | ;; |
340 | ||
341 | relayd-only) | |
1ad4c3d0 | 342 | print_header "Conf: Relayd only" |
09d45745 | 343 | |
1ad4c3d0 | 344 | CONF_OPTS+=("--disable-bin-lttng" "--disable-bin-lttng-consumerd" "--disable-bin-lttng-crash" "--disable-bin-lttng-sessiond" "--disable-extras" "--disable-man-pages" "--without-lttng-ust") |
0cdaa21c MJ |
345 | ;; |
346 | ||
22780fe6 | 347 | debug-rcu) |
1ad4c3d0 MJ |
348 | print_header "Conf: RCU sanity checks for debugging" |
349 | ||
350 | CONF_OPTS+=("--enable-python-bindings") | |
09d45745 MJ |
351 | |
352 | export CPPFLAGS="$CPPFLAGS -DDEBUG_RCU" | |
22780fe6 JR |
353 | ;; |
354 | ||
0cdaa21c | 355 | *) |
1ad4c3d0 MJ |
356 | print_header "Conf: Standard" |
357 | ||
358 | CONF_OPTS+=("--enable-python-bindings") | |
6871000c MJ |
359 | |
360 | # Something is broken in docbook-xml on yocto | |
361 | if [[ "$platform" = yocto* ]]; then | |
362 | CONF_OPTS+=("--disable-man-pages") | |
363 | fi | |
0cdaa21c | 364 | ;; |
b4005bbf MJ |
365 | esac |
366 | ||
367 | # Build type | |
67122b96 MJ |
368 | # oot : out-of-tree build |
369 | # dist : build via make dist | |
370 | # oot-dist: build via make dist out-of-tree | |
371 | # * : normal tree build | |
b4005bbf | 372 | # |
09d45745 MJ |
373 | # Make sure to move to the build directory and run configure |
374 | # before continuing. | |
b4005bbf | 375 | case "$build" in |
09d45745 | 376 | oot) |
1ad4c3d0 | 377 | print_header "Build: Out of tree" |
09d45745 MJ |
378 | |
379 | # Create and enter a temporary build directory | |
380 | builddir=$(mktemp -d) | |
381 | cd "$builddir" | |
382 | ||
51c9c62d | 383 | "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure |
09d45745 MJ |
384 | ;; |
385 | ||
386 | dist) | |
1ad4c3d0 | 387 | print_header "Build: Distribution in-tree" |
09d45745 MJ |
388 | |
389 | # Run configure and generate the tar file | |
390 | # in the source directory | |
1ad4c3d0 | 391 | |
51c9c62d | 392 | ./configure "${DIST_CONF_OPTS[@]}" || failed_configure |
09d45745 MJ |
393 | $MAKE dist |
394 | ||
395 | # Create and enter a temporary build directory | |
396 | builddir=$(mktemp -d) | |
397 | cd "$builddir" | |
398 | ||
399 | # Extract the distribution tar in the build directory, | |
400 | # ignore the first directory level | |
401 | $TAR xvf "$SRCDIR"/*.tar.* --strip 1 | |
402 | ||
403 | # Build in extracted source tree | |
51c9c62d | 404 | ./configure "${CONF_OPTS[@]}" || failed_configure |
09d45745 MJ |
405 | ;; |
406 | ||
407 | oot-dist) | |
1ad4c3d0 | 408 | print_header "Build: Distribution Out of tree" |
09d45745 MJ |
409 | |
410 | # Create and enter a temporary build directory | |
411 | builddir=$(mktemp -d) | |
412 | cd "$builddir" | |
413 | ||
414 | # Run configure out of tree and generate the tar file | |
51c9c62d | 415 | "$SRCDIR/configure" "${DIST_CONF_OPTS[@]}" || failed_configure |
09d45745 MJ |
416 | $MAKE dist |
417 | ||
418 | dist_srcdir="$(mktemp -d)" | |
419 | cd "$dist_srcdir" | |
420 | ||
421 | # Extract the distribution tar in the new source directory, | |
422 | # ignore the first directory level | |
423 | $TAR xvf "$builddir"/*.tar.* --strip 1 | |
424 | ||
425 | # Create and enter a second temporary build directory | |
426 | builddir="$(mktemp -d)" | |
427 | cd "$builddir" | |
428 | ||
429 | # Run configure from the extracted distribution tar, | |
430 | # out of the source tree | |
51c9c62d | 431 | "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure |
09d45745 MJ |
432 | ;; |
433 | ||
434 | *) | |
1ad4c3d0 | 435 | print_header "Build: Standard In-tree" |
51c9c62d | 436 | ./configure "${CONF_OPTS[@]}" || failed_configure |
09d45745 | 437 | ;; |
b4005bbf MJ |
438 | esac |
439 | ||
09d45745 MJ |
440 | # We are now inside a configured build directory |
441 | ||
0cdaa21c | 442 | # BUILD! |
1ad4c3d0 MJ |
443 | print_header "BUILD!" |
444 | $BEAR ${BEAR:+--} $MAKE -j "$($NPROC)" V=1 | |
445 | ||
446 | # Install in the workspace if enabled | |
447 | if [ "$LTTNG_TOOLS_MAKE_INSTALL" = "yes" ]; then | |
448 | print_header "Install" | |
449 | ||
450 | $MAKE install V=1 DESTDIR="$WORKSPACE" | |
451 | ||
452 | # Cleanup rpath in executables | |
453 | find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \; | |
454 | ||
455 | # Some configs don't build liblttng-ctl | |
456 | if [ -d "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" ]; then | |
457 | # Cleanup rpath in shared libraries | |
458 | find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.so" -exec chrpath --delete {} \; | |
459 | # Remove libtool .la files | |
460 | find "$WORKSPACE/$PREFIX/$LIBDIR_ARCH" -name "*.la" -delete | |
461 | fi | |
462 | fi | |
463 | ||
464 | # Run clang-tidy on the topmost commit | |
465 | if [ "$LTTNG_TOOLS_CLANG_TIDY" = "yes" ]; then | |
466 | print_header "Run clang-tidy" | |
b4005bbf | 467 | |
1ad4c3d0 MJ |
468 | # This would be better by linting only the lines touched by a patch but it |
469 | # doesn't seem to work, the lines are always filtered and no error is | |
470 | # reported. | |
471 | #git diff -U0 HEAD^ | clang-tidy-diff -p1 -j "$($NPROC)" -timeout 60 -fix | |
472 | ||
473 | # Instead, run clan-tidy on all the files touched by the patch. | |
474 | while read -r filepath; do | |
475 | if [[ "$filepath" =~ (\.cpp|\.hhp|\.c|\.h)$ ]]; then | |
476 | clang-tidy --fix-errors "$(realpath "$filepath")" | |
477 | fi | |
478 | done < <(git diff-tree --no-commit-id --diff-filter=d --name-only -r HEAD) | |
479 | ||
480 | # If the tree has local changes, the formatting was incorrect | |
481 | GIT_DIFF_OUTPUT=$(git diff) | |
482 | if [ -n "$GIT_DIFF_OUTPUT" ]; then | |
483 | echo "Saving clang-tidy proposed fixes in clang-tidy-fixes.diff" | |
484 | git diff > "$WORKSPACE/clang-tidy-fixes.diff" | |
485 | ||
486 | # Restore the unfixed files so they can be viewed in the warnings web | |
487 | # interface | |
488 | git checkout . | |
489 | exit_status=1 | |
490 | fi | |
491 | fi | |
7671741c | 492 | |
d6237b1b MJ |
493 | # Run tests for all configs except 'no-ust' / 'relayd-only' |
494 | if [ "$LTTNG_TOOLS_RUN_TESTS" = "yes" ] && [[ ! "$conf" =~ (no-ust|relayd-only) ]]; then | |
1ad4c3d0 MJ |
495 | print_header "Run test suite" |
496 | ||
0cdaa21c MJ |
497 | # Allow core dumps |
498 | ulimit -c unlimited | |
499 | ||
a4e98cc0 JR |
500 | # Force the lttng-sessiond path to /bin/true to prevent the spawing of a |
501 | # lttng-sessiond --daemonize on "lttng create" | |
502 | export LTTNG_SESSIOND_PATH="/bin/true" | |
503 | ||
1ad4c3d0 MJ |
504 | # It is implied that tests depending on LTTNG_ENABLE_DESTRUCTIVE_TESTS |
505 | # only run for the root user. Note that here `destructive` means that | |
506 | # operations are performed at the host level (add user etc.) that | |
507 | # effectively modify the host. Running those tests are acceptable on our | |
508 | # CI and root jobs since we always run root tests against a `snapshot` | |
509 | # of the host. | |
510 | if [ "$(id -u)" == "0" ]; then | |
511 | # Allow the traversal of all directories leading to the | |
512 | # DEPS_LIBS directory to enable test app run by temp users to | |
513 | # access lttng-ust. | |
514 | set_execute_traversal_bit "$DEPS_LIB" | |
515 | # Allow `all` to interact with all deps libs. | |
516 | chmod a+rwx -R "$DEPS_LIB" | |
517 | ||
518 | export LTTNG_ENABLE_DESTRUCTIVE_TESTS="will-break-my-system" | |
519 | ||
520 | # Some destructive tests play with the system clock, disable timesyncd | |
521 | systemctl stop systemd-timesyncd.service || true | |
522 | fi | |
65444f1c | 523 | |
1ad4c3d0 | 524 | make --keep-going check || exit_status=1 |
4174b905 | 525 | |
1ad4c3d0 MJ |
526 | # Copy tap logs for the jenkins tap parser before cleaning the build dir |
527 | rsync -a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests/ "$TAPDIR" | |
4174b905 | 528 | |
1ad4c3d0 MJ |
529 | # Copy the test suites top-level log which includes all tests failures |
530 | rsync -a --include 'test-suite.log' --include '*/' --exclude='*' tests/ "$WORKSPACE/log" | |
09d45745 | 531 | |
aff4e3d1 | 532 | if [ "$LTTNG_TOOLS_RUN_TESTS_LONG_REGRESSION" = "yes" ]; then |
1ad4c3d0 | 533 | print_header "Run long regression tests" |
09d45745 MJ |
534 | cd tests |
535 | mkdir -p "$TAPDIR/long_regression" | |
1ad4c3d0 | 536 | prove --merge -v --exec '' - < long_regression --archive "$TAPDIR/long_regression/" || exit_status=1 |
65444f1c | 537 | cd .. |
0cdaa21c | 538 | fi |
2c34ea14 MJ |
539 | fi |
540 | ||
d6237b1b | 541 | if [ "$LTTNG_TOOLS_RUN_TESTS" = "yes" ] && [[ "$conf" =~ (no-ust|relayd-only) ]]; then |
09d45745 MJ |
542 | # The TAP plugin will fail the job if no test logs are present |
543 | mkdir -p "$TAPDIR/no-tests" | |
544 | echo "1..1" > "$TAPDIR/no-tests/tests.log" | |
545 | echo "ok 1 - Test suite disabled" >> "$TAPDIR/no-tests/tests.log" | |
b4005bbf MJ |
546 | fi |
547 | ||
09d45745 | 548 | # Clean the build directory |
1ad4c3d0 MJ |
549 | if [ "$LTTNG_TOOLS_MAKE_CLEAN" = "yes" ]; then |
550 | print_header "Clean" | |
551 | $MAKE clean | |
0a059dd4 | 552 | fi |
b4005bbf | 553 | |
1ad4c3d0 MJ |
554 | print_header "LTTng-tools build script ended with: $(test $exit_status == 0 && echo SUCCESS || echo FAILURE)" |
555 | ||
09d45745 | 556 | # Exit with failure if any of the tests failed |
1ad4c3d0 | 557 | exit $exit_status |
95654431 MJ |
558 | |
559 | # EOF | |
1ad4c3d0 | 560 | # vim: expandtab tabstop=4 shiftwidth=4 |