Commit | Line | Data |
---|---|---|
f12f1d66 | 1 | #!/bin/sh -exu |
890bff23 MJ |
2 | # |
3 | # Copyright (C) 2015 - Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com> | |
0e9967db | 4 | # 2016 - Michael Jeanson <mjeanson@efficios.com> |
890bff23 MJ |
5 | # |
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. | |
10 | # | |
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. | |
15 | # | |
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/>. | |
18 | ||
19 | ||
20 | # do not exit immediately if any command fails | |
21 | set +e | |
0e9967db MJ |
22 | |
23 | SRCDIR="$WORKSPACE/src/babeltrace" | |
24 | TMPDIR="$WORKSPACE/tmp" | |
25 | PREFIX="$WORKSPACE/build" | |
26 | # Directory to archive the scan-build report | |
890bff23 MJ |
27 | SCAN_BUILD_ARCHIVE="${WORKSPACE}/scan-build-archive" |
28 | ||
0e9967db MJ |
29 | # Create build and tmp directories |
30 | rm -rf "$PREFIX" "$TMPDIR" | |
31 | mkdir -p "$PREFIX" "$TMPDIR" | |
32 | ||
33 | export TMPDIR | |
34 | ||
35 | # temp directory to store the scan-build report | |
36 | SCAN_BUILD_TMPDIR=$( mktemp -d ) | |
890bff23 MJ |
37 | |
38 | export CFLAGS="-O0 -g -DDEBUG" | |
890bff23 | 39 | |
0e9967db MJ |
40 | # Enter the source directory |
41 | cd "$SRCDIR" | |
42 | ||
43 | # Run bootstrap in the source directory prior to configure | |
890bff23 | 44 | ./bootstrap |
0e9967db MJ |
45 | |
46 | ||
890bff23 | 47 | ./configure --prefix=$PREFIX |
0e9967db | 48 | |
890bff23 MJ |
49 | # generate the scan-build report |
50 | scan-build -k -o ${SCAN_BUILD_TMPDIR} make | |
0e9967db | 51 | |
890bff23 MJ |
52 | # get the directory name of the report created by scan-build |
53 | SCAN_BUILD_REPORT=$( find ${SCAN_BUILD_TMPDIR} -maxdepth 1 -not -empty -not -name `basename ${SCAN_BUILD_TMPDIR}` ) | |
54 | rc=$? | |
0e9967db | 55 | |
890bff23 MJ |
56 | if [ -z "${SCAN_BUILD_REPORT}" ]; then |
57 | echo ">>> No new bugs identified." | |
58 | echo ">>> No scan-build report has been generated" | |
59 | else | |
60 | echo ">>> New scan-build report generated in ${SCAN_BUILD_REPORT}" | |
0e9967db | 61 | |
890bff23 MJ |
62 | if [ ! -d "${SCAN_BUILD_ARCHIVE}" ]; then |
63 | echo ">>> Creating scan-build archive directory" | |
0e9967db | 64 | mkdir "${SCAN_BUILD_ARCHIVE}" |
890bff23 MJ |
65 | else |
66 | echo ">>> Removing any previous scan-build reports from ${SCAN_BUILD_ARCHIVE}" | |
0e9967db | 67 | rm -f "${SCAN_BUILD_ARCHIVE}/*" |
890bff23 | 68 | fi |
0e9967db | 69 | |
890bff23 MJ |
70 | echo ">>> Archiving scan-build report to ${SCAN_BUILD_ARCHIVE}" |
71 | mv ${SCAN_BUILD_REPORT}/* ${SCAN_BUILD_ARCHIVE}/ | |
0e9967db | 72 | |
890bff23 MJ |
73 | echo ">>> Removing any temporary files and directories" |
74 | rm -rf "${SCAN_BUILD_TMPDIR}" | |
75 | fi | |
0e9967db | 76 | |
890bff23 | 77 | exit ${rc} |