Skip to content
Snippets Groups Projects
Unverified Commit 79b0a550 authored by Gaëtan Harter's avatar Gaëtan Harter Committed by GitHub
Browse files

Merge pull request #10391 from cladmi/pr/make/scan_build_integration

makefiles/scan-build: separate scan-build-analyze and make it produce an error
parents 6627e406 50f58bfb
No related branches found
No related tags found
No related merge requests found
......@@ -27,20 +27,25 @@ SCANBUILD_ENV_VARS := \
QUIET \
WERROR \
RIOT_VERSION \
RIOT_CI_BUILD \
SIZE \
TOOLCHAIN \
UNDEF \
USER \
#
# Produce errors by default at the end of compilation when warning are found
SCANBUILD_ERROR ?= $(if $(filter 1,$(WERROR)),--status-bugs)
SCANBUILD_ARGS ?= \
-analyze-headers \
--use-cc=$(CC) \
--use-c++=$(CXX) \
-analyzer-config stable-report-filename=true \
$(SCANBUILD_ERROR) \
#
export SCANBUILD_OUTPUTDIR = $(CURDIR)/scan-build/
SCANBUILD_OUTPUTDIR = scan-build/$(BOARD)
# Find all variables given on the command line and recreate the command.
CMDVARS := $(strip $(foreach varname, $(SCANBUILD_ENV_VARS), \
......@@ -52,13 +57,29 @@ ENVVARS := $(strip $(foreach varname, $(SCANBUILD_ENV_VARS), \
'$(varname)=$(subst ','\'',$($(varname)))', \
)))
.PHONY: scan-build scan-build-analyze scan-build-view
scan-build: scan-build-view scan-build-analyze
scan-build-view: scan-build-analyze
.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
# Prevent 'analyze' from producing an error when doing 'scan-build' and
# still show the webpage for interractive checking.
scan-build: SCANBUILD_ERROR=
ifeq ($(BUILD_IN_DOCKER),1)
# It will trigger executing 'scan-build' or 'scan-build-analyze' with docker
scan-build-analyze: ..in-docker-container
else # BUILD_IN_DOCKER
scan-build-analyze: clean
scan-build-analyze: ..scan-build-analyze
endif # BUILD_IN_DOCKER
..scan-build-analyze: clean
@$(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.
......@@ -70,13 +91,9 @@ scan-build-analyze: clean
$(Q)mkdir -p '$(SCANBUILD_OUTPUTDIR)'
$(Q)env -i $(ENVVARS) \
scan-build -o '$(SCANBUILD_OUTPUTDIR)' $(SCANBUILD_ARGS) \
make -C $(CURDIR) all $(strip $(CMDVARS)) FORCE_ASSERTS=1;
endif # BUILD_IN_DOCKER
make -C $(CURDIR) all $(strip $(CMDVARS)) FORCE_ASSERTS=1
ifeq (1,$(INSIDE_DOCKER))
scan-build-view:
@
else
..scan-build-view: scan-build-analyze
@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)"; \
......@@ -86,4 +103,3 @@ else
else \
echo "No report found"; \
fi
endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment