[RFC/PATCHv2] Makefile: add cppcheck target
- From
Chris Packham <judge.packham@gmail.com>
- Date
- Dec 14, 2016, 09:27 UTC
- Message-ID
- <20161214092731.29076-1-judge.packham@gmail.com>
- In-Reply-To
- <20161213092225.15299-1-judge.packham@gmail.com>
Add cppcheck target to Makefile. Cppcheck is a static analysis tool for C/C++ code. Cppcheck primarily detects the types of bugs that the compilers normally do not detect. It is an useful target for doing QA analysis.
To run the default set of checks run
make cppcheck
Additional checks can be enabled by specifying CPPCHECK_ADD. This is a comma separated list which is passed to cppcheck's --enable option. To enable style and warning checks run
make cppcheck CPPCHECK_ADD=style,warning
Based-on-patch-by: Elia Pinto <gitter.spiros@gmail.com> Signed-off-by: Chris Packham <judge.packham@gmail.com> --- Changes in v2: - only run over actual git source files. - omit any files in t/ - print cppcheck version to allow for better comparison between different build environments - introduce CPPCHECK_FLAGS which can be overridden in the make command line. This also uses a GNU make-ism to allow CPPCHECK_ADD to specify additional checks to be enabled.
Makefile | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/Makefile b/Makefile index f53fcc90d..e5c86decf 100644 --- a/Makefile +++ b/Makefile @@ -2635,3 +2635,12 @@ cover_db: coverage-report cover_db_html: cover_db cover -report html -outputdir cover_db_html cover_db +.PHONY: cppcheck + +CPPCHECK_FLAGS = --force --quiet --inline-suppr $(if $(CPPCHECK_ADD),--enable=$(CPPCHECK_ADD)) + +cppcheck: + @cppcheck --version + $(FIND_SOURCE_FILES) | \ + grep -v '^t/t' | \ + xargs cppcheck $(CPPCHECK_FLAGS)
-- 2.11.0.24.ge6920cf