X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/6e29655b5473c6f8235b72654f9aae9cfeb9b078..c4ebddd27ab964e55f4c7a1ae098f3f2c8ef47a6:/LUFA/Build/lufa.cppcheck.in diff --git a/LUFA/Build/lufa.cppcheck.in b/LUFA/Build/lufa.cppcheck.in index 330ec1d49..66f3aeef5 100644 --- a/LUFA/Build/lufa.cppcheck.in +++ b/LUFA/Build/lufa.cppcheck.in @@ -6,12 +6,13 @@ # www.lufa-lib.org # -LUFA_BUILD_MODULES += CPPCHECK -LUFA_BUILD_TARGETS += cppcheck cppcheck-config -LUFA_BUILD_MANDATORY_VARS += -LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_PATH CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_TEMPLATE \ - CPPCHECK_ENABLE CPPCHECK_SUPPRESS CPPCHECK_FAIL_ON_WARNING CPPCHECK_QUIET \ - CPPCHECK_FLAGS +LUFA_BUILD_MODULES += CPPCHECK +LUFA_BUILD_TARGETS += cppcheck cppcheck-config +LUFA_BUILD_MANDATORY_VARS += SRC +LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_TEMPLATE CPPCHECK_ENABLE \ + CPPCHECK_SUPPRESS CPPCHECK_FAIL_ON_WARNING CPPCHECK_QUIET CPPCHECK_FLAGS +LUFA_BUILD_PROVIDED_VARS += +LUFA_BUILD_PROVIDED_MACROS += # ----------------------------------------------------------------------------- # LUFA CPPCheck Buildsystem Makefile Module. @@ -27,11 +28,10 @@ LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_PATH CPPCHECK_INCLUDES CPPCHECK_EXCLUDES C # # MANDATORY PARAMETERS: # -# (None) +# SRC - List of source files to statically analyze # # OPTIONAL PARAMETERS: # -# CPPCHECK_PATH - Path of the files to statically analyze # CPPCHECK_INCLUDES - Extra include paths to search for missing # header files # CPPCHECK_EXCLUDES - Source file paths to exclude checking (can be @@ -44,10 +44,21 @@ LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_PATH CPPCHECK_INCLUDES CPPCHECK_EXCLUDES C # CPPCHECK_QUIET - Enable cppcheck verbose or quiet output mode # CPPCHECK_FLAGS - Additional flags to pass to cppcheck # +# PROVIDED VARIABLES: +# +# (None) +# +# PROVIDED MACROS: +# +# (None) +# # ----------------------------------------------------------------------------- +ERROR_IF_UNSET = $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set)) +ERROR_IF_EMPTY = $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank)) +ERROR_IF_NONBOOL = $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N)) + # Default values of optionally user-supplied variables -CPPCHECK_PATH ?= . CPPCHECK_INCLUDES ?= CPPCHECK_EXCLUDES ?= CPPCHECK_MSG_TEMPLATE ?= {file}:{line}: {severity} ({id}): {message} @@ -57,32 +68,35 @@ CPPCHECK_FAIL_ON_WARNING ?= Y CPPCHECK_QUIET ?= Y CPPCHECK_FLAGS ?= +# Sanity check user supplied values +$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR))) +$(call ERROR_IF_EMPTY, SRC) +$(call ERROR_IF_EMPTY, CPPCHECK_MSG_TEMPLATE) +$(call ERROR_IF_EMPTY, CPPCHECK_ENABLE) +$(call ERROR_IF_NONBOOL, CPPCHECK_FAIL_ON_WARNING) +$(call ERROR_IF_NONBOOL, CPPCHECK_QUIET) + # Build a default argument list for cppcheck BASE_CPPCHECK_FLAGS := --template="$(CPPCHECK_MSG_TEMPLATE)" $(CPPCHECK_INCLUDES:%=-I%) $(CPPCHECK_EXCLUDES:%=-i%) --inline-suppr --force --std=c99 # Sanity check parameters and construct additional command line arguments to cppcheck - ifeq ($(CPPCHECK_FAIL_ON_WARNING), Y) BASE_CPPCHECK_FLAGS += --error-exitcode=1 -else ifneq ($(CPPCHECK_FAIL_ON_WARNING), N) - $(error CPPCHECK_FAIL_ON_WARNING must be Y or N) endif ifeq ($(CPPCHECK_QUIET), Y) BASE_CPPCHECK_FLAGS += --quiet -else ifneq ($(CPPCHECK_QUIET), N) - $(error CPPCHECK_QUIET must be Y or N) endif # Output Messages MSG_CPPCHECK_CMD := ' [CPPCHECK]:' cppcheck-config: - @echo $(MSG_CPPCHECK_CMD) Checking cppcheck configuration for path \"$(CPPCHECK_PATH)\" - cppcheck $(BASE_CPPCHECK_FLAGS) --check-config $(CPPCHECK_FLAGS) $(CPPCHECK_PATH) + @echo $(MSG_CPPCHECK_CMD) Checking cppcheck configuration check on source files + cppcheck $(BASE_CPPCHECK_FLAGS) --check-config $(CPPCHECK_FLAGS) $(SRC) cppcheck: - @echo $(MSG_CPPCHECK_CMD) Performing cppcheck analysis on path \"$(CPPCHECK_PATH)\" - cppcheck $(BASE_CPPCHECK_FLAGS) --enable=$(CPPCHECK_ENABLE) $(CPPCHECK_SUPPRESS:%=--suppress=%) $(CPPCHECK_FLAGS) $(CPPCHECK_PATH) + @echo $(MSG_CPPCHECK_CMD) Performing static analysis on source files + cppcheck $(BASE_CPPCHECK_FLAGS) --enable=$(CPPCHECK_ENABLE) $(CPPCHECK_SUPPRESS:%=--suppress=%) $(CPPCHECK_FLAGS) $(SRC) # Phony build targets for this module .PHONY: cppcheck-config cppcheck