build: enable shields dir treatment

In dts.cmake, build shield list. For each shield, check if
associate KCONFIG is enabled and if it is, add matching files
to following new cmake variables:
-DTC_SHIELD_OVERLAY_FILE
-DTC_SHIELD_FIXUP
Then, consume these variables when needed.

Shield overlay is conceived as the very first overlay applied
to the board dts. It intends to build a new board that should
then behave as any other board versus common or user's overlay.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2018-03-15 17:21:35 +01:00 committed by Anas Nashif
commit 6af514b67f
3 changed files with 47 additions and 1 deletions

View file

@ -18,6 +18,8 @@
# Note: $ARCH and $BOARD_DIR might be glob patterns. # Note: $ARCH and $BOARD_DIR might be glob patterns.
source "$(BOARD_DIR)/Kconfig.defconfig" source "$(BOARD_DIR)/Kconfig.defconfig"
source "boards/shields/*/Kconfig.defconfig"
source "$(SOC_DIR)/$(ARCH)/*/Kconfig.defconfig" source "$(SOC_DIR)/$(ARCH)/*/Kconfig.defconfig"
source "boards/Kconfig" source "boards/Kconfig"

View file

@ -29,3 +29,7 @@ endmenu
menu "Shields" menu "Shields"
source "boards/shields/Kconfig" source "boards/shields/Kconfig"
endmenu endmenu
menu "Shields"
source "boards/shields/*/Kconfig.shield"
endmenu

View file

@ -14,15 +14,55 @@ set_ifndef(DTS_SOURCE ${BOARD_ROOT}/boards/${ARCH}/${BOARD_FAMILY}/${BOARD}.dts)
set_ifndef(DTS_COMMON_OVERLAYS ${ZEPHYR_BASE}/dts/common/common.dts) set_ifndef(DTS_COMMON_OVERLAYS ${ZEPHYR_BASE}/dts/common/common.dts)
set_ifndef(DTS_APP_BINDINGS ${APPLICATION_SOURCE_DIR}/dts/bindings) set_ifndef(DTS_APP_BINDINGS ${APPLICATION_SOURCE_DIR}/dts/bindings)
#Parse boards/shields to generate the shield list
set(shield_dir ${ZEPHYR_BASE}/boards/shields)
# Match the .overlay files in the shield directories to make sure we are
# finding shields, e.g. x_nucleo_iks01a1/x_nucleo_iks01a1.overlay
file(GLOB_RECURSE shields_refs_list
RELATIVE ${shield_dir}
${shield_dir}/*/*.overlay
)
# The above gives a list like
# x_nucleo_iks01a1/x_nucleo_iks01a1.overlay;x_nucleo_iks01a2/x_nucleo_iks01a2.overlay
# we construct a list of shield names by extracting file name and
# removing the extension.
foreach(shield_path ${shields_refs_list})
get_filename_component(shield ${shield_path} NAME_WE)
# Generate CONFIG flags matching each shield
string(TOUPPER "CONFIG_SHIELD_${shield}" shield_config)
if(${shield_config})
# if shield config flag is on, add shield overlay to the shield overlays
# list and dts.fixup file to the shield fixup file
set(DTC_SHIELD_OVERLAY_FILE ${DTC_SHIELD_OVERLAY_FILE} ${shield_dir}/${shield_path})
set(DTC_SHIELD_FIXUP ${DTC_SHIELD_FIXUP} ${shield_dir}/${shield}/dts.fixup)
endif()
endforeach()
message(STATUS "Generating zephyr/include/generated/generated_dts_board.h") message(STATUS "Generating zephyr/include/generated/generated_dts_board.h")
if(CONFIG_HAS_DTS) if(CONFIG_HAS_DTS)
if(DTC_SHIELD_OVERLAY_FILE)
# Convert from space-separated files into file list
string(REPLACE " " ";" DTC_SHIELD_OVERLAY_FILES_AS_LIST ${DTC_SHIELD_OVERLAY_FILE})
endif()
if(DTC_OVERLAY_FILE) if(DTC_OVERLAY_FILE)
# Convert from space-separated files into file list # Convert from space-separated files into file list
string(REPLACE " " ";" DTC_OVERLAY_FILE_AS_LIST ${DTC_OVERLAY_FILE}) string(REPLACE " " ";" DTC_OVERLAY_FILE_AS_LIST ${DTC_OVERLAY_FILE})
endif() endif()
# Prepend shield overlays
set(DTC_OVERLAY_FILE_AS_LIST ${DTC_SHIELD_OVERLAY_FILES_AS_LIST} ${DTC_OVERLAY_FILE_AS_LIST})
# Prepend common overlays # Prepend common overlays
set(DTC_OVERLAY_FILE_AS_LIST ${DTS_COMMON_OVERLAYS} ${DTC_OVERLAY_FILE_AS_LIST}) set(DTC_OVERLAY_FILE_AS_LIST ${DTS_COMMON_OVERLAYS} ${DTC_OVERLAY_FILE_AS_LIST})
@ -98,7 +138,7 @@ if(CONFIG_HAS_DTS)
set(DTS_APP_FIXUP ${APPLICATION_SOURCE_DIR}/dts.fixup) set(DTS_APP_FIXUP ${APPLICATION_SOURCE_DIR}/dts.fixup)
endif() endif()
set(DTS_FIXUPS ${DTS_SOC_FIXUP} ${DTS_BOARD_FIXUP} ${DTS_APP_FIXUP}) set(DTS_FIXUPS ${DTS_SOC_FIXUP} ${DTS_BOARD_FIXUP} ${DTC_SHIELD_FIXUP} ${DTS_APP_FIXUP})
if(NOT "${DTS_FIXUPS}" STREQUAL "") if(NOT "${DTS_FIXUPS}" STREQUAL "")
set(DTS_FIXUPS --fixup ${DTS_FIXUPS}) set(DTS_FIXUPS --fixup ${DTS_FIXUPS})
endif() endif()