mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-13 08:33:49 +01:00
build system: enable support for static analysis
Modules can now add the following snipped to their `Makefile`:
MODULE_SUPPORTS_STATIC_ANALYSIS := 1
When the application is then build with `make STATIC_ANALYSIS=1`, all
modules that opted in to static analysis get build with static analysis.
This commit is contained in:
parent
16c24a43e9
commit
0069a6bf9a
@ -78,6 +78,14 @@ ifneq (,$(SRCXX))
|
||||
endif
|
||||
endif
|
||||
|
||||
# If static analysis is enabled *and* the module claims to compile fine with it,
|
||||
# add the corresponding flags
|
||||
ifeq (1,$(STATIC_ANALYSIS))
|
||||
ifeq (1,$(MODULE_SUPPORTS_STATIC_ANALYSIS))
|
||||
CFLAGS := $(CFLAGS_STATIC_ANALYSIS) $(CFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
compile-commands: | $(DIRS:%=COMPILE-COMMANDS--%)
|
||||
$(file >$(BINDIR)/$(MODULE)/compile_cmds.txt,SRC: $(sort $(SRC) $(SRC_NO_LTO)))
|
||||
$(file >>$(BINDIR)/$(MODULE)/compile_cmds.txt,SRC_NO_LTO: $(sort $(SRC_NO_LTO)))
|
||||
|
||||
@ -4,4 +4,7 @@ SRC := $(filter-out mbox.c msg.c msg_bus.c thread.c thread_flags.c,$(wildcard *.
|
||||
# enable submodules
|
||||
SUBMODULES := 1
|
||||
|
||||
# this module is expected to pass static analysis
|
||||
MODULE_SUPPORTS_STATIC_ANALYSIS := 1
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
||||
@ -36,6 +36,9 @@ OPTIONAL_CFLAGS_BLACKLIST += -Wdocumentation -Wno-error=documentation -Wno-docum
|
||||
# We use GDB for debugging
|
||||
include $(RIOTMAKE)/tools/gdb.inc.mk
|
||||
|
||||
# GCC's static analysis tools can be enabled using -fanalyzer
|
||||
CFLAGS_STATIC_ANALYSIS := -fanalyzer
|
||||
|
||||
# Data address spaces starts at zero for all supported architectures. This fixes
|
||||
# compilation at least on MSP430 and AVR.
|
||||
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
|
||||
|
||||
@ -70,6 +70,7 @@ export CXX # The CXX compiler to use.
|
||||
export CCAS # The C compiler to use for assembler files, typically the same as CC.
|
||||
export CFLAGS # The compiler flags. Must only ever be used with `+=`.
|
||||
export CFLAGS_CPU # CPU architecture specific compiler flags
|
||||
export CFLAGS_STATIC_ANALYSIS# Additional CFLAGS to use when static analysis should be enabled
|
||||
export CXXUWFLAGS # (Patterns of) flags in CFLAGS that should not be passed to CXX.
|
||||
export CXXEXFLAGS # Additional flags that should be passed to CXX.
|
||||
export CCASUWFLAGS # (Patterns of) flags in CFLAGS that should not be passed to CCAS.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user