eng: Improve build option default values

Merge "default" and "default-by-variant" attributes.  Use an enabled-by
expression to select the default value.
This commit is contained in:
Sebastian Huber 2023-01-17 15:14:02 +01:00
parent dc2ea301ea
commit f3811f29a8

View File

@ -714,8 +714,6 @@ option. The following explicit attributes are mandatory:
* ``default`` * ``default``
* ``default-by-variant``
* ``description`` * ``description``
The explicit attributes for this type are: The explicit attributes for this type are:
@ -729,19 +727,11 @@ actions
actions are carried out during the configure command execution. actions are carried out during the configure command execution.
default default
The attribute value shall be a :ref:`SpecTypeBuildOptionValue`. It shall be
the default value of the option if no variant-specific default value is
specified. Use ``null`` to specify that no default value exits. The
variant-specific default values may be specified by the
``default-by-variant`` attribute.
default-by-variant
The attribute value shall be a list. Each list element shall be a The attribute value shall be a list. Each list element shall be a
:ref:`SpecTypeBuildOptionDefaultByVariant`. The list is checked two times :ref:`SpecTypeBuildOptionDefaultValue`. It shall be the list of default
and processed from top to bottom. Firstly, the base BSP name is used to values of the option. When a default value is needed, the first value on
match with a variant. Secondly, the BSP family name prefixed by ``bsps/`` the list which is enabled according to the enabled set is choosen. If no
is used to match with a variant. If a matching variant is found, then the value is enabled, then the default value is ``null``.
processing stops.
description description
The attribute value shall be an optional string. It shall be the The attribute value shall be an optional string. It shall be the
@ -766,17 +756,17 @@ Please have a look at the following example:
- define: null - define: null
build-type: option build-type: option
copyrights: copyrights:
- Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de) - Copyright (C) 2020, 2022 embedded brains GmbH (http://www.embedded-brains.de)
default: 115200 default:
default-by-variant: - enabled-by:
- value: 9600
variants:
- bsps/powerpc/motorola_powerpc - bsps/powerpc/motorola_powerpc
- m68k/m5484FireEngine - m68k/m5484FireEngine
- powerpc/hsc_cm01 - powerpc/hsc_cm01
- value: 19200 value: 9600
variants: - enabled-by: m68k/COBRA5475
- m68k/COBRA5475 value: 19200
- enabled-by: true
value: 115200
description: | description: |
Default baud for console and other serial devices. Default baud for console and other serial devices.
enabled-by: true enabled-by: true
@ -3423,22 +3413,20 @@ This type is used by the following types:
* :ref:`SpecTypeBuildOptionAction` * :ref:`SpecTypeBuildOptionAction`
.. _SpecTypeBuildOptionDefaultByVariant: .. _SpecTypeBuildOptionDefaultValue:
Build Option Default by Variant Build Option Default Value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
This set of attributes specifies build option default values by variant. All This set of attributes specifies a build option default value. All explicit
explicit attributes shall be specified. The explicit attributes for this type attributes shall be specified. The explicit attributes for this type are:
are:
enabled-by
The attribute value shall be an :ref:`SpecTypeEnabledByExpression`.
value value
The attribute value shall be a :ref:`SpecTypeBuildOptionValue`. It value The attribute value shall be a :ref:`SpecTypeBuildOptionValue`. Its value
shall be the default value for the matching variants. shall be the default value for the associated enabled-by expression.
variants
The attribute value shall be a list of strings. It shall be a list of
Python regular expression matching with the desired variants.
This type is used by the following types: This type is used by the following types:
@ -3495,9 +3483,7 @@ This type is used by the following types:
* :ref:`SpecTypeBuildOptionAction` * :ref:`SpecTypeBuildOptionAction`
* :ref:`SpecTypeBuildOptionDefaultByVariant` * :ref:`SpecTypeBuildOptionDefaultValue`
* :ref:`SpecTypeBuildOptionItemType`
.. _SpecTypeBuildSource: .. _SpecTypeBuildSource:
@ -3681,6 +3667,8 @@ This type is used by the following types:
* :ref:`SpecTypeActionRequirementTransition` * :ref:`SpecTypeActionRequirementTransition`
* :ref:`SpecTypeBuildOptionDefaultValue`
* :ref:`SpecTypeEnabledByExpression` * :ref:`SpecTypeEnabledByExpression`
* :ref:`SpecTypeInterfaceIncludeLinkRole` * :ref:`SpecTypeInterfaceIncludeLinkRole`