Skip to content

Commit 09390ba

Browse files
committed
cmake: include pre_dt_board.cmake from all board directories
After zephyrproject-rtos#72857 the concept of board directory was expanded from a single path (BOARD_DIR) to a list of paths (BOARD_DIRECTORIES) which is taken into account in several places except when including `pre_dt_board.cmake` files. This patch moves the inclusion of `pre_dt_board.cmake` files into `dts.cmake` AFTER `boards.cmake` is included (so we can access `BOARD_DIRECTORIES`) but BEFORE `pre_dt.cmake`, which preserves the original inclusion order relative to pre DTC operations. The original motivation of this patch was to address the practicality of defining board extensions that can re-use base board definitions. In particular, one of the drawbacks of zephyrproject-rtos#72857 is that board extensions are not really extending board definitions just the qualifier. There is still the need to create a DTS for each new board extension which is often a copy-and-paste of the base board DTS eventually with a few alterations. The problem is that except for toy examples, board DTS files are rarely self-contained and instead are composed of multiple dtsi includes using relative paths which then forces board extension files to either use hard coded paths to the base board directory OR recursively copy all included dtsi files from the base board directory into the board extension directory. With this patch a board extension directory can define custom configuration steps like regular base boards can and then adjust CPP and DTC include search paths dynamically, for example with: ``` list(APPEND DTS_EXTRA_CPPFLAGS "-I${BOARD_DIR}") list(APPEND EXTRA_DTC_FLAGS "-i${BOARD_DIR}") ``` Signed-off-by: Nicolas Lebedenco <[email protected]>
1 parent f9eeefa commit 09390ba

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cmake/modules/dts.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ include_guard(GLOBAL)
55
include(extensions)
66
include(python)
77
include(boards)
8+
9+
# Include board specific device-tree flags before parsing.
10+
foreach(dir IN LISTS BOARD_DIRECTORIES)
11+
include("${dir}/pre_dt_board.cmake" OPTIONAL)
12+
endforeach()
13+
814
include(pre_dt)
915
find_package(HostTools)
1016
find_package(Dtc 1.4.6)

cmake/modules/zephyr_default.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ list(APPEND zephyr_cmake_modules hwm_v2)
101101
list(APPEND zephyr_cmake_modules configuration_files)
102102
list(APPEND zephyr_cmake_modules generated_file_directories)
103103

104-
# Include board specific device-tree flags before parsing.
105-
set(pre_dt_board "\${BOARD_DIR}/pre_dt_board.cmake" OPTIONAL)
106-
list(APPEND zephyr_cmake_modules "\${pre_dt_board}")
107-
108104
# DTS should be close to kconfig because CONFIG_ variables from
109105
# kconfig and dts should be available at the same time.
110106
list(APPEND zephyr_cmake_modules dts)

0 commit comments

Comments
 (0)