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