Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: dts: import devicetree symbols into CMake #37624

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmake/dts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ set(DTS_POST_CPP ${PROJECT_BINARY_DIR}/${BOARD}.dts.pre.tmp)
# This is relative to each element of DTS_ROOT.
set(VENDOR_PREFIXES dts/bindings/vendor-prefixes.txt)

# Devicetree in CMake.
set(DTS_CMAKE_SCRIPT ${ZEPHYR_BASE}/scripts/dts/gen_dts_cmake.py)
set(DTS_CMAKE ${PROJECT_BINARY_DIR}/dts.cmake)

set_ifndef(DTS_SOURCE ${BOARD_DIR}/${BOARD}.dts)

zephyr_file(APPLICATION_ROOT DTS_ROOT)
Expand Down Expand Up @@ -175,6 +179,7 @@ if(SUPPORTS_DTS)
CMAKE_CONFIGURE_DEPENDS
${include_files}
${GEN_DEFINES_SCRIPT}
${DTS_CMAKE_SCRIPT}
)

#
Expand Down Expand Up @@ -250,6 +255,20 @@ if(SUPPORTS_DTS)
message(STATUS "Generated device_extern.h: ${DEVICE_EXTERN_H}")
endif()

execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${DTS_CMAKE_SCRIPT}
--edt-pickle ${EDT_PICKLE}
--cmake-out ${DTS_CMAKE}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
RESULT_VARIABLE ret
)
if(NOT "${ret}" STREQUAL "0")
message(FATAL_ERROR "gen_dts_cmake.py failed with return code: ${ret}")
else()
message(STATUS "Including generated dts.cmake file: ${DTS_CMAKE}")
include(${DTS_CMAKE})
endif()

else()
file(WRITE ${DEVICETREE_UNFIXED_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */")
file(WRITE ${DEVICE_EXTERN_H} "/* WARNING. THIS FILE IS AUTO-GENERATED. DO NOT MODIFY! */")
Expand Down
Loading