build-unit-test-docker: add cppcheck static analysis tool
Add the cppcheck static analysis tool. This tool's output is only for
information while it's being tuned. The tool is meant to find security
flaws in cpp as well as finding performance improvements and style. In
this case, the style improvements have been primarily scope reduction
or using a standard library algorithm instead of a raw mechanism.
The author of a patch should check the log output from their presubmit
to see if this tool has identified anything. The reviewers can also
check.
The tuning here refers to the configuration. This tool was chosen
partially because it's under very active development and partially
because it's very quick.
If cppcheck reports a false positive, please file an issue against that
project including the pertinent information.
Change-Id: Ia43d4b9d0995dfa6667c2a8b09d072931936e437
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/build-unit-test-docker.sh b/build-unit-test-docker.sh
index 85bae94..03ea535 100755
--- a/build-unit-test-docker.sh
+++ b/build-unit-test-docker.sh
@@ -92,6 +92,7 @@
[libvncserver]=7b1ef0ffc4815cab9a96c7278394152bdc89dc4d
# version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb
[tinyxml2]=37bc3aca429f0164adf68c23444540b4a24b5778
+ [cppcheck]=df32b0fb05f0c951ab0efa691292c7428f3f50a9
)
# Turn the depcache into a dictionary so we can reference the HEAD of each repo
@@ -225,6 +226,13 @@
RUN curl -L https://dl.bintray.com/boostorg/release/${PKG_REV['boost']}/source/boost_$(echo "${PKG_REV['boost']}" | tr '.' '_').tar.bz2 | tar -xj && \
cp -a -r boost_*/boost ${PREFIX}/include
+FROM openbmc-base as openbmc-cppcheck
+RUN curl -L https://github.com/danmar/cppcheck/archive/${PKG_REV['cppcheck']}.tar.gz | tar -xz && \
+cd cppcheck-* && \
+mkdir "${PREFIX}/cppcheck-cfg" && cp cfg/* "${PREFIX}/cppcheck-cfg/" && \
+make -j$(nproc) CFGDIR="${PREFIX}/cppcheck-cfg" CXXFLAGS="-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-unused-function" && \
+make PREFIX=${PREFIX} install
+
FROM openbmc-base as openbmc-tinyxml2
RUN curl -L https://github.com/leethomason/tinyxml2/archive/${PKG_REV['tinyxml2']}.tar.gz | tar -xz && \
cd tinyxml2-* && \