@@ -43,6 +43,7 @@ set(SHIELD-NOTFOUND ${SHIELD_AS_LIST})
4343# Use BOARD to search for a '_defconfig' file.
4444# e.g. zephyr/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig.
4545# When found, use that path to infer the ARCH we are building for.
46+ unset (SHIELD_LIST)
4647foreach (root ${BOARD_ROOT} )
4748 set (shield_dir ${root} /boards/shields)
4849 # Match the Kconfig.shield files in the shield directories to make sure we are
@@ -54,61 +55,62 @@ foreach(root ${BOARD_ROOT})
5455 # we construct a list of shield names by extracting the folder and find
5556 # and overlay files in there. Each overlay corresponds to a shield.
5657 # We obtain the shield name by removing the overlay extension.
57- unset (SHIELD_LIST)
5858 foreach (shields_refs ${shields_refs_list} )
5959 get_filename_component (shield_path ${shields_refs} DIRECTORY )
6060 file (GLOB shield_overlays RELATIVE ${shield_path} ${shield_path} /*.overlay)
6161 foreach (overlay ${shield_overlays} )
6262 get_filename_component (shield ${overlay} NAME_WE )
6363 list (APPEND SHIELD_LIST ${shield} )
6464 set (SHIELD_DIR_${shield} ${shield_path} )
65+ set (SHIELD_ROOT_${shield} ${root} )
66+
6567 endforeach ()
6668 endforeach ()
69+ endforeach ()
6770
68- if (DEFINED SHIELD)
69- foreach (s ${SHIELD_AS_LIST} )
70- if (NOT ${s} IN_LIST SHIELD_LIST)
71- continue ()
72- endif ()
73-
74- if (BOARD_DIR AND NOT (${root} STREQUAL ${ZEPHYR_BASE} ))
75- set (SHIELD_${s} _OUT_OF_TREE 1)
76- endif ()
77-
78- list (REMOVE_ITEM SHIELD-NOTFOUND ${s} )
71+ if (DEFINED SHIELD)
72+ foreach (s ${SHIELD_AS_LIST} )
73+ if (NOT ${s} IN_LIST SHIELD_LIST)
74+ continue ()
75+ endif ()
76+
77+ if (BOARD_DIR AND NOT (SHIELD_ROOT_${s} STREQUAL ${ZEPHYR_BASE} ))
78+ set (SHIELD_${s} _OUT_OF_TREE 1)
79+ endif ()
80+
81+ list (REMOVE_ITEM SHIELD-NOTFOUND ${s} )
82+
83+ # if shield config flag is on, add shield overlay to the shield overlays
84+ # list and dts_fixup file to the shield fixup file
85+ list (APPEND
86+ shield_dts_files
87+ ${SHIELD_DIR_${s} }/${s} .overlay
88+ )
7989
80- # if shield config flag is on, add shield overlay to the shield overlays
81- # list and dts_fixup file to the shield fixup file
82- list (APPEND
83- shield_dts_files
84- ${SHIELD_DIR_${s} }/${s} .overlay
85- )
90+ list (APPEND
91+ SHIELD_DIRS
92+ ${SHIELD_DIR_${s} }
93+ )
8694
95+ # search for shield/shield.conf file
96+ if (EXISTS ${SHIELD_DIR_${s} }/${s} .conf)
97+ # add shield.conf to the shield config list
8798 list (APPEND
88- SHIELD_DIRS
89- ${SHIELD_DIR_${s} }
99+ shield_conf_files
100+ ${SHIELD_DIR_${s} }/ ${s} .conf
90101 )
91-
92- # search for shield/shield.conf file
93- if (EXISTS ${SHIELD_DIR_${s} }/${s} .conf)
94- # add shield.conf to the shield config list
95- list (APPEND
96- shield_conf_files
97- ${SHIELD_DIR_${s} }/${s} .conf
98- )
99- endif ()
100-
101- zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards
102- DTS shield_dts_files
103- KCONF shield_conf_files
104- )
105- zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards/${s}
106- DTS shield_dts_files
107- KCONF shield_conf_files
108- )
109- endforeach ()
110- endif ()
111- endforeach ()
102+ endif ()
103+
104+ zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards
105+ DTS shield_dts_files
106+ KCONF shield_conf_files
107+ )
108+ zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards/${s}
109+ DTS shield_dts_files
110+ KCONF shield_conf_files
111+ )
112+ endforeach ()
113+ endif ()
112114
113115# Prepare shield usage command printing.
114116# This command prints all shields in the system in the following cases:
0 commit comments