@@ -40,75 +40,76 @@ endif()
4040# After processing all shields, only invalid shields will be left in this list.
4141set (SHIELD-NOTFOUND ${SHIELD_AS_LIST} )
4242
43- # Use BOARD to search for a '_defconfig' file.
44- # e.g. zephyr/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig.
45- # When found, use that path to infer the ARCH we are building for.
46- foreach (root ${BOARD_ROOT} )
47- set (shield_dir ${root} /boards/shields)
48- # Match the Kconfig.shield files in the shield directories to make sure we are
49- # finding shields, e.g. x_nucleo_iks01a1/Kconfig.shield
50- file (GLOB_RECURSE shields_refs_list ${shield_dir} /*/Kconfig.shield)
51-
52- # The above gives a list like
53- # x_nucleo_iks01a1/Kconfig.shield;x_nucleo_iks01a2/Kconfig.shield
54- # we construct a list of shield names by extracting the folder and find
55- # and overlay files in there. Each overlay corresponds to a shield.
56- # We obtain the shield name by removing the overlay extension.
57- unset (SHIELD_LIST)
58- foreach (shields_refs ${shields_refs_list} )
59- get_filename_component (shield_path ${shields_refs} DIRECTORY )
60- file (GLOB shield_overlays RELATIVE ${shield_path} ${shield_path} /*.overlay)
61- foreach (overlay ${shield_overlays} )
62- get_filename_component (shield ${overlay} NAME_WE )
63- list (APPEND SHIELD_LIST ${shield} )
64- set (SHIELD_DIR_${shield} ${shield_path} )
43+ if (DEFINED SHIELD)
44+ foreach (s ${SHIELD_AS_LIST} )
45+
46+ # Use BOARD to search for a '_defconfig' file.
47+ # e.g. zephyr/boards/arm/96b_carbon_nrf51/96b_carbon_nrf51_defconfig.
48+ # When found, use that path to infer the ARCH we are building for.
49+ foreach (root ${BOARD_ROOT} )
50+ set (shield_dir ${root} /boards/shields)
51+ # Match the Kconfig.shield files in the shield directories to make sure we are
52+ # finding shields, e.g. x_nucleo_iks01a1/Kconfig.shield
53+ file (GLOB_RECURSE shields_refs_list ${shield_dir} /*/Kconfig.shield)
54+
55+ # The above gives a list like
56+ # x_nucleo_iks01a1/Kconfig.shield;x_nucleo_iks01a2/Kconfig.shield
57+ # we construct a list of shield names by extracting the folder and find
58+ # and overlay files in there. Each overlay corresponds to a shield.
59+ # We obtain the shield name by removing the overlay extension.
60+ unset (SHIELD_LIST)
61+ foreach (shields_refs ${shields_refs_list} )
62+ get_filename_component (shield_path ${shields_refs} DIRECTORY )
63+ file (GLOB shield_overlays RELATIVE ${shield_path} ${shield_path} /*.overlay)
64+ foreach (overlay ${shield_overlays} )
65+ get_filename_component (shield ${overlay} NAME_WE )
66+ list (APPEND SHIELD_LIST ${shield} )
67+ set (SHIELD_DIR_${shield} ${shield_path} )
68+ endforeach ()
6569 endforeach ()
66- endforeach ()
6770
68- if (DEFINED SHIELD)
69- foreach (s ${SHIELD_AS_LIST} )
70- if (NOT ${s} IN_LIST SHIELD_LIST)
71- continue ()
72- endif ()
71+ if (NOT ${s} IN_LIST SHIELD_LIST)
72+ continue ()
73+ endif ()
7374
74- if (BOARD_DIR AND NOT (${root} STREQUAL ${ZEPHYR_BASE} ))
75- set (SHIELD_${s} _OUT_OF_TREE 1)
76- endif ()
75+ if (BOARD_DIR AND NOT (${root} STREQUAL ${ZEPHYR_BASE} ))
76+ set (SHIELD_${s} _OUT_OF_TREE 1)
77+ endif ()
7778
78- list (REMOVE_ITEM SHIELD-NOTFOUND ${s} )
79+ list (REMOVE_ITEM SHIELD-NOTFOUND ${s} )
7980
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- )
81+ # if shield config flag is on, add shield overlay to the shield overlays
82+ # list and dts_fixup file to the shield fixup file
83+ list (APPEND
84+ shield_dts_files
85+ ${SHIELD_DIR_${s} }/${s} .overlay
86+ )
87+
88+ list (APPEND
89+ SHIELD_DIRS
90+ ${SHIELD_DIR_${s} }
91+ )
8692
93+ # search for shield/shield.conf file
94+ if (EXISTS ${SHIELD_DIR_${s} }/${s} .conf)
95+ # add shield.conf to the shield config list
8796 list (APPEND
88- SHIELD_DIRS
89- ${SHIELD_DIR_${s} }
97+ shield_conf_files
98+ ${SHIELD_DIR_${s} }/ ${s} .conf
9099 )
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- )
100+ endif ()
101+
102+ zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards
103+ DTS shield_dts_files
104+ KCONF shield_conf_files
105+ )
106+ zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards/${s}
107+ DTS shield_dts_files
108+ KCONF shield_conf_files
109+ )
109110 endforeach ()
110- endif ()
111- endforeach ()
111+ endforeach ()
112+ endif ()
112113
113114# Prepare shield usage command printing.
114115# This command prints all shields in the system in the following cases:
0 commit comments