diff options
author | Chris Kay <chris.kay@arm.com> | 2022-01-14 16:18:44 +0000 |
---|---|---|
committer | Chris Kay <chris.kay@arm.com> | 2022-01-31 12:15:57 +0000 |
commit | 76d67d088a783dc06dad2acc5a66bfa86050b935 (patch) | |
tree | d4b320e0aa0f75c08ffb4ccbdb4ba5d65d7e975e | |
parent | 5b6770444b3bd8d02786602ca18194b25e1083fb (diff) | |
download | arm-trusted-firmware-topics/cmake.tar.gz |
build(cmake): add platform variant supporttopics/cmake
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>
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | cmake/Modules/TFAMetadata.cmake | 21 | ||||
-rw-r--r-- | schemas/platform.schema.json | 8 |
3 files changed, 42 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b6dcead4e..2c8d63cde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,19 @@ arm_config_option( 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 # further configuration options. diff --git a/cmake/Modules/TFAMetadata.cmake b/cmake/Modules/TFAMetadata.cmake index fccb67d97..4c9d11f67 100644 --- a/cmake/Modules/TFAMetadata.cmake +++ b/cmake/Modules/TFAMetadata.cmake @@ -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) diff --git a/schemas/platform.schema.json b/schemas/platform.schema.json index 550450f7c..1960fffd8 100644 --- a/schemas/platform.schema.json +++ b/schemas/platform.schema.json @@ -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" + } + } } } } |