cmake: Fix shield bug when BOARD_ROOT is a list

Fix bug where SHIELDS would be marked as "not found" in the
NOT_FOUND_SHIELD_LIST when they were present, just not in the first
BOARD root in the BOARD_ROOT list.

Instead of marking shields in the NOT_FOUND_SHIELD_LIST, we (continue)
popping shields from SHIELD and check if there are any shields left in
SHIELD.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2020-03-19 08:45:53 -07:00 committed by Carles Cufí
commit a8e90cbfb3

View file

@ -303,69 +303,70 @@ foreach(root ${BOARD_ROOT})
if(DEFINED SHIELD) if(DEFINED SHIELD)
foreach(s ${SHIELD_AS_LIST}) foreach(s ${SHIELD_AS_LIST})
list(REMOVE_ITEM SHIELD ${s})
list(FIND SHIELD_LIST ${s} _idx) list(FIND SHIELD_LIST ${s} _idx)
if (NOT _idx EQUAL -1) if (_idx EQUAL -1)
list(GET shields_refs_list ${_idx} s_path) continue()
get_filename_component(s_dir ${s_path} DIRECTORY) endif()
# if shield config flag is on, add shield overlay to the shield overlays list(REMOVE_ITEM SHIELD ${s})
# list and dts_fixup file to the shield fixup file
list(GET shields_refs_list ${_idx} s_path)
get_filename_component(s_dir ${s_path} DIRECTORY)
# if shield config flag is on, add shield overlay to the shield overlays
# list and dts_fixup file to the shield fixup file
list(APPEND
shield_dts_files
${shield_dir}/${s_path}
)
list(APPEND
shield_dts_fixups
${shield_dir}/${s_dir}/dts_fixup.h
)
# search for shield/boards/board.overlay file
if(EXISTS ${shield_dir}/${s_dir}/boards/${BOARD}.overlay)
# add shield/board overlay to the shield overlays list
list(APPEND list(APPEND
shield_dts_files shield_dts_files
${shield_dir}/${s_path} ${shield_dir}/${s_dir}/boards/${BOARD}.overlay
) )
endif()
# search for shield/boards/shield/board.overlay file
if(EXISTS ${shield_dir}/${s_dir}/boards/${s}/${BOARD}.overlay)
# add shield/board overlay to the shield overlays list
list(APPEND list(APPEND
shield_dts_fixups shield_dts_files
${shield_dir}/${s_dir}/dts_fixup.h ${shield_dir}/${s_dir}/boards/${s}/${BOARD}.overlay
)
# search for shield/boards/board.overlay file
if(EXISTS ${shield_dir}/${s_dir}/boards/${BOARD}.overlay)
# add shield/board overlay to the shield overlays list
list(APPEND
shield_dts_files
${shield_dir}/${s_dir}/boards/${BOARD}.overlay
) )
endif() endif()
# search for shield/boards/shield/board.overlay file # search for shield/shield.conf file
if(EXISTS ${shield_dir}/${s_dir}/boards/${s}/${BOARD}.overlay) if(EXISTS ${shield_dir}/${s_dir}/${s}.conf)
# add shield/board overlay to the shield overlays list # add shield.conf to the shield config list
list(APPEND list(APPEND
shield_dts_files shield_conf_files
${shield_dir}/${s_dir}/boards/${s}/${BOARD}.overlay ${shield_dir}/${s_dir}/${s}.conf
) )
endif() endif()
# search for shield/shield.conf file # search for shield/boards/board.conf file
if(EXISTS ${shield_dir}/${s_dir}/${s}.conf) if(EXISTS ${shield_dir}/${s_dir}/boards/${BOARD}.conf)
# add shield.conf to the shield config list # add HW specific board.conf to the shield config list
list(APPEND list(APPEND
shield_conf_files shield_conf_files
${shield_dir}/${s_dir}/${s}.conf ${shield_dir}/${s_dir}/boards/${BOARD}.conf
) )
endif() endif()
# search for shield/boards/board.conf file # search for shield/boards/shield/board.conf file
if(EXISTS ${shield_dir}/${s_dir}/boards/${BOARD}.conf) if(EXISTS ${shield_dir}/${s_dir}/boards/${s}/${BOARD}.conf)
# add HW specific board.conf to the shield config list # add HW specific board.conf to the shield config list
list(APPEND list(APPEND
shield_conf_files shield_conf_files
${shield_dir}/${s_dir}/boards/${BOARD}.conf ${shield_dir}/${s_dir}/boards/${s}/${BOARD}.conf
) )
endif()
# search for shield/boards/shield/board.conf file
if(EXISTS ${shield_dir}/${s_dir}/boards/${s}/${BOARD}.conf)
# add HW specific board.conf to the shield config list
list(APPEND
shield_conf_files
${shield_dir}/${s_dir}/boards/${s}/${BOARD}.conf
)
endif()
else()
list(APPEND NOT_FOUND_SHIELD_LIST ${s})
endif() endif()
endforeach() endforeach()
endif() endif()
@ -378,8 +379,8 @@ if(NOT BOARD_DIR)
message(FATAL_ERROR "Invalid usage") message(FATAL_ERROR "Invalid usage")
endif() endif()
if(DEFINED SHIELD AND DEFINED NOT_FOUND_SHIELD_LIST) if(DEFINED SHIELD AND NOT (SHIELD STREQUAL ""))
foreach (s ${NOT_FOUND_SHIELD_LIST}) foreach (s ${SHIELD})
message("No shield named '${s}' found") message("No shield named '${s}' found")
endforeach() endforeach()
print_usage() print_usage()