device: make device dependencies optional

Device dependencies are not always required, so make them optional via
CONFIG_DEVICE_DEPS. When enabled, the gen_device_deps script will run so
that dependencies are collected and part of the final image. Related
APIs will be also made available. Since device dependencies are used in
just a few places (power domains), disable the feature by default. When
not enabled, a second linking pass will not be required.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2023-06-14 14:30:41 +02:00 committed by Carles Cufí
commit 48b201cc53
11 changed files with 50 additions and 11 deletions

View file

@ -54,7 +54,7 @@ set(CMAKE_EXECUTABLE_SUFFIX .elf)
# into the `zephyr_final` target.
#
# Multiple linking stages are required in the following cases:
# - device handles structs must be generated (CONFIG_HAS_DTS=y)
# - device dependencies structs must be generated (CONFIG_DEVICE_DEPS=y)
# - ISR tables must be generated (CONFIG_GEN_ISR_TABLES=y)
# - Kernel objects hash tables (CONFIG_USERSPACE=y)
# - Application memory partitions (CONFIG_USERSPACE=y)
@ -75,7 +75,7 @@ set(ZEPHYR_LINK_STAGE_EXECUTABLE zephyr_pre${ZEPHYR_CURRENT_LINKER_PASS})
# existing variable to allow slowly cleanup of linking stage handling.
# Three stage linking active: pre0 -> pre1 -> final, this will correspond to `pre1`
# Two stage linking active: pre0 -> final, this will correspond to `pre0`
if(CONFIG_USERSPACE OR CONFIG_HAS_DTS)
if(CONFIG_USERSPACE OR CONFIG_DEVICE_DEPS)
set(ZEPHYR_PREBUILT_EXECUTABLE zephyr_pre1)
else()
set(ZEPHYR_PREBUILT_EXECUTABLE zephyr_pre0)
@ -912,7 +912,7 @@ zephyr_get_include_directories_for_lang(C
STRIP_PREFIX # Don't use a -I prefix
)
if(CONFIG_HAS_DTS)
if(CONFIG_DEVICE_DEPS)
if(CONFIG_DEVICE_DEPS_DYNAMIC)
set(dynamic_deps --dynamic-deps)
endif()
@ -1177,7 +1177,7 @@ if(CONFIG_USERSPACE)
)
endif()
if(CONFIG_USERSPACE OR CONFIG_HAS_DTS)
if(CONFIG_USERSPACE OR CONFIG_DEVICE_DEPS)
configure_linker_script(
${ZEPHYR_CURRENT_LINKER_CMD}
"${LINKER_PASS_${ZEPHYR_CURRENT_LINKER_PASS}_DEFINE}"