Skip to content

Commit

Permalink
cmake: modules: dts: improve message() generation
Browse files Browse the repository at this point in the history
If DTS_SOURCE is already set, then it might not be a BOARD.dts, even
though that is true basically always today.

Make the output generation a bit more generic so that we can handle
a pre-set DTS_SOURCE better, even though this is currently an edge
case. (It won't be an edge case anymore when we have system devicetree
support.)

Signed-off-by: Martí Bolívar <[email protected]>
  • Loading branch information
mbolivar-nordic committed Mar 28, 2023
1 parent 982c333 commit b5ae998
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions cmake/modules/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,20 @@ set(VENDOR_PREFIXES dts/bindings/vendor-prefixes.txt)

# TODO: What to do about non-posix platforms where NOT CONFIG_HAS_DTS (xtensa)?
# Drop support for NOT CONFIG_HAS_DTS perhaps?
set_ifndef(DTS_SOURCE ${BOARD_DIR}/${BOARD}.dts)
if(EXISTS ${DTS_SOURCE})
# We found a devicetree. Check for a board revision overlay.
if(BOARD_REVISION AND EXISTS ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
list(APPEND DTS_SOURCE ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
if(NOT DEFINED DTS_SOURCE)
if(EXISTS ${BOARD_DIR}/${BOARD}.dts)
set(DTS_SOURCE ${BOARD_DIR}/${BOARD}.dts)
message(STATUS "Found BOARD.dts: ${DTS_SOURCE}")
# We found a devicetree. Check for a board revision overlay.
if(BOARD_REVISION AND EXISTS ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
list(APPEND DTS_SOURCE ${BOARD_DIR}/${BOARD}_${BOARD_REVISION_STRING}.overlay)
endif()
else()
# If we don't have a devicetree after all, there's not much to do.
set(header_template ${ZEPHYR_BASE}/misc/generated/generated_header.template)
zephyr_file_copy(${header_template} ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT)
return()
endif()
else()
# If we don't have a devicetree after all, there's not much to do.
set(header_template ${ZEPHYR_BASE}/misc/generated/generated_header.template)
zephyr_file_copy(${header_template} ${DEVICETREE_GENERATED_H} ONLY_IF_DIFFERENT)
return()
endif()

#
Expand All @@ -159,15 +162,10 @@ if(DTC_OVERLAY_FILE)
)
endif()

set(i 0)
foreach(dts_file ${dts_files})
if(i EQUAL 0)
message(STATUS "Found BOARD.dts: ${dts_file}")
else()
if(dts_file MATCHES ".*[.]overlay$")
message(STATUS "Found devicetree overlay: ${dts_file}")
endif()

math(EXPR i "${i}+1")
endforeach()

unset(DTS_ROOT_BINDINGS)
Expand Down

0 comments on commit b5ae998

Please sign in to comment.