-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppcheck.sh
More file actions
executable file
·80 lines (71 loc) · 2.05 KB
/
cppcheck.sh
File metadata and controls
executable file
·80 lines (71 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#! /bin/sh
#
# Run Cppcheck on sources and build directory.
#
# This script is primarily meant to be executed in a CI environment, but it is
# also useful for direct use by developers:
# - To avoid XML output, set environment variable XML_OUTPUT to a value unequal
# to "yes".
# - Specify the location of the build directory in environment variable
# BUILD_PATH because its default value "build" is most certainly wrong.
# - The Cppcheck binary can be specified by pointing environment variable
# CPPCHECK to it (if it is left unspecified, the script tries to find a
# specific version of Cppcheck, otherwise it defaults to plain "cppcheck").
#
# From a build directory, run the script as follows:
# $ XML_OUTPUT=no BUILD_PATH=$(pwd) /PATH/TO/SOURCE/cppcheck.sh
#
set -eu
XML_OUTPUT="${XML_OUTPUT:-yes}"
BUILD_PATH="${BUILD_PATH:-build}"
if test ! -d "${BUILD_PATH}"
then
echo "Build path \"${BUILD_PATH}\" does not exist."
exit 1
fi
CPPCHECK="${CPPCHECK:-}"
if test "x${CPPCHECK}" = 'x'
then
STRBO_BASE_PATH="${STRBO_BASE_PATH:-${HOME}/StrBo}"
if test -x "${STRBO_BASE_PATH}/cppcheck-2.12.0/bin/cppcheck"
then
CPPCHECK="${STRBO_BASE_PATH}/cppcheck-2.12.0/bin/cppcheck"
else
CPPCHECK='cppcheck'
fi
fi
SOURCE_PATH="$(dirname "$0")"
if test "${XML_OUTPUT}" = 'yes'
then
XML_OPTIONS='--xml --xml-version=2'
XML_OUTFILE='cppcheck.xml'
else
XML_OPTIONS=
XML_OUTFILE='/dev/stdout'
fi
if test -f "${BUILD_PATH}/src/config.h"
then
CONFIG_H="${BUILD_PATH}/src/config.h"
else
CONFIG_H="${BUILD_PATH}/config.h"
fi
cd "${SOURCE_PATH}"
${CPPCHECK} \
--quiet ${XML_OPTIONS} \
--std=c++17 --platform=unix64 --library=std,gnu,gtk \
--enable=all --inconclusive \
--suppress=missingIncludeSystem \
-j "$(nproc)" \
-I. \
-Isrc \
-I"${BUILD_PATH}" \
-I"${BUILD_PATH}/src" \
-DHAVE_CONFIG_H \
-DNDEBUG \
--include="${CONFIG_H}" \
--include=cppcheck_17.hh \
--config-exclude=/usr \
--suppressions-list=cppcheck_suppressed.txt \
--inline-suppr \
"$@" \
$(find src -regex '.*\.cc?$') 2>"${XML_OUTFILE}"