refactor(tools/cppcheck): introduce build target for MISRA check
The CPPCheck was integrated to the build system but it was not inline
with other checkers in the system. This patch refactors the cppcheck
integration with the Cmake build system.
1. Corrected the issue that Cmake .dump files are created along with
source files
2. Enabled the MISRA checks without have to copy the rules file at
a particular location. The limitation being that the rule description
will not be present in the error output.
3. Introduced separate build rules for regular CPPCheck and MISRA check.
4. Cleaned up the CPPCheck cmake file to remove unneeded sequences.
5. The output of CPPCheck is now aligned to gcc output format which
makes it more readable for developers familiar with GCC output.
6. Added MISRA rule suppressions to match project expectations.
7. The cppcheck platform file `GNU.xml` is now renamed to a generic name as the file is not specific to GNU but common for aarch64 platforms.
The patch also moves static check build targets to `tools/` cmake file.
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
Change-Id: I793e86c8238e7a5d39ef720ba3e0b22f51db648d
diff --git a/docs/getting_started/build-options.rst b/docs/getting_started/build-options.rst
index 58edeb7..6dab78d 100644
--- a/docs/getting_started/build-options.rst
+++ b/docs/getting_started/build-options.rst
@@ -102,17 +102,17 @@
.. code-block:: bash
- cmake -DRMM_CONFIG=fvp_defcfg -DRMM_STATIC_ANALYSIS_CPPCHECK=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
+ cmake -DRMM_CONFIG=fvp_defcfg -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
cmake --build ${RMM_BUILD_DIR} -- cppcheck
cat ${BUILD_DIR}/tools/cppcheck/cppcheck.xml
-9. Perform a Cppcheck static analysis with CERT_C/MISRA/THREAD SAFETY (example with MISRA):
+9. Perform a Cppcheck static analysis with MISRA:
.. code-block:: bash
- cmake -DRMM_CONFIG=fvp_defcfg -DRMM_STATIC_ANALYSIS_CPPCHECK=ON -DRMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_MISRA=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
- cmake --build ${RMM_BUILD_DIR} -- cppcheck
- cat ${BUILD_DIR}/tools/cppcheck/cppcheck.xml
+ cmake -DRMM_CONFIG=fvp_defcfg -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -S ${RMM_SOURCE_DIR} -B ${RMM_BUILD_DIR}
+ cmake --build ${RMM_BUILD_DIR} -- cppcheck-misra
+ cat ${BUILD_DIR}/tools/cppcheck/cppcheck_misra.xml
10. Perform a checkpatch analysis:
@@ -270,10 +270,6 @@
RMM_TOOLCHAIN ,gnu | llvm , ,"Toolchain name"
LOG_LEVEL , ,40 ,"Log level to apply for RMM (0 - 50)"
RMM_STATIC_ANALYSIS , , ,"Enable static analysis checkers"
- RMM_STATIC_ANALYSIS_CPPCHECK ,ON | OFF ,ON ,"Enable Cppcheck static analysis"
- RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_CERT_C ,ON | OFF ,ON ,"Enable Cppcheck's SEI CERT C checker"
- RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_MISRA ,ON | OFF ,ON ,"Enable Cppcheck's MISRA C:2012 checker"
- RMM_STATIC_ANALYSIS_CPPCHECK_CHECKER_THREAD_SAFETY ,ON | OFF ,ON ,"Enable Cppcheck's thread safety checker"
RMM_UART_ADDR , ,0x0 ,"Base addr of UART to be used for RMM logs"
PLAT_CMN_CTX_MAX_XLAT_TABLES , ,0 ,"Maximum number of translation tables used by the runtime context"
PLAT_CMN_EXTRA_MMAP_REGIONS , ,0 ,"Extra platform mmap regions that need to be mapped in S1 xlat tables"
diff --git a/docs/getting_started/getting-started.rst b/docs/getting_started/getting-started.rst
index bbf744e..87c003d 100644
--- a/docs/getting_started/getting-started.rst
+++ b/docs/getting_started/getting-started.rst
@@ -51,6 +51,7 @@
"docutils",">v2.38.0","Documentation"
"gcovr",">=v4.2","Tools(Coverage analysis)"
"CBMC",">=5.84.0","Tools(CBMC analysis)"
+ "CPPcheck",">=1.90","Tools(CPPcheck)"
.. _getting_started_toolchain:
@@ -216,15 +217,14 @@
if using the Cppcheck static analysis.
Follow the public documentation to install Cppcheck either from the official
-website https://cppcheck.sourceforge.io/#download or from the official github
+website https://cppcheck.sourceforge.io/ or from the official github
https://github.com/danmar/cppcheck/
If you own a valid copy of a MISRA rules file:
.. code-block:: bash
- sudo mkdir /usr/local/share/Cppcheck/misra
- sudo cp -a <path to the misra rules file>/<file name> /usr/local/share/Cppcheck/misra/misra.rules
+ cp -a <path to the misra rules file>/<file name> ${RMM_SOURCE_DIR}/tools/cppcheck/misra.rules
############
Install CBMC