cmake: introduce EXTRA_DTC_OVERLAY_FILE for devicetree

This commit introduces EXTRA_DTC_OVERLAY_FILE.

This allows users to specify additional devicetree overlays in addition
to a sample / board specific default devicetree overlay files.

It also allows snippets to provide extra devicetree overlays on addition
to sample / board specific overlays.

The name EXTRA_DTC_OVERLAY_FILE clearly indicates the purpose and
follows the naming scheme of EXTRA_ in front of variable name.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2023-05-17 12:52:45 +02:00 committed by Carles Cufí
commit 384fb1e478
2 changed files with 17 additions and 1 deletions

View file

@ -117,3 +117,4 @@ DTC_OVERLAY_FILE=\"dts1.overlay dts2.overlay\"")
zephyr_boilerplate_watch(DTC_OVERLAY_FILE)
zephyr_get(EXTRA_CONF_FILE SYSBUILD LOCAL VAR EXTRA_CONF_FILE OVERLAY_CONFIG)
zephyr_get(EXTRA_DTC_OVERLAY_FILE SYSBUILD LOCAL)

View file

@ -75,6 +75,12 @@ find_package(Dtc 1.4.6)
# - BOARD_DIR: board directory to use when looking for DTS_SOURCE
# - BOARD_REVISION_STRING: used when looking for a board revision's
# devicetree overlay file in BOARD_DIR
# - DTC_OVERLAY_FILE: list of devicetree overlay files which will be
# used to modify or extend the base devicetree.
# - EXTRA_DTC_OVERLAY_FILE: list of extra devicetree overlay files.
# This variable is is similar to DTC_OVERLAY_FILE but the files in
# EXTRA_DTC_OVERLAY_FILE will be applied after DTC_OVERLAY_FILE and
# thus files specified by EXTRA_DTC_OVERLAY_FILE have higher precedence.
# - EXTRA_DTC_FLAGS: list of extra command line options to pass to
# dtc when using it to check for additional errors and warnings;
# invalid flags are automatically filtered out of the list
@ -82,7 +88,7 @@ find_package(Dtc 1.4.6)
# C preprocessor when generating the devicetree from DTS_SOURCE
# - DTS_SOURCE: the devicetree source file to use may be pre-set
# with this variable; otherwise, it defaults to
# ${BOARD_DIR}/${BOARD.dts}
# ${BOARD_DIR}/${BOARD}.dts
#
# Variables set by this module and not mentioned above are for internal
# use only, and may be removed, renamed, or re-purposed without prior notice.
@ -158,6 +164,15 @@ if(DTC_OVERLAY_FILE)
)
endif()
if(EXTRA_DTC_OVERLAY_FILE)
zephyr_list(TRANSFORM EXTRA_DTC_OVERLAY_FILE NORMALIZE_PATHS
OUTPUT_VARIABLE EXTRA_DTC_OVERLAY_FILE_AS_LIST)
list(APPEND
dts_files
${EXTRA_DTC_OVERLAY_FILE_AS_LIST}
)
endif()
set(i 0)
foreach(dts_file ${dts_files})
if(i EQUAL 0)