Module: check_mk
Branch: master
Commit: 8b418a0ca0724df67fed48cf5fb5b30d2a417a7d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b418a0ca0724d…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Jan 2 13:49:59 2018 +0100
Use the local compilation database for cppcheck, too.
Change-Id: I141eae2a8fce6d809bf7cfd19d2f400453cc6837
---
.gitignore | 1 -
Makefile | 34 +++++++-------------------------
livestatus/.gitignore | 1 -
livestatus/src/.gitignore | 10 ++++++----
livestatus/src/Makefile.am | 12 +++++++++--
livestatus/src/cppcheck-suppressions.txt | 9 +++++++++
scripts/compiled_sources | 7 -------
7 files changed, 32 insertions(+), 42 deletions(-)
diff --git a/.gitignore b/.gitignore
index 6f604ed..5cd8ee9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,7 +29,6 @@ clang-analyzer/
cmc-*.tar.gz
cme-*.tar.gz
compile
-compile_commands.json
config.guess
config.h
config.h.in
diff --git a/Makefile b/Makefile
index 27b6b63..e7eae1d 100644
--- a/Makefile
+++ b/Makefile
@@ -374,7 +374,7 @@ install-minified-js: $(JAVASCRIPT_MINI)
# GNU standards here (see "Standard Targets for Users",
#
https://www.gnu.org/prep/standards/html_node/Standard-Targets.html).
clean:
- rm -rf api clang-analyzer compile_commands.json dist.tmp rpm.topdir *.rpm *.deb *.exe \
+ rm -rf api clang-analyzer dist.tmp rpm.topdir *.rpm *.deb *.exe \
mk-livestatus-*.tar.gz \
$(NAME)-*.tar.gz *~ counters autochecks \
precompiled cache web/htdocs/js/*_min.js \
@@ -461,14 +461,6 @@ GTAGS: config.h
# to configure.ac).
$(MAKE) -C livestatus GTAGS
-compile_commands.json: config.h $(FILES_TO_FORMAT)
- $(MAKE) -C livestatus clean
- $(BEAR) $(MAKE) -C livestatus -j4
-ifeq ($(ENTERPRISE),yes)
- $(MAKE) -C enterprise/core clean
- $(BEAR) --append $(MAKE) -C enterprise/core -j4
-endif
-
compile-neb-cmc: config.status
$(MAKE) -C livestatus -j4
ifeq ($(ENTERPRISE),yes)
@@ -496,29 +488,17 @@ analyze: config.h
# fragile.
# GCC-like output on stderr intended for human consumption.
-cppcheck: compile_commands.json
- @scripts/compiled_sources | \
- grep /livestatus/src/ |\
- sed 's/^"\(.*\)"$$/\1/' | \
- ( cd livestatus && $(CPPCHECK) -DHAVE_CONFIG_H -UCMC --enable=all
--suppress=missingIncludeSystem --suppress=unusedFunction --suppress=passedByValue
--inline-suppr -I src -I .. -I . --file-list=- --quiet --template=gcc )
+cppcheck: config.h
+ $(MAKE) -C livestatus/src cppcheck
ifeq ($(ENTERPRISE),yes)
- @scripts/compiled_sources | \
- grep /enterprise/core/ |\
- sed 's/^"\(.*\)"$$/\1/' | \
- ( cd enterprise/core/src && $(CPPCHECK) -DHAVE_CONFIG_H -DCMC --enable=all
--suppress=missingIncludeSystem --suppress=unusedFunction --suppress=passedByValue
--inline-suppr -I . -I ../../.. -I livestatus -I checkhelper --file-list=- --quiet
--template=gcc )
+ $(MAKE) -C enterprise/core/src cppcheck
endif
# XML output into file intended for machine processing.
-cppcheck-xml: compile_commands.json
- scripts/compiled_sources | \
- grep /livestatus/src/ |\
- sed 's/^"\(.*\)"$$/\1/' | \
- ( cd livestatus && $(CPPCHECK) -DHAVE_CONFIG_H -UCMC --enable=all
--suppress=missingIncludeSystem --suppress=unusedFunction --suppress=passedByValue
--inline-suppr -I src -I .. -I . --file-list=- --quiet --template=gcc --xml
--xml-version=2 2> cppcheck-result.xml )
+cppcheck-xml: config.h
+ $(MAKE) -C livestatus/src cppcheck-xml
ifeq ($(ENTERPRISE),yes)
- scripts/compiled_sources | \
- grep /enterprise/core/ |\
- sed 's/^"\(.*\)"$$/\1/' | \
- ( cd enterprise/core/src && $(CPPCHECK) -DHAVE_CONFIG_H -DCMC --enable=all
--suppress=missingIncludeSystem --suppress=unusedFunction --suppress=passedByValue
--inline-suppr -I . -I ../../.. -I livestatus -I checkhelper --file-list=- --quiet
--template=gcc --xml --xml-version=2 2> cppcheck-result.xml )
+ $(MAKE) -C enterprise/core/src cppcheck-xml
endif
# TODO: We should probably handle this rule via AM_EXTRA_RECURSIVE_TARGETS in
diff --git a/livestatus/.gitignore b/livestatus/.gitignore
index 349f3b8..0acdced 100644
--- a/livestatus/.gitignore
+++ b/livestatus/.gitignore
@@ -1,4 +1,3 @@
-cppcheck-result.xml
.cproject
cscope.files
Debug
diff --git a/livestatus/src/.gitignore b/livestatus/src/.gitignore
index 431d451..d39fed4 100644
--- a/livestatus/src/.gitignore
+++ b/livestatus/src/.gitignore
@@ -1,10 +1,12 @@
*.a
+*.la
+*.o
+*.so
.cproject
.deps
-*.la
-livecheck
Makefile
Makefile.in
-*.o
-*.so
+compile_commands.json
+cppcheck-result.xml
+livecheck
unixcat
diff --git a/livestatus/src/Makefile.am b/livestatus/src/Makefile.am
index 84ead24..9fef8b1 100644
--- a/livestatus/src/Makefile.am
+++ b/livestatus/src/Makefile.am
@@ -23,9 +23,11 @@
# Boston, MA 02110-1301 USA.
CLANG_VERSION ?= 5.0
-RUN_CLANG_TIDY ?= run-clang-tidy-$(CLANG_VERSION).py
-IWYU_TOOL ?= iwyu_tool
+
BEAR ?= bear
+CPPCHECK ?= cppcheck
+IWYU_TOOL ?= iwyu_tool
+RUN_CLANG_TIDY ?= run-clang-tidy-$(CLANG_VERSION).py
bin_PROGRAMS = unixcat
@@ -177,6 +179,12 @@ tidy: compile_commands.json
iwyu: compile_commands.json
$(IWYU_TOOL) --output-format=clang -p . --
--mapping_file=$(abs_top_srcdir)/tests/iwyu-mappings/check_mk.imp
+cppcheck: compile_commands.json
+ $(CPPCHECK) -UCMC --enable=all --suppressions-list=cppcheck-suppressions.txt
--inline-suppr --project=compile_commands.json --quiet --template=gcc
+
+cppcheck-xml: compile_commands.json
+ $(CPPCHECK) -UCMC --enable=all --suppressions-list=cppcheck-suppressions.txt
--inline-suppr --project=compile_commands.json --quiet --template=gcc --xml
--xml-version=2 2> cppcheck-result.xml
+
all-local: livestatus.o
install-data-local:
diff --git a/livestatus/src/cppcheck-suppressions.txt
b/livestatus/src/cppcheck-suppressions.txt
new file mode 100644
index 0000000..987a260
--- /dev/null
+++ b/livestatus/src/cppcheck-suppressions.txt
@@ -0,0 +1,9 @@
+missingIncludeSystem
+passedByValue
+unusedFunction
+// cppcheck doesn't undestand uniform initialization yet.
+constStatement
+// This is nonsense, but otherwise cppcheck complains even if it shouldn't.
+unmatchedSuppression
+// cppcheck is simply too dumb about macros...
+*:/usr/include/boost/config.hpp
diff --git a/scripts/compiled_sources b/scripts/compiled_sources
deleted file mode 100755
index 89c6d23..0000000
--- a/scripts/compiled_sources
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import json
-
-with open('compile_commands.json') as cc:
- for command_object in json.load(cc):
- print('"%s"' % command_object['file'])