3 # Copyright (C) 2015 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4 # Copyright (C) 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/>.
22 WORKSPACE
=${WORKSPACE:-}
24 DEPS_INC
="$WORKSPACE/deps/build/include"
25 DEPS_LIB
="$WORKSPACE/deps/build/lib"
26 DEPS_PKGCONFIG
="$DEPS_LIB/pkgconfig"
27 DEPS_BIN
="$WORKSPACE/deps/build/bin"
29 export PATH
="$DEPS_BIN:$PATH"
30 export LD_LIBRARY_PATH
="$DEPS_LIB:${LD_LIBRARY_PATH:-}"
31 export PKG_CONFIG_PATH
="$DEPS_PKGCONFIG"
32 export CPPFLAGS
="-I$DEPS_INC"
33 export LDFLAGS
="-L$DEPS_LIB"
35 SRCDIR
="$WORKSPACE/src/$PROJECT_NAME"
36 TMPDIR
="$WORKSPACE/tmp"
39 export CFLAGS
="-O0 -g -DDEBUG"
41 # Directory to archive the scan-build report
42 SCAN_BUILD_ARCHIVE
="${WORKSPACE}/scan-build-archive"
44 # Create tmp directory
50 # Builds configured with '-Werror=missing-include-dirs' if this directory
54 # temp directory to store the scan-build report
55 SCAN_BUILD_TMPDIR
=$
(mktemp
-d)
57 case "$PROJECT_NAME" in
59 export BABELTRACE_DEV_MODE
=1
60 export BABELTRACE_DEBUG_MODE
=1
61 export BABELTRACE_MINIMAL_LOG_LEVEL
=TRACE
62 CONF_OPTS
="--enable-python-bindings --enable-python-bindings-doc --enable-python-plugins"
63 BUILD_TYPE
="autotools"
67 BUILD_TYPE
="autotools"
71 BUILD_TYPE
="autotools"
75 BUILD_TYPE
="autotools"
78 CONF_OPTS
="--enable-java-agent-all --enable-python-agent"
79 BUILD_TYPE
="autotools"
80 export CLASSPATH
="/usr/share/java/log4j-1.2.jar"
84 BUILD_TYPE
="linux-rseq"
87 echo "Generic project, no configure options."
89 BUILD_TYPE
="autotools"
93 if [ -d "$WORKSPACE/src/linux" ]; then
94 export KERNELDIR
="$WORKSPACE/src/linux"
97 # Enter the source directory
101 case "$BUILD_TYPE" in
103 # Prepare build dir for autotools based projects
104 if [ -f "./bootstrap" ]; then
106 .
/configure
$CONF_OPTS
109 scan-build
-k -o "${SCAN_BUILD_TMPDIR}" make -j"$NPROC" V
=1
113 make -j"$NPROC" prepare
114 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
117 echo "Unsupported build type: $BUILD_TYPE"
123 # get the directory name of the report created by scan-build
124 SCAN_BUILD_REPORT
=$
(find "${SCAN_BUILD_TMPDIR}" -maxdepth 1 -not -empty -not -name "$(basename "${SCAN_BUILD_TMPDIR}")")
127 if [ -z "${SCAN_BUILD_REPORT}" ]; then
128 echo ">>> No new bugs identified."
129 echo ">>> No scan-build report has been generated"
131 echo ">>> New scan-build report generated in ${SCAN_BUILD_REPORT}"
133 if [ ! -d "${SCAN_BUILD_ARCHIVE}" ]; then
134 echo ">>> Creating scan-build archive directory"
135 mkdir
"${SCAN_BUILD_ARCHIVE}"
137 echo ">>> Removing any previous scan-build reports from ${SCAN_BUILD_ARCHIVE}"
138 rm -f "${SCAN_BUILD_ARCHIVE}/*"
141 echo ">>> Archiving scan-build report to ${SCAN_BUILD_ARCHIVE}"
142 mv "${SCAN_BUILD_REPORT}"/* "${SCAN_BUILD_ARCHIVE}/"
144 echo ">>> Removing any temporary files and directories"
145 rm -rf "${SCAN_BUILD_TMPDIR}"