cmake: Fix the generation of fixup files

A recent change in how the fixup mechanism works caused several
regressions. See
https://github.com/zephyrproject-rtos/zephyr/pull/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 <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2019-01-28 13:40:50 +01:00 committed by Anas Nashif
parent 94e02794f3
commit 361fdaac1a
2 changed files with 13 additions and 38 deletions

View file

@ -487,32 +487,21 @@ endforeach()
set_ifndef( DTS_BOARD_FIXUP_FILE ${BOARD_DIR}/dts_fixup.h) set_ifndef( DTS_BOARD_FIXUP_FILE ${BOARD_DIR}/dts_fixup.h)
set_ifndef( DTS_SOC_FIXUP_FILE ${SOC_DIR}/${ARCH}/${SOC_PATH}/dts_fixup.h) set_ifndef( DTS_SOC_FIXUP_FILE ${SOC_DIR}/${ARCH}/${SOC_PATH}/dts_fixup.h)
set( DTS_APP_FIXUP_FILE ${APPLICATION_SOURCE_DIR}/dts_fixup.h) set( DTS_APP_FIXUP_FILE ${APPLICATION_SOURCE_DIR}/dts_fixup.h)
set_ifndef(DTS_SHIELDS_FIXUP_FILE ${ZEPHYR_BINARY_DIR}/include/generated/shields/dts_fixup.h)
# Concatenate the shield fixups into a single file for easy set_ifndef(DTS_CAT_OF_FIXUP_FILES ${ZEPHYR_BINARY_DIR}/include/generated/generated_dts_board_fixups.h)
# Concatenate the fixups into a single header file for easy
# #include'ing # #include'ing
foreach(f ${shield_dts_fixups}) file(WRITE ${DTS_CAT_OF_FIXUP_FILES} "/* May only be included by generated_dts_board.h */\n\n")
if(EXISTS ${f}) foreach(fixup_file
file(READ ${f} contents) ${DTS_BOARD_FIXUP_FILE}
file(APPEND ${DTS_SHIELDS_FIXUP_FILE} "${contents}") ${DTS_SOC_FIXUP_FILE}
endif() ${DTS_APP_FIXUP_FILE}
endforeach() ${shield_dts_fixups}
foreach(fixup_source
DTS_BOARD_FIXUP_FILE
DTS_SOC_FIXUP_FILE
DTS_APP_FIXUP_FILE
DTS_SHIELDS_FIXUP_FILE
) )
if(EXISTS ${${fixup_source}}) if(EXISTS ${fixup_file})
# Add defines such that generated_dts_board.h knows which fixups file(READ ${fixup_file} contents)
# are present and where they file(APPEND ${DTS_CAT_OF_FIXUP_FILES} "${contents}")
# are. e.g. -DDTS_SOC_FIXUP_FILE=/path/to/fixup.h
zephyr_compile_definitions(${fixup_source}="${${fixup_source}}")
set_property(GLOBAL APPEND PROPERTY
PROPERTY_LINKER_SCRIPT_DEFINES
-D${fixup_source}="${${fixup_source}}"
)
endif() endif()
endforeach() endforeach()

View file

@ -15,20 +15,6 @@
/* The following definitions fixup the generated include */ /* The following definitions fixup the generated include */
#ifdef DTS_BOARD_FIXUP_FILE #include <generated_dts_board_fixups.h>
#include DTS_BOARD_FIXUP_FILE
#endif
#ifdef DTS_SOC_FIXUP_FILE
#include DTS_SOC_FIXUP_FILE
#endif
#ifdef DTS_APP_FIXUP_FILE
#include DTS_APP_FIXUP_FILE
#endif
#ifdef DTS_SHIELDS_FIXUP_FILE
#include DTS_SHIELDS_FIXUP_FILE
#endif
#endif /* GENERATED_DTS_BOARD_H */ #endif /* GENERATED_DTS_BOARD_H */