Commit 16922ce9 authored by Ben Avison's avatar Ben Avison
Browse files

Generate cppcheck suppression specification for module builds

Cppcheck 1.84 or later permits warning suppressions to be specified on a
per-symbol basis, provided the suppressions are specified in an XML file.

We wish to make use of this to reduce the number of inline suppression
markers in source files. However, it is difficult for a CI job script to know
how to analyse a CMHG file, because the filename and build options vary from
component to component. It is much easier instead to automatically emit an
consistently-named XML file during the standard CMHG rule in the shared
makefiles, especially since the cppcheck CI job needs to run CMHG anyway in
order to auto-generate a C header file from the CMHG file. So this is what
we do here. The only environment for which this is enabled is Norcroft-based
cross-compilation, but that's the only one we need.

Another precedent for this sort of build side-effect are the symbol listing
files that are generated during ROM link - although in that case they are
primarily to assist debugging the resultant ROM images.
parent 3542c0f3
......@@ -14,7 +14,21 @@ endif
.cmhg.h:; ${CMHG} ${CINCLUDES} ${CMHGFLAGS} -d $@ $<
# CMHG source files -> object file
.cmhg.o:; ${CMHG} ${CINCLUDES} ${CMHGFLAGS} -o $@ $<
.cmhg.o:
${CMHG} ${CINCLUDES} ${CMHGFLAGS} -o $@ $<
ifneq (GNU,${TOOLCHAIN})
{ \
echo "<?xml version=\"1.0\"?>"; \
echo "<suppressions>"; \
for func in $$(/opt/rool/bin/decaof -s $@ | sed '0,/Symbol Table/d;/:/!N;s/\n//;/External reference/!d;s/ .*//;/^_/d'); do \
echo " <suppress>"; \
echo " <id>unusedFunction</id>"; \
echo " <symbolName>$$func</symbolName>"; \
echo " </suppress>"; \
done; \
echo "</suppressions>"; \
} > cmhg-cppcheck-suppress.xml
endif
.cmhg.od:; ${CMHG} ${CINCLUDES} ${CMHGFLAGS} -o $@ $<
# EOF
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment