Build in verbose mode
[lttng-ci.git] / scripts / lttng-tools / scan-build.sh
CommitLineData
b4005bbf
MJ
1#!/bin/sh -exu
2#
3# Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19# temp directory to store the scan-build report
20SCAN_BUILD_TMPDIR=$( mktemp -d /tmp/scan-build.XXXXXX )
21
22# directory to use for archiving the scan-build report
23SCAN_BUILD_ARCHIVE="${WORKSPACE}/scan-build-archive"
24
25# Create build directory
26rm -rf $WORKSPACE/build
27mkdir -p $WORKSPACE/build
28
29# liburcu
30URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
31URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
32
33# lttng-ust
34UST_INCS="$WORKSPACE/deps/lttng-ust/build/include/"
35UST_LIBS="$WORKSPACE/deps/lttng-ust/build/lib/"
36
37export CFLAGS="-O0 -g -DDEBUG"
38export CPPFLAGS="-I$URCU_INCS -I$UST_INCS"
39export LDFLAGS="-L$URCU_LIBS -L$UST_LIBS"
40export LD_LIBRARY_PATH="$URCU_LIBS:$UST_LIBS:${LD_LIBRARY_PATH:-}"
41
42PREFIX="$WORKSPACE/build"
43
44./bootstrap
45./configure --prefix=$PREFIX
46make clean
47# generate the scan-build report
48scan-build -k -o ${SCAN_BUILD_TMPDIR} make
49
50# get the directory name of the report created by scan-build
51set +e
52SCAN_BUILD_REPORT=$( find ${SCAN_BUILD_TMPDIR} -maxdepth 1 -not -empty -not -name `basename ${SCAN_BUILD_TMPDIR}` )
53rc=$?
54set -e
55
56if [ -z "${SCAN_BUILD_REPORT}" ]; then
57 echo ">>> No new bugs identified."
58 echo ">>> No scan-build report has been generated"
59else
60 echo ">>> New scan-build report generated in ${SCAN_BUILD_REPORT}"
61
62 if [ ! -d "${SCAN_BUILD_ARCHIVE}" ]; then
63 echo ">>> Creating scan-build archive directory"
64 install -d -o jenkins -g jenkins -m 0755 "${SCAN_BUILD_ARCHIVE}"
65 else
66 echo ">>> Removing any previous scan-build reports from ${SCAN_BUILD_ARCHIVE}"
67 rm -f ${SCAN_BUILD_ARCHIVE}/*
68 fi
69
70 echo ">>> Archiving scan-build report to ${SCAN_BUILD_ARCHIVE}"
71 mv ${SCAN_BUILD_REPORT}/* ${SCAN_BUILD_ARCHIVE}/
72
73 echo ">>> Removing any temporary files and directories"
74 rm -rf "${SCAN_BUILD_TMPDIR}"
75fi
76
77exit ${rc}
This page took 0.028558 seconds and 4 git commands to generate.