cmake: dt: Reconfigure when DTS dependencies change
When DT sources change CMake must be run again. CMake is currently detecting changes to DT source files that we manually specify, but not sources that are included through use of the preprocessor. This patch makes the preprocessor output the includes used and adds them to the 'CMAKE_CONFIGURE_DEPENDS' property. This fixes #16791. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
parent
c5dd84a316
commit
5c57abcc48
1 changed files with 18 additions and 8 deletions
|
@ -65,12 +65,6 @@ if(SUPPORTS_DTS)
|
||||||
message(STATUS "Overlaying ${dts_file}")
|
message(STATUS "Overlaying ${dts_file}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Ensure that changes to 'dts_file's cause CMake to be re-run
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY
|
|
||||||
CMAKE_CONFIGURE_DEPENDS
|
|
||||||
${dts_file}
|
|
||||||
)
|
|
||||||
|
|
||||||
math(EXPR i "${i}+1")
|
math(EXPR i "${i}+1")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
@ -109,7 +103,8 @@ if(SUPPORTS_DTS)
|
||||||
|
|
||||||
# Run the C preprocessor on an empty C source file that has one or
|
# Run the C preprocessor on an empty C source file that has one or
|
||||||
# more DTS source files -include'd into it to create the
|
# more DTS source files -include'd into it to create the
|
||||||
# intermediary file *.dts.pre.tmp
|
# intermediary file *.dts.pre.tmp. Also, generate a dependency file
|
||||||
|
# so that changes to DT sources are detected.
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_C_COMPILER}
|
COMMAND ${CMAKE_C_COMPILER}
|
||||||
-x assembler-with-cpp
|
-x assembler-with-cpp
|
||||||
|
@ -119,8 +114,10 @@ if(SUPPORTS_DTS)
|
||||||
${NOSYSDEF_CFLAG}
|
${NOSYSDEF_CFLAG}
|
||||||
-D__DTS__
|
-D__DTS__
|
||||||
-P
|
-P
|
||||||
-E ${ZEPHYR_BASE}/misc/empty_file.c
|
-E # Stop after preprocessing
|
||||||
|
-MD # Generate a dependency file as a side-effect
|
||||||
-o ${BOARD}.dts.pre.tmp
|
-o ${BOARD}.dts.pre.tmp
|
||||||
|
${ZEPHYR_BASE}/misc/empty_file.c
|
||||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
RESULT_VARIABLE ret
|
RESULT_VARIABLE ret
|
||||||
)
|
)
|
||||||
|
@ -128,6 +125,19 @@ if(SUPPORTS_DTS)
|
||||||
message(FATAL_ERROR "command failed with return code: ${ret}")
|
message(FATAL_ERROR "command failed with return code: ${ret}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Parse the generated dependency file to find the DT sources that
|
||||||
|
# were included and then add them to the list of files that trigger
|
||||||
|
# a re-run of CMake.
|
||||||
|
toolchain_parse_make_rule(
|
||||||
|
${PROJECT_BINARY_DIR}/${BOARD}.dts.pre.d
|
||||||
|
include_files # Output parameter
|
||||||
|
)
|
||||||
|
|
||||||
|
set_property(DIRECTORY APPEND PROPERTY
|
||||||
|
CMAKE_CONFIGURE_DEPENDS
|
||||||
|
${include_files}
|
||||||
|
)
|
||||||
|
|
||||||
# Run the DTC on *.dts.pre.tmp to create the intermediary file *.dts_compiled
|
# Run the DTC on *.dts.pre.tmp to create the intermediary file *.dts_compiled
|
||||||
|
|
||||||
set(DTC_WARN_UNIT_ADDR_IF_ENABLED "")
|
set(DTC_WARN_UNIT_ADDR_IF_ENABLED "")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue