Kconfig.zephyr: add an option for checking build time init priority

Add an option for running the build time initialization priority check
as part of the build.

By default the build is going to fail if any error is reported
(dependent devices, inverted priority), optionally it can also be failed
on warnings (dependent devices, same priority).

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
Fabio Baltieri 2023-03-09 17:29:54 +00:00 committed by Carles Cufí
parent 8412cb32ce
commit 2264c14fdf
2 changed files with 32 additions and 0 deletions

View file

@ -1759,6 +1759,19 @@ if(CONFIG_BUILD_OUTPUT_INFO_HEADER)
)
endif()
if(CONFIG_CHECK_INIT_PRIORITIES)
if(CONFIG_CHECK_INIT_PRIORITIES_FAIL_ON_WARNING)
set(fail_on_warning "--fail-on-warning")
endif()
list(APPEND
post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/build/check_init_priorities.py
--build-dir ${PROJECT_BINARY_DIR}/..
--edt-pickle ${EDT_PICKLE}
${fail_on_warning}
)
endif()
# Generate and use MCUboot related artifacts as needed.
if(CONFIG_BOOTLOADER_MCUBOOT)
get_target_property(signing_script zephyr_property_target SIGNING_SCRIPT)

View file

@ -719,6 +719,25 @@ config BUILD_OUTPUT_STRIP_PATHS
Debuggers usually have a path mapping feature to ensure the files are
still found.
config CHECK_INIT_PRIORITIES
bool "Build time initialization priorities check"
help
Check the build for initialization priority issues by comparing the
initialization priority in the build with the device dependency
derived from the devicetree definition.
Fails the build on priority errors (dependent devices, inverted
priority), see CHECK_INIT_PRIORITIES_FAIL_ON_WARNING to fail on
warnings (dependent devices, same priority) as well.
config CHECK_INIT_PRIORITIES_FAIL_ON_WARNING
bool "Fail the build on priority check warnings"
depends on CHECK_INIT_PRIORITIES
help
Fail the build if the dependency check script identifies any pair of
devices depending on each other but initialized with the same
priority.
endmenu
config DEPRECATED