Skip to content

Commit 361fdaa

Browse files
SebastianBoenashif
authored andcommitted
cmake: Fix the generation of fixup files
A recent change in how the fixup mechanism works caused several regressions. See zephyrproject-rtos#12680 for more details about the regressions. The core of the matter is that using defines to pass on include paths causes interopability issues when integrating with external build systems. To resolve this we re-write the fixup mechanism to instead generate an aggregated fixup file that is ready to be included at build time. Then no paths are passed through defines and we resolve the regressions reported. Signed-off-by: Sebastian Bøe <[email protected]>
1 parent 94e0279 commit 361fdaa

File tree

2 files changed

+13
-38
lines changed

2 files changed

+13
-38
lines changed

CMakeLists.txt

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -487,32 +487,21 @@ endforeach()
487487
set_ifndef( DTS_BOARD_FIXUP_FILE ${BOARD_DIR}/dts_fixup.h)
488488
set_ifndef( DTS_SOC_FIXUP_FILE ${SOC_DIR}/${ARCH}/${SOC_PATH}/dts_fixup.h)
489489
set( DTS_APP_FIXUP_FILE ${APPLICATION_SOURCE_DIR}/dts_fixup.h)
490-
set_ifndef(DTS_SHIELDS_FIXUP_FILE ${ZEPHYR_BINARY_DIR}/include/generated/shields/dts_fixup.h)
491490

492-
# Concatenate the shield fixups into a single file for easy
493-
# #include'ing
494-
foreach(f ${shield_dts_fixups})
495-
if(EXISTS ${f})
496-
file(READ ${f} contents)
497-
file(APPEND ${DTS_SHIELDS_FIXUP_FILE} "${contents}")
498-
endif()
499-
endforeach()
491+
set_ifndef(DTS_CAT_OF_FIXUP_FILES ${ZEPHYR_BINARY_DIR}/include/generated/generated_dts_board_fixups.h)
500492

501-
foreach(fixup_source
502-
DTS_BOARD_FIXUP_FILE
503-
DTS_SOC_FIXUP_FILE
504-
DTS_APP_FIXUP_FILE
505-
DTS_SHIELDS_FIXUP_FILE
493+
# Concatenate the fixups into a single header file for easy
494+
# #include'ing
495+
file(WRITE ${DTS_CAT_OF_FIXUP_FILES} "/* May only be included by generated_dts_board.h */\n\n")
496+
foreach(fixup_file
497+
${DTS_BOARD_FIXUP_FILE}
498+
${DTS_SOC_FIXUP_FILE}
499+
${DTS_APP_FIXUP_FILE}
500+
${shield_dts_fixups}
506501
)
507-
if(EXISTS ${${fixup_source}})
508-
# Add defines such that generated_dts_board.h knows which fixups
509-
# are present and where they
510-
# are. e.g. -DDTS_SOC_FIXUP_FILE=/path/to/fixup.h
511-
zephyr_compile_definitions(${fixup_source}="${${fixup_source}}")
512-
set_property(GLOBAL APPEND PROPERTY
513-
PROPERTY_LINKER_SCRIPT_DEFINES
514-
-D${fixup_source}="${${fixup_source}}"
515-
)
502+
if(EXISTS ${fixup_file})
503+
file(READ ${fixup_file} contents)
504+
file(APPEND ${DTS_CAT_OF_FIXUP_FILES} "${contents}")
516505
endif()
517506
endforeach()
518507

include/generated_dts_board.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,6 @@
1515

1616
/* The following definitions fixup the generated include */
1717

18-
#ifdef DTS_BOARD_FIXUP_FILE
19-
#include DTS_BOARD_FIXUP_FILE
20-
#endif
21-
22-
#ifdef DTS_SOC_FIXUP_FILE
23-
#include DTS_SOC_FIXUP_FILE
24-
#endif
25-
26-
#ifdef DTS_APP_FIXUP_FILE
27-
#include DTS_APP_FIXUP_FILE
28-
#endif
29-
30-
#ifdef DTS_SHIELDS_FIXUP_FILE
31-
#include DTS_SHIELDS_FIXUP_FILE
32-
#endif
18+
#include <generated_dts_board_fixups.h>
3319

3420
#endif /* GENERATED_DTS_BOARD_H */

0 commit comments

Comments
 (0)