aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2012-10-13 02:03:18 +0000
committerEvan Huus <eapache@gmail.com>2012-10-13 02:03:18 +0000
commit4930f6d82069d4d3d83ccfabe07f86af96253320 (patch)
tree44e137be243d64489ebb9a25cece079a390af0e9
parent93f4ea8838ee93f830785d5a3ff8f9a638106bb8 (diff)
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
-rwxr-xr-xtools/cppcheck/cppcheck.sh48
1 files changed, 37 insertions, 11 deletions
diff --git a/tools/cppcheck/cppcheck.sh b/tools/cppcheck/cppcheck.sh
index d586fd4a1c..5f07e09624 100755
--- a/tools/cppcheck/cppcheck.sh
+++ b/tools/cppcheck/cppcheck.sh
@@ -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:
+#