X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=inline;f=scripts%2Fcommon%2Fscan-build.sh;h=5ef74c30787cc23d92d0bec0f0f8a21e3a44bc9f;hb=51c9c62db1805a4cdd96be18df4082f1ac5d81c5;hp=8ff83044215a8bab782561f2a9450a832ed27549;hpb=69f05d5914f8c90efd4af992a309255b22f3c30f;p=lttng-ci.git diff --git a/scripts/common/scan-build.sh b/scripts/common/scan-build.sh index 8ff8304..5ef74c3 100755 --- a/scripts/common/scan-build.sh +++ b/scripts/common/scan-build.sh @@ -1,7 +1,7 @@ -#!/bin/sh -exu +#!/bin/bash # -# Copyright (C) 2015 - Jonathan Rajotte-Julien -# 2016 - Michael Jeanson +# Copyright (C) 2015 Jonathan Rajotte-Julien +# Copyright (C) 2019 Michael Jeanson # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,51 +16,109 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +set -exu -# do not exit immediately if any command fails -set +e +# Required variables +WORKSPACE=${WORKSPACE:-} + +DEPS_INC="$WORKSPACE/deps/build/include" +DEPS_LIB="$WORKSPACE/deps/build/lib" +DEPS_PKGCONFIG="$DEPS_LIB/pkgconfig" +DEPS_BIN="$WORKSPACE/deps/build/bin" + +export PATH="$DEPS_BIN:$PATH" +export LD_LIBRARY_PATH="$DEPS_LIB:${LD_LIBRARY_PATH:-}" +export PKG_CONFIG_PATH="$DEPS_PKGCONFIG" +export CPPFLAGS="-I$DEPS_INC" +export LDFLAGS="-L$DEPS_LIB" SRCDIR="$WORKSPACE/src/$PROJECT_NAME" TMPDIR="$WORKSPACE/tmp" -PREFIX="$WORKSPACE/build" + +NPROC=$(nproc) +export CFLAGS="-O0 -g -DDEBUG" # Directory to archive the scan-build report SCAN_BUILD_ARCHIVE="${WORKSPACE}/scan-build-archive" -# Create build and tmp directories -rm -rf "$PREFIX" "$TMPDIR" -mkdir -p "$PREFIX" "$TMPDIR" +# Create tmp directory +rm -rf "$TMPDIR" +mkdir -p "$TMPDIR" export TMPDIR -# temp directory to store the scan-build report -SCAN_BUILD_TMPDIR=$( mktemp -d ) - -# liburcu -URCU_INCS="$WORKSPACE/deps/liburcu/build/include/" -URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/" - -# lttng-ust -UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/" -UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/" +# Builds configured with '-Werror=missing-include-dirs' if this directory +# doesn't exist +mkdir -p "$DEPS_INC" -export CFLAGS="-O0 -g -DDEBUG" - -export CPPFLAGS="-I$URCU_INCS -I$UST_INCS" -export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS" -export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:${LD_LIBRARY_PATH:-}" +# temp directory to store the scan-build report +SCAN_BUILD_TMPDIR=$(mktemp -d) + +case "$PROJECT_NAME" in +babeltrace) + export BABELTRACE_DEV_MODE=1 + export BABELTRACE_DEBUG_MODE=1 + export BABELTRACE_MINIMAL_LOG_LEVEL=TRACE + CONF_OPTS="--enable-python-bindings --enable-python-bindings-doc --enable-python-plugins" + BUILD_TYPE="autotools" + ;; +liburcu) + CONF_OPTS="" + BUILD_TYPE="autotools" + ;; +lttng-modules) + CONF_OPTS="" + BUILD_TYPE="autotools" + ;; +lttng-tools) + CONF_OPTS="" + BUILD_TYPE="autotools" + ;; +lttng-ust) + CONF_OPTS="--enable-java-agent-all --enable-python-agent" + BUILD_TYPE="autotools" + export CLASSPATH="/usr/share/java/log4j-1.2.jar" + ;; +linux-rseq) + CONF_OPTS="" + BUILD_TYPE="linux-rseq" + ;; +*) + echo "Generic project, no configure options." + CONF_OPTS="" + BUILD_TYPE="autotools" + ;; +esac + +if [ -d "$WORKSPACE/src/linux" ]; then + export KERNELDIR="$WORKSPACE/src/linux" +fi # Enter the source directory cd "$SRCDIR" -# Run bootstrap in the source directory prior to configure -./bootstrap - +# Build +case "$BUILD_TYPE" in +autotools) + # Prepare build dir for autotools based projects + if [ -f "./bootstrap" ]; then + ./bootstrap + ./configure $CONF_OPTS + fi -./configure --prefix="$PREFIX" + scan-build -k -o "${SCAN_BUILD_TMPDIR}" make -j"$NPROC" V=1 + ;; +linux-rseq) + make defconfig + make -j"$NPROC" prepare + scan-build -k -o "${SCAN_BUILD_TMPDIR}" make -j"$NPROC" kernel/rseq.o kernel/do_on_cpu/core.o kernel/do_on_cpu/interpreter.o kernel/do_on_cpu/validate.o V=1 + ;; +*) + echo "Unsupported build type: $BUILD_TYPE" + exit 1 + ;; +esac -# generate the scan-build report -scan-build -k -o "${SCAN_BUILD_TMPDIR}" make -j "$(nproc)" # get the directory name of the report created by scan-build SCAN_BUILD_REPORT=$(find "${SCAN_BUILD_TMPDIR}" -maxdepth 1 -not -empty -not -name "$(basename "${SCAN_BUILD_TMPDIR}")")