build(cmake): add platform variant support

Some platforms offer multiple variants, targeting different but similar
physical boards. For example, the Total Compute platform currently
offers both TC1 and TC2. We'll be using this section to dictate
information that needs to be interpreted before loading the toolchain.

Change-Id: I9fe7450ab42c398a7ca42e0b2303df199fac8567
Signed-off-by: Chris Kay <chris.kay@arm.com>
This commit is contained in:
Chris Kay 2022-01-14 16:18:44 +00:00
parent 5b6770444b
commit 76d67d088a
3 changed files with 42 additions and 0 deletions

View File

@ -85,6 +85,19 @@ arm_config_option(
DEFAULT "${CMAKE_CURRENT_BINARY_DIR}/${target}"
TYPE PATH)
#
# Retrieve the list of variants for the configured platform, and let the user
# configure the variant.
#
tfa_platform_variants(variants
PLATFORM ${TFA_PLATFORM})
arm_config_option(
NAME TFA_PLATFORM_VARIANT
HELP "Platform variant to build."
STRINGS ${variants})
#
# We're done with very early setup, so we can now create the project. This will
# do some of the automatic compiler detection, which we need for setting up

View File

@ -33,6 +33,14 @@ Return the path to the platform ``<platform>`` in ``<out-var>``.
tfa_platform_target(<out-var> PLATFORM <platform>)
Return the CMake target name for the platform ``<platform>`` in ``<out-var>``.
.. command:: tfa_platform_variants
.. code-block:: cmake
tfa_platform_variants(<out-var> PLATFORM <platform>)
Return the list of variants for the platform ``<platform>`` in ``<out-var>``.
#]=======================================================================]
include_guard()
@ -182,6 +190,15 @@ tfa_json_getter(tfa_platform_metadata_target
JSON "${global-metadata}" PARENT tfa_platform_metadata
PATH "target")
tfa_json_getter(tfa_platform_metadata_variants
JSON "${global-metadata}" PARENT tfa_platform_metadata
PATH "variants")
tfa_json_getter(tfa_platform_metadata_variants_variant
JSON "${global-metadata}" PARENT tfa_platform_metadata_variants
PATH "@VARIANT@" ARGUMENTS VARIANT
ERROR_MESSAGE "No such variant `@VARIANT@` for the @PLATFORM@ platform.")
#
# External platform metadata API.
#
@ -189,3 +206,7 @@ tfa_json_getter(tfa_platform_metadata_target
tfa_json_getter(tfa_platform_target
JSON "${global-metadata}" PARENT tfa_platform_metadata_target
DECODE STRING)
tfa_json_getter(tfa_platform_variants
JSON "${global-metadata}" PARENT tfa_platform_metadata_variants
DECODE MEMBERS)

View File

@ -7,6 +7,14 @@
"target": {
"type": "string",
"pattern": "^(?![0-9])([a-z0-9]+-?)+(?<!-)$"
},
"variants": {
"additionalProperties": false,
"patternProperties": {
"^(?![0-9])([A-Z0-9][a-z0-9]*-?)+(?<!-)$": {
"type": "object"
}
}
}
}
}