3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # 2016-2019 Michael Jeanson <mjeanson@efficios.com>
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.
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.
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/>.
21 # Version compare functions
24 if [[ "$1" == "$2" ]]; then
28 local i ver1
=($1) ver2
=($2)
29 # fill empty fields in ver1 with zeros
30 for ((i
=${#ver1[@]}; i
<${#ver2[@]}; i
++)); do
33 for ((i
=0; i
<${#ver1[@]}; i
++)); do
34 if [[ -z ${ver2[i]} ]]; then
35 # fill empty fields in ver2 with zeros
38 if ((10#${ver1[i]} > 10#${ver2[i]})); then
41 if ((10#${ver1[i]} < 10#${ver2[i]})); then
50 vercomp
"$1" "$2"; local res
="$?"
51 [ "$res" -eq "0" ] ||
[ "$res" -eq "2" ]
55 vercomp
"$1" "$2"; local res
="$?"
60 vercomp
"$1" "$2"; local res
="$?"
61 [ "$res" -eq "0" ] ||
[ "$res" -eq "1" ]
65 vercomp
"$1" "$2"; local res
="$?"
70 vercomp
"$1" "$2"; local res
="$?"
75 # Assume we are in the configured build directory
76 echo "#################### BEGIN config.log ####################"
78 echo "#################### END config.log ####################"
80 # End the build with failure
85 WORKSPACE
=${WORKSPACE:-}
92 # Controls if the tests are run
93 LTTNG_UST_RUN_TESTS
="${LTTNG_UST_RUN_TESTS:=yes}"
95 DEPS_INC
="$WORKSPACE/deps/build/include"
96 DEPS_LIB
="$WORKSPACE/deps/build/lib"
97 DEPS_PKGCONFIG
="$DEPS_LIB/pkgconfig"
98 #DEPS_BIN="$WORKSPACE/deps/build/bin"
99 #DEPS_JAVA="$WORKSPACE/deps/build/share/java"
101 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
102 export PKG_CONFIG_PATH
="$DEPS_PKGCONFIG"
103 export CPPFLAGS
="-I$DEPS_INC"
104 export LDFLAGS
="-L$DEPS_LIB"
106 SRCDIR
="$WORKSPACE/src/lttng-ust"
107 TMPDIR
="$WORKSPACE/tmp"
110 # Create tmp directory
115 export CFLAGS
="-g -O2"
117 # Set compiler variables
149 export CXX
=clang
++-3.9
153 export CXX
=clang
++-4.0
157 export CXX
=clang
++-5.0
161 export CXX
=clang
++-6.0
168 if [ "x$cc" != "x" ]; then
174 if [ "x${CC:-}" != "x" ]; then
175 echo "Selected compiler:"
179 # Set platform variables
184 export NPROC
="getconf _NPROCESSORS_ONLN"
185 export CPPFLAGS
="-I/usr/local/include $CPPFLAGS"
186 export LDFLAGS
="-L/usr/local/lib $LDFLAGS"
187 export PYTHON
="python3"
188 export PYTHON_CONFIG
="python3-config"
189 export CLASSPATH
='/usr/local/share/java/classes/*'
190 export JAVA_HOME
='/usr/local/openjdk11'
197 export PYTHON
="python3"
198 export PYTHON_CONFIG
="python3-config"
199 export CLASSPATH
='/usr/share/java/*'
203 # Print build env details
205 print_tooling || true
207 # Enter the source directory
210 # Run bootstrap in the source directory prior to configure
213 # Get source version from configure script
214 eval "$(grep '^PACKAGE_VERSION=' ./configure)"
215 PACKAGE_VERSION
=${PACKAGE_VERSION//\-pre*/}
217 # Set configure options and environment variables for each build
219 CONF_OPTS
=("--prefix=$PREFIX")
222 echo "Static lib only configuration"
224 CONF_OPTS
+=("--enable-static" "--disable-shared")
226 # Unsupported! liblttng-ust can't pull in it's static (.a) dependencies.
231 echo "Java and Python agents configuration"
233 CONF_OPTS
+=("--enable-java-agent-all" "--enable-jni-interface" "--enable-python-agent")
237 echo "Enable RCU sanity checks for debugging"
238 export CPPFLAGS
="${CPPFLAGS} -DDEBUG_RCU"
242 echo "Standard configuration"
247 # oot : out-of-tree build
248 # dist : build via make dist
249 # oot-dist: build via make dist out-of-tree
250 # * : normal tree build
252 # Make sure to move to the build directory and run configure
256 echo "Out of tree build"
258 # Create and enter a temporary build directory
259 builddir
=$
(mktemp
-d)
262 "$SRCDIR/configure" "${CONF_OPTS[@]}" || failed_configure
266 echo "Distribution in-tree build"
268 # Run configure and generate the tar file
269 # in the source directory
270 .
/configure || failed_configure
273 # Create and enter a temporary build directory
274 builddir
=$
(mktemp
-d)
277 # Extract the distribution tar in the build directory,
278 # ignore the first directory level
279 $TAR xvf
"$SRCDIR"/*.
tar.
* --strip 1
281 # Build in extracted source tree
282 .
/configure
"${CONF_OPTS[@]}" || failed_configure
286 echo "Distribution out of tree build"
288 # Create and enter a temporary build directory
289 builddir
=$
(mktemp
-d)
292 # Run configure out of tree and generate the tar file
293 "$SRCDIR/configure" || failed_configure
296 dist_srcdir
="$(mktemp -d)"
299 # Extract the distribution tar in the new source directory,
300 # ignore the first directory level
301 $TAR xvf
"$builddir"/*.
tar.
* --strip 1
303 # Create and enter a second temporary build directory
304 builddir
="$(mktemp -d)"
307 # Run configure from the extracted distribution tar,
308 # out of the source tree
309 "$dist_srcdir/configure" "${CONF_OPTS[@]}" || failed_configure
313 echo "Standard in-tree build"
314 .
/configure
"${CONF_OPTS[@]}" || failed_configure
318 # We are now inside a configured build directory
321 $MAKE -j "$($NPROC)" V
=1
323 # Install in the workspace
324 $MAKE install DESTDIR
="$WORKSPACE"
326 # Run tests, don't fail now, we want to run the archiving steps
328 if [ "$LTTNG_UST_RUN_TESTS" = "yes" ]; then
329 $MAKE --keep-going check || failed_tests
=1
331 # Copy tap logs for the jenkins tap parser before cleaning the build dir
332 rsync
-a --exclude 'test-suite.log' --include '*/' --include '*.log' --exclude='*' tests
/ "$WORKSPACE/tap"
334 # The test suite prior to 2.8 did not produce TAP logs
335 if verlt
"$PACKAGE_VERSION" "2.8"; then
336 mkdir
-p "$WORKSPACE/tap/no-log"
337 echo "1..1" > "$WORKSPACE/tap/no-log/tests.log"
338 echo "ok 1 - Test suite doesn't support logging" >> "$WORKSPACE/tap/no-log/tests.log"
342 # Clean the build directory
345 # Cleanup rpath in executables and shared libraries
346 #find "$WORKSPACE/$PREFIX/bin" -type f -perm -0500 -exec chrpath --delete {} \;
347 find "$WORKSPACE/$PREFIX/lib" -name "*.so" -exec chrpath
--delete {} \
;
349 # Remove libtool .la files
350 find "$WORKSPACE/$PREFIX/lib" -name "*.la" -exec rm -f {} \
;
352 # Exit with failure if any of the tests failed