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