diff options
author | Evan Huus <eapache@gmail.com> | 2012-07-21 02:43:10 +0000 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2012-07-21 02:43:10 +0000 |
commit | e70e0e6bfc345ceba3e48d1eef13b053ffd002dc (patch) | |
tree | ed40d11f3748bda5598088eba9db3ee23282fc28 /tools | |
parent | bddb918dc4b94f2f3023fdf8924fcea3e2160565 (diff) |
Enhancements to the cppcheck script:
- Take command-line arguments of files to check. In this case make output
GCC-like, as it's much more human-readable than the HTML.
- If there are no arguments, provide HTML output for the entire current
directory like before, for use with build-bot integration.
- Don't hack with the CWD to try and get include-paths to work. Cppcheck
will warn already if it can't find them, and since a lot of the checks
still work in any case, a warning is more appropriate than an error or
a hack.
svn path=/trunk/; revision=43882
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/cppcheck/cppcheck.sh | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/tools/cppcheck/cppcheck.sh b/tools/cppcheck/cppcheck.sh index c38726e58e..d586fd4a1c 100755 --- a/tools/cppcheck/cppcheck.sh +++ b/tools/cppcheck/cppcheck.sh @@ -26,34 +26,36 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -CUR_DIRECTORY="`dirname $0`" -ORIGINAL_DIR="`pwd`" -CPPCHECK_DIR="./tools/cppcheck" - CPPCHECK=`which cppcheck` +CPPCHECK_DIR=`dirname $0` THREADS=4 +QUIET="--quiet" SUPPRESSIONS="$CPPCHECK_DIR/suppressions" INCLUDES="$CPPCHECK_DIR/includes" -TEMPLATE="<tr><td>{file}</td><td>{line}</td><td>{severity}</td><td>{message}</td><td>{id}</td></tr>" + +if [ $# -gt 0 ]; then + TEMPLATE="gcc" + TARGET=$* +else + 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>" + TARGET="." +fi # Use a little-documented feature of the shell to pass SIGINTs only to the # child process (cppcheck in this case). That way the final 'echo' still # runs and we aren't left with broken HTML. trap : INT -cd $CUR_DIRECTORY/../.. - -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>" - -$CPPCHECK --quiet --force --enable=style \ +$CPPCHECK --force --enable=style $QUIET \ --suppressions-list=$SUPPRESSIONS \ --includes-file=$INCLUDES \ --template=$TEMPLATE \ - -j $THREADS . 2>&1 - -echo "</table></body></html>" + -j $THREADS $TARGET 2>&1 -cd $ORIGINAL_DIR +if [ $# -eq 0 ]; then + echo "</table></body></html>" +fi |