cmake: make SoC optional for boards containing a single SoC
Allowing users to omit the SoC when building for a board containing a single SoC make less typing required when building. Full identifier is still supported. This means that if board 'plank' contains a single SoC 'foo', then the following input are equivalent: -DBOARD=plank -DBOARD=plank/foo When building for variants on single SoC boards, a `//` can be used to indicate SoC field and build system will insert the SoC if the board has just a single SoC, as example build the 'bar' variant for 'plank' board can be specified as: -DBOARD=plank//bar -DBOARD=plank/foo/bar The enhancement allows all boards to specify the SoC on the board without forcing users to type the SoC as part of BOARD input. As example, -DBOARD=bbc_microbit, is allowed in addition to -DBOARD=bbc_microbit/nrf52822. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
committed by
Jamie McCrae
parent
bcc06c60ae
commit
c5321c1dbe
@@ -153,7 +153,7 @@ if(NOT BOARD_DIR)
|
||||
|
||||
set(format_str "{NAME}\;{DIR}\;{HWM}\;")
|
||||
set(format_str "${format_str}{REVISION_FORMAT}\;{REVISION_DEFAULT}\;{REVISION_EXACT}\;")
|
||||
set(format_str "${format_str}{REVISIONS}\;{IDENTIFIERS}")
|
||||
set(format_str "${format_str}{REVISIONS}\;{SOCS}\;{IDENTIFIERS}")
|
||||
|
||||
execute_process(${list_boards_commands} --board=${BOARD}
|
||||
--cmakeformat=${format_str}
|
||||
@@ -166,7 +166,7 @@ if(NOT BOARD_DIR)
|
||||
endif()
|
||||
string(STRIP "${ret_board}" ret_board)
|
||||
set(single_val "NAME;DIR;HWM;REVISION_FORMAT;REVISION_DEFAULT;REVISION_EXACT")
|
||||
set(multi_val "REVISIONS;IDENTIFIERS")
|
||||
set(multi_val "REVISIONS;SOCS;IDENTIFIERS")
|
||||
cmake_parse_arguments(BOARD "" "${single_val}" "${multi_val}" ${ret_board})
|
||||
set(BOARD_DIR ${BOARD_DIR} CACHE PATH "Board directory for board (${BOARD})" FORCE)
|
||||
|
||||
@@ -220,6 +220,14 @@ elseif(HWMv2)
|
||||
endif()
|
||||
|
||||
if(BOARD_IDENTIFIERS)
|
||||
# Allow users to omit the SoC when building for a board with a single SoC.
|
||||
list(LENGTH BOARD_SOCS socs_length)
|
||||
if(NOT DEFINED BOARD_IDENTIFIER AND socs_length EQUAL 1)
|
||||
set(BOARD_IDENTIFIER "/${BOARD_SOCS}")
|
||||
elseif("${BOARD_IDENTIFIER}" MATCHES "^//.*" AND socs_length EQUAL 1)
|
||||
string(REGEX REPLACE "^//" "/${BOARD_SOCS}/" BOARD_IDENTIFIER "${BOARD_IDENTIFIER}")
|
||||
endif()
|
||||
|
||||
if(NOT ("${BOARD}${BOARD_IDENTIFIER}" IN_LIST BOARD_IDENTIFIERS))
|
||||
string(REPLACE ";" "\n" BOARD_IDENTIFIERS "${BOARD_IDENTIFIERS}")
|
||||
message(FATAL_ERROR "Board identifier `${BOARD_IDENTIFIER}` for board \
|
||||
|
||||
Reference in New Issue
Block a user