cmake: additional board revision comments addressed for #29990

This commit contains some additional review comments that was posted
after board revision PR #29990 was merged.

The follow-up changes are:
- Fixed typo: REVIVISION --> REVISION
- Renaming leftover in print message:
  zephyr_check_board_revision --> board_check_revision
- Fixed regex, to allow revision 10, 20, 30, 40, etc.
- digits --> number in comment

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2020-12-16 21:07:03 +01:00 committed by Anas Nashif
parent 8e55cfab96
commit 16d66b0e1d
2 changed files with 8 additions and 8 deletions

View file

@ -208,11 +208,11 @@ list(APPEND ARCH_ROOT ${ZEPHYR_BASE})
# Check that BOARD has been provided, and that it has not changed.
zephyr_check_cache(BOARD REQUIRED)
string(FIND "${BOARD}" "@" REVIVISION_SEPARATOR_INDEX)
if(NOT (REVIVISION_SEPARATOR_INDEX EQUAL -1))
math(EXPR BOARD_REVISION_INDEX "${REVIVISION_SEPARATOR_INDEX} + 1")
string(FIND "${BOARD}" "@" REVISION_SEPARATOR_INDEX)
if(NOT (REVISION_SEPARATOR_INDEX EQUAL -1))
math(EXPR BOARD_REVISION_INDEX "${REVISION_SEPARATOR_INDEX} + 1")
string(SUBSTRING ${BOARD} ${BOARD_REVISION_INDEX} -1 BOARD_REVISION)
string(SUBSTRING ${BOARD} 0 ${REVIVISION_SEPARATOR_INDEX} BOARD)
string(SUBSTRING ${BOARD} 0 ${REVISION_SEPARATOR_INDEX} BOARD)
endif()
set(BOARD_MESSAGE "Board: ${BOARD}")

View file

@ -797,7 +797,7 @@ endfunction()
#
# FORMAT <LETTER | MAJOR.MINOR.PATCH>: Specify the revision format.
# LETTER: Revision format is a single letter from A - Z.
# MAJOR.MINOR.PATCH: Revision format is three digits, separated by `.`,
# MAJOR.MINOR.PATCH: Revision format is three numbers, separated by `.`,
# `x.y.z`. Trailing zeroes may be omitted on the
# command line, which means:
# 1.0.0 == 1.0 == 1
@ -859,10 +859,10 @@ function(board_check_revision)
if(BOARD_REV_FORMAT STREQUAL LETTER)
set(revision_regex "([A-Z])")
elseif(BOARD_REV_FORMAT MATCHES "^MAJOR\.MINOR\.PATCH$")
set(revision_regex "((0|[1-9]+)(\.[0-9]+)(\.[0-9]+))")
set(revision_regex "((0|[1-9][0-9]*)(\.[0-9]+)(\.[0-9]+))")
# We allow loose <board>@<revision> typing on command line.
# so append missing zeroes.
if(BOARD_REVISION MATCHES "((0|[1-9]+)(\.[0-9]+)?(\.[0-9]+)?)")
if(BOARD_REVISION MATCHES "((0|[1-9][0-9]*)(\.[0-9]+)?(\.[0-9]+)?)")
if(NOT CMAKE_MATCH_3)
set(BOARD_REVISION ${BOARD_REVISION}.0)
set(BOARD_REVISION ${BOARD_REVISION} PARENT_SCOPE)
@ -874,7 +874,7 @@ function(board_check_revision)
endif()
else()
message(FATAL_ERROR "Invalid format specified for \
`zephyr_check_board_revision(FORMAT <LETTER | MAJOR.MINOR.PATCH>)`")
`board_check_revision(FORMAT <LETTER | MAJOR.MINOR.PATCH>)`")
endif()
if(NOT (BOARD_REVISION MATCHES "^${revision_regex}$"))