@@ -36,13 +36,16 @@ include(python)
3636# Check that SHIELD has not changed.
3737zephyr_check_cache(SHIELD WATCH)
3838
39+ if (NOT DEFINED SHIELD)
40+ # No shields required for the build, skip unnecessary work
41+ return ()
42+ endif ()
43+
3944if (SHIELD)
4045 message (STATUS "Shield(s): ${SHIELD} " )
4146endif ()
4247
43- if (DEFINED SHIELD)
44- string (REPLACE " " ";" SHIELD_AS_LIST "${SHIELD} " )
45- endif ()
48+ string (REPLACE " " ";" SHIELD_AS_LIST "${SHIELD} " )
4649# SHIELD-NOTFOUND is a real CMake list, from which valid shields can be popped.
4750# After processing all shields, only invalid shields will be left in this list.
4851set (SHIELD-NOTFOUND ${SHIELD_AS_LIST} )
@@ -85,56 +88,54 @@ if(shields_length GREATER 0)
8588endif ()
8689
8790# Process shields in-order
88- if (DEFINED SHIELD)
89- foreach (s ${SHIELD_AS_LIST} )
90- if (NOT ${s} IN_LIST SHIELD_LIST)
91- continue ()
92- endif ()
91+ foreach (s ${SHIELD_AS_LIST} )
92+ if (NOT ${s} IN_LIST SHIELD_LIST)
93+ continue ()
94+ endif ()
9395
94- list (REMOVE_ITEM SHIELD-NOTFOUND ${s} )
96+ list (REMOVE_ITEM SHIELD-NOTFOUND ${s} )
9597
96- # Add <shield>.overlay to the shield_dts_files output variable.
97- list (APPEND
98- shield_dts_files
99- ${SHIELD_DIR_${s} }/${s} .overlay
100- )
98+ # Add <shield>.overlay to the shield_dts_files output variable.
99+ list (APPEND
100+ shield_dts_files
101+ ${SHIELD_DIR_${s} }/${s} .overlay
102+ )
103+
104+ # Add the shield's directory to the SHIELD_DIRS output variable.
105+ list (APPEND
106+ SHIELD_DIRS
107+ ${SHIELD_DIR_${s} }
108+ )
101109
102- # Add the shield's directory to the SHIELD_DIRS output variable.
110+ include (${SHIELD_DIR_${s} }/pre_dt_shield.cmake OPTIONAL )
111+
112+ # Search for shield/shield.conf file
113+ if (EXISTS ${SHIELD_DIR_${s} }/${s} .conf)
103114 list (APPEND
104- SHIELD_DIRS
105- ${SHIELD_DIR_${s} }
115+ shield_conf_files
116+ ${SHIELD_DIR_${s} }/ ${s} .conf
106117 )
118+ endif ()
107119
108- include (${SHIELD_DIR_${s} }/pre_dt_shield.cmake OPTIONAL )
109-
110- # Search for shield/shield.conf file
111- if (EXISTS ${SHIELD_DIR_${s} }/${s} .conf)
112- list (APPEND
113- shield_conf_files
114- ${SHIELD_DIR_${s} }/${s} .conf
115- )
116- endif ()
117-
118- # Add board-specific .conf and .overlay files to their
119- # respective output variables.
120- zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards
121- DTS shield_dts_files
122- KCONF shield_conf_files
123- )
124- zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards/${s}
125- DTS shield_dts_files
126- KCONF shield_conf_files
127- )
128- endforeach ()
129- endif ()
120+ # Add board-specific .conf and .overlay files to their
121+ # respective output variables.
122+ zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards
123+ DTS shield_dts_files
124+ KCONF shield_conf_files
125+ )
126+ zephyr_file(CONF_FILES ${SHIELD_DIR_${s} }/boards/${s}
127+ DTS shield_dts_files
128+ KCONF shield_conf_files
129+ )
130+ endforeach ()
130131
131132# Prepare shield usage command printing.
132133# This command prints all shields in the system in the following cases:
133134# - User specifies an invalid SHIELD
134135# - User invokes '<build-command> shields' target
135136list (SORT SHIELD_LIST)
136137
137- if (DEFINED SHIELD AND NOT (SHIELD-NOTFOUND STREQUAL "" ))
138+ if (NOT (SHIELD-NOTFOUND STREQUAL "" ))
138139 # Convert the list to pure string with newlines for printing.
139140 string (REPLACE ";" "\n " shield_string "${SHIELD_LIST} " )
140141
0 commit comments