Enhancements to the CppCheck script:

- make html output a flag (-h), instead of what happens when you
  specify no files
- add flag (-j) for job count, like make et al.
- add flag (-a) to ignore the suppressions file and report all issues
- require /bin/bash instead of just /bin/sh in order to get arithmetic $(())
- add mode-lines

svn path=/trunk/; revision=45520
This commit is contained in:
Evan Huus 2012-10-13 02:03:18 +00:00
parent 93f4ea8838
commit 4930f6d820
1 changed files with 37 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# cppcheck.sh
@ -31,18 +31,32 @@ CPPCHECK_DIR=`dirname $0`
THREADS=4
QUIET="--quiet"
SUPPRESSIONS="$CPPCHECK_DIR/suppressions"
INCLUDES="$CPPCHECK_DIR/includes"
SUPPRESSIONS="--suppressions-list=$CPPCHECK_DIR/suppressions"
INCLUDES="--includes-file=$CPPCHECK_DIR/includes"
MODE="gcc"
if [ $# -gt 0 ]; then
while getopts "ahj:" OPTCHAR ; do
case $OPTCHAR in
a) SUPPRESSIONS=" " ;;
h) MODE="html" ;;
j) THREADS="$OPTARG" ;;
esac
done
shift $(($OPTIND-1))
if [ "$MODE" = "gcc" ]; then
TEMPLATE="gcc"
TARGET=$*
else
elif [ "$MODE" = "html" ]; then
echo "<html><body><table border=1>"
echo "<tr><th>File</th><th>Line</th><th>Severity</th>"
echo "<th>Message</th><th>ID</th></tr>"
TEMPLATE="<tr><td>{file}</td><td>{line}</td><td>{severity}</td><td>{message}</td><td>{id}</td></tr>"
fi
if [ $# -eq 0 ]; then
TARGET="."
else
TARGET=$@
fi
# Use a little-documented feature of the shell to pass SIGINTs only to the
@ -50,12 +64,24 @@ fi
# runs and we aren't left with broken HTML.
trap : INT
$CPPCHECK --force --enable=style $QUIET \
--suppressions-list=$SUPPRESSIONS \
--includes-file=$INCLUDES \
--template=$TEMPLATE \
$CPPCHECK --force --enable=style $QUIET \
$SUPPRESSIONS $INCLUDES \
--template=$TEMPLATE \
-j $THREADS $TARGET 2>&1
if [ $# -eq 0 ]; then
if [ "$MODE" = "html" ]; then
echo "</table></body></html>"
fi
#
# Editor modelines - http://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 4
# tab-width: 8
# indent-tabs-mode: nil
# End:
#
# vi: set shiftwidth=4 tabstop=8 expandtab:
# :indentSize=4:tabSize=8:noTabs=true:
#