Skip to content

Commit

Permalink
cmake: improve board revision handling
Browse files Browse the repository at this point in the history
In old hw model, board revisions was handled by creation of a
revisions.cmake file. In the new hw model, board revisions are defined
as integral part of board.yml, and revision.cmake is only needed and
used for custom revision format.

Users familiar with revision.cmake in old hw model may not be aware of
this difference, therefore provide warnings if developers create a
revision.cmake that is ignored by the build system.

Also fail a build if users specify a board revision for a board which
doesn't support revision. Such scenario can easily occur in the case
where a board developer may be creating a revisions.cmake file and
then try to build for a revision specified in that file.

Signed-off-by: Torsten Rasmussen <[email protected]>
  • Loading branch information
tejlmand committed Jan 19, 2024
1 parent f29abd4 commit c2a905e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cmake/modules/boards.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ elseif(HWMv2)
if(BOARD_REVISION_FORMAT STREQUAL "custom")
include(${BOARD_DIR}/revision.cmake)
else()
if(EXISTS ${BOARD_DIR}/revision.cmake)
message(WARNING
"revision.cmake ignored, revision.cmake is only used for revision format: 'custom'"
)
endif()

string(TOUPPER "${BOARD_REVISION_FORMAT}" rev_format)
if(BOARD_REVISION_EXACT)
set(rev_exact EXACT)
Expand All @@ -226,6 +232,16 @@ elseif(HWMv2)
${rev_exact}
)
endif()
elseif(DEFINED BOARD_REVISION)
if(EXISTS ${BOARD_DIR}/revision.cmake)
message(WARNING
"revision.cmake is not used, revisions must be defined in '${BOARD_DIR}/board.yml'"
)
endif()

message(FATAL_ERROR "Invalid board revision: ${BOARD_REVISION}\n"
"Board '${BOARD}' does not define any revisions."
)
endif()

if(BOARD_IDENTIFIERS)
Expand Down

0 comments on commit c2a905e

Please sign in to comment.