cmake: boards: Error out if multiple boards use the same name
Detecting this requires `boards.cmake` being able to handle multi-line output from `list_boards.py`. Implement a similar line reading loop to the one used in `hwm_v2.cmake`. Failing to handle this could result in an incorrectly parsed list of valid board qualifiers. Here's the expected list for `nrf52_bsim`: - "native" and here's what would happen if two copies of that board were found: - "native\nNAME" - "nrf52_bsim" - "native" Instead of that, there would now be a proper error message listing all board directories which contain `nrf52_bsim`. Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
parent
88d8b23836
commit
4acb615c14
1 changed files with 18 additions and 0 deletions
|
@ -195,6 +195,24 @@ endif()
|
||||||
|
|
||||||
if(NOT "${ret_board}" STREQUAL "")
|
if(NOT "${ret_board}" STREQUAL "")
|
||||||
string(STRIP "${ret_board}" ret_board)
|
string(STRIP "${ret_board}" ret_board)
|
||||||
|
string(FIND "${ret_board}" "\n" idx REVERSE)
|
||||||
|
if(idx GREATER -1)
|
||||||
|
while(TRUE)
|
||||||
|
math(EXPR start "${idx} + 1")
|
||||||
|
string(SUBSTRING "${ret_board}" ${start} -1 line)
|
||||||
|
string(SUBSTRING "${ret_board}" 0 ${idx} ret_board)
|
||||||
|
|
||||||
|
cmake_parse_arguments(LIST_BOARD "" "DIR" "" ${line})
|
||||||
|
set(board_dirs "${board_dirs}\n${LIST_BOARD_DIR}")
|
||||||
|
|
||||||
|
if(idx EQUAL -1)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
string(FIND "${ret_board}" "\n" idx REVERSE)
|
||||||
|
endwhile()
|
||||||
|
message(FATAL_ERROR "Multiple boards named '${BOARD}' found in:${board_dirs}")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(single_val "NAME;DIR;HWM;REVISION_FORMAT;REVISION_DEFAULT;REVISION_EXACT")
|
set(single_val "NAME;DIR;HWM;REVISION_FORMAT;REVISION_DEFAULT;REVISION_EXACT")
|
||||||
set(multi_val "REVISIONS;SOCS;QUALIFIERS")
|
set(multi_val "REVISIONS;SOCS;QUALIFIERS")
|
||||||
cmake_parse_arguments(LIST_BOARD "" "${single_val}" "${multi_val}" ${ret_board})
|
cmake_parse_arguments(LIST_BOARD "" "${single_val}" "${multi_val}" ${ret_board})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue