2015-07-21 11:32:47 +02:00
|
|
|
SCANBUILD_ENV_VARS := \
|
|
|
|
APPDIR \
|
|
|
|
AR \
|
|
|
|
AS \
|
|
|
|
ASFLAGS \
|
|
|
|
BINDIR \
|
|
|
|
BINDIRBASE \
|
|
|
|
BOARD \
|
2020-04-14 15:23:23 +02:00
|
|
|
BOARDDIR \
|
2019-09-09 17:00:59 +02:00
|
|
|
BOARDSDIR \
|
2018-09-25 17:51:18 +02:00
|
|
|
BUILD_DIR \
|
2015-07-21 11:32:47 +02:00
|
|
|
BUILDRELPATH \
|
|
|
|
CC \
|
|
|
|
CFLAGS \
|
|
|
|
CPPMIX \
|
|
|
|
CXX \
|
|
|
|
CXXEXFLAGS \
|
|
|
|
CXXUWFLAGS \
|
|
|
|
ELFFILE \
|
|
|
|
HEXFILE \
|
2018-12-19 18:10:57 +01:00
|
|
|
FLASHFILE \
|
2015-07-21 11:32:47 +02:00
|
|
|
HOME \
|
|
|
|
LINK \
|
|
|
|
LINKFLAGPREFIX \
|
|
|
|
LINKFLAGS \
|
|
|
|
OBJCOPY \
|
|
|
|
OFLAGS \
|
|
|
|
PATH \
|
|
|
|
PREFIX \
|
|
|
|
QUIET \
|
2015-07-21 07:05:14 +02:00
|
|
|
WERROR \
|
2015-07-21 11:32:47 +02:00
|
|
|
RIOT_VERSION \
|
2018-11-14 13:01:09 +01:00
|
|
|
RIOT_CI_BUILD \
|
2015-07-21 11:32:47 +02:00
|
|
|
SIZE \
|
|
|
|
TOOLCHAIN \
|
|
|
|
UNDEF \
|
|
|
|
USER \
|
|
|
|
#
|
|
|
|
|
2018-11-14 13:01:09 +01:00
|
|
|
# Produce errors by default at the end of compilation when warning are found
|
|
|
|
SCANBUILD_ERROR ?= $(if $(filter 1,$(WERROR)),--status-bugs)
|
|
|
|
|
2015-07-21 11:32:47 +02:00
|
|
|
SCANBUILD_ARGS ?= \
|
|
|
|
-analyze-headers \
|
|
|
|
--use-cc=$(CC) \
|
|
|
|
--use-c++=$(CXX) \
|
|
|
|
-analyzer-config stable-report-filename=true \
|
2018-11-14 13:01:09 +01:00
|
|
|
$(SCANBUILD_ERROR) \
|
2015-07-21 11:32:47 +02:00
|
|
|
#
|
|
|
|
|
2018-11-14 13:01:09 +01:00
|
|
|
SCANBUILD_OUTPUTDIR = scan-build/$(BOARD)
|
2015-07-21 11:32:47 +02:00
|
|
|
|
|
|
|
# Find all variables given on the command line and recreate the command.
|
|
|
|
CMDVARS := $(strip $(foreach varname, $(SCANBUILD_ENV_VARS), \
|
|
|
|
$(if $(filter command, $(origin $(varname))), \
|
|
|
|
'$(varname)=$(subst ','\'',$($(varname)))', \
|
|
|
|
)))
|
|
|
|
ENVVARS := $(strip $(foreach varname, $(SCANBUILD_ENV_VARS), \
|
|
|
|
$(if $(filter environment, $(origin $(varname))), \
|
|
|
|
'$(varname)=$(subst ','\'',$($(varname)))', \
|
|
|
|
)))
|
|
|
|
|
2018-11-14 13:01:09 +01:00
|
|
|
.PHONY: scan-build scan-build-analyze
|
|
|
|
.PHONY: ..scan-build-view ..scan-build-analyze
|
|
|
|
|
|
|
|
ifeq (1,$(INSIDE_DOCKER))
|
|
|
|
# In the container just do the analysis, 'view' will be done by the host
|
|
|
|
scan-build: ..scan-build-analyze
|
|
|
|
else # INSIDE_DOCKER
|
|
|
|
scan-build: ..scan-build-view
|
|
|
|
endif # INSIDE_DOCKER
|
|
|
|
|
2018-11-14 13:01:09 +01:00
|
|
|
# Prevent 'analyze' from producing an error when doing 'scan-build' and
|
|
|
|
# still show the webpage for interractive checking.
|
|
|
|
scan-build: SCANBUILD_ERROR=
|
|
|
|
|
2015-07-21 11:32:47 +02:00
|
|
|
ifeq ($(BUILD_IN_DOCKER),1)
|
2018-11-14 13:01:09 +01:00
|
|
|
# It will trigger executing 'scan-build' or 'scan-build-analyze' with docker
|
2015-07-21 11:32:47 +02:00
|
|
|
scan-build-analyze: ..in-docker-container
|
|
|
|
else # BUILD_IN_DOCKER
|
2018-11-14 13:01:09 +01:00
|
|
|
scan-build-analyze: ..scan-build-analyze
|
|
|
|
endif # BUILD_IN_DOCKER
|
|
|
|
|
|
|
|
|
|
|
|
..scan-build-analyze: clean
|
2015-07-21 11:32:47 +02:00
|
|
|
@$(COLOR_ECHO) '$(COLOR_GREEN)Performing Clang static code analysis using toolchain "$(TOOLCHAIN)".$(COLOR_RESET)'
|
|
|
|
# ccc-analyzer needs to be told the proper -target setting for best results,
|
|
|
|
# otherwise false error reports about unknown register names etc will be produced.
|
|
|
|
# These kinds of errors can be safely ignored as long as they only come from LLVM
|
|
|
|
@if [ "$${TOOLCHAIN}" != "llvm" -a "$${BOARD}" != "native" ]; then \
|
|
|
|
$(COLOR_ECHO) '$(COLOR_YELLOW)Recommend using TOOLCHAIN=llvm for best results.$(COLOR_RESET)'; \
|
|
|
|
$(COLOR_ECHO) '$(COLOR_YELLOW)Ignore any "error: unknown register name '\''rX'\'' in asm" messages.$(COLOR_RESET)'; \
|
|
|
|
fi
|
2016-12-17 01:16:59 +01:00
|
|
|
$(Q)mkdir -p '$(SCANBUILD_OUTPUTDIR)'
|
|
|
|
$(Q)env -i $(ENVVARS) \
|
2015-07-21 11:32:47 +02:00
|
|
|
scan-build -o '$(SCANBUILD_OUTPUTDIR)' $(SCANBUILD_ARGS) \
|
2020-07-03 11:17:57 +02:00
|
|
|
$(MAKE) -C $(CURDIR) all $(strip $(CMDVARS)) FORCE_ASSERTS=1
|
2015-07-21 11:32:47 +02:00
|
|
|
|
2018-11-14 13:01:09 +01:00
|
|
|
..scan-build-view: scan-build-analyze
|
2015-07-21 11:32:47 +02:00
|
|
|
@echo "Showing most recent report in your web browser..."
|
|
|
|
@REPORT_FILE="$$(find '$(SCANBUILD_OUTPUTDIR)' -maxdepth 2 -mindepth 2 \
|
|
|
|
-type f -name 'index.html' 2>/dev/null | sort | tail -n 1)"; \
|
|
|
|
if [ -n "$${REPORT_FILE}" ]; then \
|
|
|
|
echo "$(OPEN) $${REPORT_FILE}"; \
|
|
|
|
$(OPEN) "$${REPORT_FILE}"; \
|
|
|
|
else \
|
|
|
|
echo "No report found"; \
|
|
|
|
fi
|