-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: implement build infrastructure for supporting SCA tools.
Static code analyser (SCA) tools are important in software development. CMake offers built-in support for some tools, such as cppcheck and clang-tidy. Other tools, such as sparse, are not directly supported. This commit provides a uniform way for users to specify a supported SCA using `ZEPHYR_SCA_VARIANT=<tool>` which is consistent with how toolchains are specified. ZEPHYR_SCA_VARIANT can be set using `-D` or in environment. Support for an SCA tool is done in `cmake/sca/<tool>/sca.cmake`. SCA_ROOT can be used to specify additional search paths when looking up implementation for a tool. SCA_ROOT can also be specified in `zephyr/module.yml` as setting. This makes it possible to provide SCA tool implementation as part of a Zephyr module. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
- Loading branch information
1 parent
ac95102
commit cb690ec
Showing
4 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Copyright (c) 2022, Nordic Semiconductor ASA | ||
|
||
# 'SCA_ROOT' is a prioritized list of directories where SCA tools may | ||
# be found. It always includes ${ZEPHYR_BASE} at the lowest priority. | ||
list(APPEND SCA_ROOT ${ZEPHYR_BASE}) | ||
|
||
zephyr_get(ZEPHYR_SCA_VARIANT) | ||
|
||
if(ScaTools_FIND_REQUIRED AND NOT DEFINED ZEPHYR_SCA_VARIANT) | ||
message(FATAL_ERROR "ScaTools required but 'ZEPHYR_SCA_VARIANT' is not set. " | ||
"Please set 'ZEPHYR_SCA_VARIANT' to desired tool." | ||
) | ||
endif() | ||
|
||
if(NOT DEFINED ZEPHYR_SCA_VARIANT) | ||
return() | ||
endif() | ||
|
||
foreach(root ${SCA_ROOT}) | ||
if(EXISTS ${root}/cmake/sca/${ZEPHYR_SCA_VARIANT}/sca.cmake) | ||
include(${root}/cmake/sca/${ZEPHYR_SCA_VARIANT}/sca.cmake) | ||
return() | ||
endif() | ||
endforeach() | ||
|
||
message(FATAL_ERROR "ZEPHYR_SCA_VARIANT set to '${ZEPHYR_SCA_VARIANT}' but no " | ||
"implementation for '${ZEPHYR_SCA_VARIANT}' found. " | ||
"SCA_ROOTs searched: ${SCA_ROOT}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters