Fix scan-build job for lttng-ust
[lttng-ci.git] / scripts / lttng-ust / scan-build.sh
CommitLineData
2b68721a
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# do not exit immediately if any command fails
20set +e
21
22# temp directory to store the scan-build report
23SCAN_BUILD_TMPDIR=$( mktemp -d /tmp/scan-build.XXXXXX )
24
25# directory to use for archiving the scan-build report
26SCAN_BUILD_ARCHIVE="${WORKSPACE}/scan-build-archive"
27
28# Create build directory
29rm -rf $WORKSPACE/build
30mkdir -p $WORKSPACE/build
31
c9b78c7b
MJ
32# liburcu
33URCU_INCS="$WORKSPACE/deps/liburcu/build/include/"
34URCU_LIBS="$WORKSPACE/deps/liburcu/build/lib/"
35
2b68721a 36export CFLAGS="-O0 -g -DDEBUG"
c9b78c7b
MJ
37export CPPFLAGS="-I$URCU_INCS"
38export LDFLAGS="-L$URCU_LIBS"
39export LD_LIBRARY_PATH="$URCU_LIBS:${LD_LIBRARY_PATH:-}"
40
2b68721a
MJ
41PREFIX="$WORKSPACE/build"
42
43./bootstrap
44./configure --prefix=$PREFIX
45make clean
46# generate the scan-build report
47scan-build -k -o ${SCAN_BUILD_TMPDIR} make
48
49# get the directory name of the report created by scan-build
50SCAN_BUILD_REPORT=$( find ${SCAN_BUILD_TMPDIR} -maxdepth 1 -not -empty -not -name `basename ${SCAN_BUILD_TMPDIR}` )
51rc=$?
52
53if [ -z "${SCAN_BUILD_REPORT}" ]; then
54 echo ">>> No new bugs identified."
55 echo ">>> No scan-build report has been generated"
56else
57 echo ">>> New scan-build report generated in ${SCAN_BUILD_REPORT}"
58
59 if [ ! -d "${SCAN_BUILD_ARCHIVE}" ]; then
60 echo ">>> Creating scan-build archive directory"
61 install -d -o jenkins -g jenkins -m 0755 "${SCAN_BUILD_ARCHIVE}"
62 else
63 echo ">>> Removing any previous scan-build reports from ${SCAN_BUILD_ARCHIVE}"
64 rm -f ${SCAN_BUILD_ARCHIVE}/*
65 fi
66
67 echo ">>> Archiving scan-build report to ${SCAN_BUILD_ARCHIVE}"
68 mv ${SCAN_BUILD_REPORT}/* ${SCAN_BUILD_ARCHIVE}/
69
70 echo ">>> Removing any temporary files and directories"
71 rm -rf "${SCAN_BUILD_TMPDIR}"
72fi
73
74exit ${rc}
This page took 0.030096 seconds and 4 git commands to generate.