Skip to content

Commit a5895d6

Browse files
Jordan Yatescarlescufi
authored andcommitted
cmake: extensions: board revisions can be optional
Add a new option to `board_check_revision` that can make specifying a board revision optional. This makes it easier to work with boards that can come in a base variant with extensions. For example Fanstel BLE modules that come with/without power amplifiers. Signed-off-by: Jordan Yates <[email protected]>
1 parent 3bc694d commit a5895d6

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

cmake/modules/extensions.cmake

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,11 @@ endfunction()
863863
# command line, which means:
864864
# 1.0.0 == 1.0 == 1
865865
#
866+
# OPTIONAL: Revision specifier is optional. If revision is not provided the base
867+
# board will be used. If both `EXACT` and `OPTIONAL` are given, then
868+
# specifying the revision is optional, but if it is given then the
869+
# `EXACT` requirements apply. Mutually exclusive with `DEFAULT_REVISION`.
870+
#
866871
# EXACT: Revision is required to be an exact match. As example, available revisions are:
867872
# 0.1.0 and 0.3.0, and user provides 0.2.0, then an error is reported
868873
# when `EXACT` is given.
@@ -890,15 +895,21 @@ endfunction()
890895
# will be used as a valid revision for the board.
891896
#
892897
function(board_check_revision)
893-
set(options EXACT)
898+
set(options OPTIONAL EXACT)
894899
set(single_args FORMAT DEFAULT_REVISION HIGHEST_REVISION)
895900
set(multi_args VALID_REVISIONS)
896901
cmake_parse_arguments(BOARD_REV "${options}" "${single_args}" "${multi_args}" ${ARGN})
897902

898903
string(TOUPPER ${BOARD_REV_FORMAT} BOARD_REV_FORMAT)
899904

905+
if(DEFINED BOARD_REV_DEFAULT_REVISION AND BOARD_REV_OPTIONAL)
906+
message(FATAL_ERROR "Arguments BOARD_REVISION and OPTIONAL are mutually exclusive")
907+
endif()
908+
900909
if(NOT DEFINED BOARD_REVISION)
901-
if(DEFINED BOARD_REV_DEFAULT_REVISION)
910+
if(BOARD_REV_OPTIONAL)
911+
return()
912+
elseif(DEFINED BOARD_REV_DEFAULT_REVISION)
902913
set(BOARD_REVISION ${BOARD_REV_DEFAULT_REVISION})
903914
set(BOARD_REVISION ${BOARD_REVISION} PARENT_SCOPE)
904915
else()

doc/hardware/porting/board_porting.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ board_check_revision() details
695695
.. code-block:: cmake
696696
697697
board_check_revision(FORMAT <LETTER | NUMBER | MAJOR.MINOR.PATCH>
698-
[EXACT]
698+
[OPTIONAL EXACT]
699699
[DEFAULT_REVISION <revision>]
700700
[HIGHEST_REVISION <revision>]
701701
[VALID_REVISIONS <revision> [<revision> ...]]
@@ -712,6 +712,12 @@ This function supports the following arguments:
712712
ambiguity, so only :file:`<board>_1_0_0.conf` and
713713
:file:`<board>_1_0_0.overlay` are allowed.
714714

715+
* ``OPTIONAL``: if given, a revision is not required to be specified.
716+
If the revision is not supplied, the base board is used with no overlays.
717+
Can be combined with ``EXACT``, in which case providing the revision is
718+
optional, but if given the ``EXACT`` rules apply. Mutually exclusive with
719+
``DEFAULT_REVISION``.
720+
715721
* ``EXACT``: if given, the revision is required to be an exact match.
716722
Otherwise, the closest matching revision not greater than the user's choice
717723
will be selected.

0 commit comments

Comments
 (0)