aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaef Coles <raef.coles@arm.com>2020-10-29 13:09:44 +0000
committerAnton Komlev <Anton.Komlev@arm.com>2020-11-04 13:14:33 +0000
commit558487a0a0756afe480030cdfaeeccdd9abd486f (patch)
tree4a91777b4d2c365c55de299cc23e1bef106b6df5
parent9524fa29a4d0ecbe9082f47fb092761c0ded2c8b (diff)
downloadtrusted-firmware-m-558487a0a0756afe480030cdfaeeccdd9abd486f.tar.gz
Tools: Allow file generation without cmake
Alter file generation to pick up variables from the environment, as well as cmake, to allow integration into environments that don't run the cmake. Change-Id: Iac921ba69a01459a5959828e3825cd8e901e3a96 Signed-off-by: Raef Coles <raef.coles@arm.com>
-rw-r--r--docs/getting_started/tfm_integration_guide.rst18
-rw-r--r--tools/CMakeLists.txt8
-rw-r--r--tools/tfm_manifest_list.yaml (renamed from tools/tfm_manifest_list.yaml.in)32
-rw-r--r--tools/tfm_parse_manifest_list.py27
-rw-r--r--tools/tfm_psa_ff_test_manifest_list.yaml (renamed from tools/tfm_psa_ff_test_manifest_list.yaml.in)12
5 files changed, 55 insertions, 42 deletions
diff --git a/docs/getting_started/tfm_integration_guide.rst b/docs/getting_started/tfm_integration_guide.rst
index 5dfca9a696..9c1cf30bb8 100644
--- a/docs/getting_started/tfm_integration_guide.rst
+++ b/docs/getting_started/tfm_integration_guide.rst
@@ -162,6 +162,24 @@ to NS interrupts to the lower half of available priorities so that it wouldn't
be possible for any non-secure interrupt to preempt a higher-priority secure
interrupt.
+**********************************
+Integration with non-Cmake systems
+**********************************
+
+Generated Files
+===============
+
+Files that are derived from PSA manifests are generated at build-time by cmake.
+For integration with systems that do no use cmake, the files must be generated
+manually.
+
+The ``tools/tfm_parse_manifest_list.py`` script can be invoked manually. Some
+arguments will be needed to be provided. Please refer to
+``tfm_parse_manifest_list.py --help`` for more details.
+
+Some variables are used in the template files, these will need to be set in the
+environment before the script will succeed when the script is not run via cmake.
+
--------------
*Copyright (c) 2017-2020, Arm Limited. All rights reserved.*
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 381a9f196c..7accf48e02 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -10,15 +10,15 @@ find_package(Python3)
############################### Manifest declaration ###########################
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_manifest_list.yaml.in
- ${CMAKE_CURRENT_BINARY_DIR}/tfm_manifest_list.yaml @ONLY)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_manifest_list.yaml
+ ${CMAKE_CURRENT_BINARY_DIR}/tfm_manifest_list.yaml)
set(MANIFEST_LISTS ${CMAKE_CURRENT_BINARY_DIR}/tfm_manifest_list.yaml)
set(MANIFEST_LISTS ${MANIFEST_LISTS} ${TFM_EXTRA_MANIFEST_LIST_PATH})
if ("${TEST_PSA_API}" STREQUAL "IPC")
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_psa_ff_test_manifest_list.yaml.in
- ${CMAKE_CURRENT_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml @ONLY)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tfm_psa_ff_test_manifest_list.yaml
+ ${CMAKE_CURRENT_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml)
set(MANIFEST_LISTS ${MANIFEST_LISTS} ${CMAKE_CURRENT_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml)
endif()
diff --git a/tools/tfm_manifest_list.yaml.in b/tools/tfm_manifest_list.yaml
index 7751e58636..82dcdd759c 100644
--- a/tools/tfm_manifest_list.yaml.in
+++ b/tools/tfm_manifest_list.yaml
@@ -107,8 +107,8 @@
{
"name": "TFM Core Test Service",
"short_name": "TFM_SP_CORE_TEST",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_core_test/tfm_ss_core_test.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_core_test/tfm_ss_core_test.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_CORE",
"version_major": 0,
@@ -123,8 +123,8 @@
{
"name": "TFM Core Test Service 2",
"short_name": "TFM_SP_CORE_TEST_2",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_core_test_2/tfm_ss_core_test_2.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_core_test_2/tfm_ss_core_test_2.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_CORE",
"version_major": 0,
@@ -139,8 +139,8 @@
{
"name": "TFM Secure Client Service",
"short_name": "TFM_SP_SECURE_TEST_PARTITION",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_secure_client_service/tfm_secure_client_service.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
"version_major": 0,
@@ -163,8 +163,8 @@
{
"name": "TFM IPC Service Test",
"short_name": "TFM_SP_IPC_SERVICE_TEST",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_ipc_service/tfm_ipc_service_test.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_ipc_service/tfm_ipc_service_test.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_CORE_IPC",
"version_major": 0,
@@ -179,8 +179,8 @@
{
"name": "TFM IPC Client Service",
"short_name": "TFM_SP_IPC_CLIENT_TEST",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_ipc_client/tfm_ipc_client_test.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_ipc_client/tfm_ipc_client_test.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_CORE_IPC",
"version_major": 0,
@@ -195,8 +195,8 @@
{
"name": "TFM IRQ Test Service 1",
"short_name": "TFM_IRQ_TEST_1",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_irq_test_service_1/tfm_irq_test_service_1.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_irq_test_service_1/tfm_irq_test_service_1.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_ENABLE_IRQ_TEST",
"version_major": 0,
@@ -212,8 +212,8 @@
{
"name": "TF-M PS Test Service",
"short_name": "TFM_SP_PS_TEST",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_ps_test_service/tfm_ps_test_service.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_ps_test_service/tfm_ps_test_service.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_PS",
"version_major": 0,
@@ -228,8 +228,8 @@
{
"name": "TF-M Secure Client 2 Service",
"short_name": "TFM_SP_SECURE_CLIENT_2",
- "manifest": "@TFM_TEST_PATH@/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml",
- "source_path": "@TFM_TEST_PATH@",
+ "manifest": "${TFM_TEST_PATH}/test_services/tfm_secure_client_2/tfm_secure_client_2.yaml",
+ "source_path": "${TFM_TEST_PATH}",
"tfm_partition_ipc": true,
"conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
"version_major": 0,
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index a2628d6e26..1d6b64aa37 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -79,6 +79,7 @@ def process_manifest(manifest_list_files):
print("Start to generate PSA manifests:")
for manifest_item in manifest_list:
+ # Replace environment variables in the manifest path
manifest_path = os.path.expandvars(manifest_item['manifest'])
file = open(manifest_path)
manifest = yaml.safe_load(file)
@@ -103,7 +104,9 @@ def process_manifest(manifest_list_files):
interpreted as a relative path from the OUT_DIR.
"""
if 'source_path' in manifest_item:
- outfile_name = os.path.relpath(outfile_name, start = manifest_item['source_path'])
+ # Replace environment variables in the source path
+ source_path = os.path.expandvars(manifest_item['source_path'])
+ outfile_name = os.path.relpath(outfile_name, start = source_path)
manifest_header_list.append(outfile_name)
@@ -140,7 +143,9 @@ def gen_files(context, gen_file_lists):
print("Start to generate file from the generated list:")
for file in file_list:
+ # Replace environment variables in the output filepath
outfile_name = os.path.expandvars(file["output"])
+ # Replace environment variables in the template filepath
templatefile_name = os.path.expandvars(file["template"])
if OUT_DIR is not None:
@@ -161,7 +166,9 @@ def gen_files(context, gen_file_lists):
print ("Generation of files done")
def parse_args():
- parser = argparse.ArgumentParser(description='Parse secure partition manifest list and generate files listed by the file list')
+ parser = argparse.ArgumentParser(description='Parse secure partition manifest list and generate files listed by the file list',
+ epilog='Note that environment variables in template files will be replaced with their values')
+
parser.add_argument('-o', '--outdir'
, dest='outdir'
, required=False
@@ -212,20 +219,8 @@ def main():
gen_file_args = args.gen_file_args
OUT_DIR = args.outdir
- if len(manifest_args) == 0:
- manifest_list = DEFAULT_MANIFEST_LIST
- else:
- """
- Only convert to abs path when value is not default
- Because the default value is a fixed relative path to TF-M root folder,
- it will be various to different execution path if converted to absolute path.
- The same for gen_file_list
- """
- manifest_list = [os.path.abspath(x) for x in args.manifest_args]
- if len(gen_file_args) == 0:
- gen_file_list = DEFAULT_GEN_FILE_LIST
- else:
- gen_file_list = [os.path.abspath(x) for x in args.gen_file_args]
+ manifest_list = [os.path.abspath(x) for x in args.manifest_args]
+ gen_file_list = [os.path.abspath(x) for x in args.gen_file_args]
# Arguments could be relative path.
# Convert to absolute path as we are going to change diretory later
diff --git a/tools/tfm_psa_ff_test_manifest_list.yaml.in b/tools/tfm_psa_ff_test_manifest_list.yaml
index 7fc4965618..cba0c5ca4f 100644
--- a/tools/tfm_psa_ff_test_manifest_list.yaml.in
+++ b/tools/tfm_psa_ff_test_manifest_list.yaml
@@ -14,8 +14,8 @@
{
"name": "PSA FF Test Client Partition",
"short_name": "PSA_FF_TEST_CLIENT",
- "manifest": "@PSA_ARCH_TESTS_PATH@/api-tests/platform/manifests/client_partition_psa.json",
- "source_path":"@PSA_ARCH_TESTS_PATH@",
+ "manifest": "${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/client_partition_psa.json",
+ "source_path":"${PSA_ARCH_TESTS_PATH}",
"tfm_partition_ipc": true,
"conditional": "PSA_API_TEST_IPC",
"version_major": 0,
@@ -30,8 +30,8 @@
{
"name": "PSA FF Test Server Partition",
"short_name": "PSA_FF_TEST_SERVER",
- "manifest": "@PSA_ARCH_TESTS_PATH@/api-tests/platform/manifests/server_partition_psa.json",
- "source_path":"@PSA_ARCH_TESTS_PATH@",
+ "manifest": "${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/server_partition_psa.json",
+ "source_path":"${PSA_ARCH_TESTS_PATH}",
"tfm_partition_ipc": true,
"conditional": "PSA_API_TEST_IPC",
"version_major": 0,
@@ -46,8 +46,8 @@
{
"name": "PSA FF Test Driver Partition",
"short_name": "PSA_FF_TEST_DRIVER",
- "manifest": "@PSA_ARCH_TESTS_PATH@/api-tests/platform/manifests/driver_partition_psa.json",
- "source_path":"@PSA_ARCH_TESTS_PATH@",
+ "manifest": "${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/driver_partition_psa.json",
+ "source_path":"${PSA_ARCH_TESTS_PATH}",
"tfm_partition_ipc": true,
"conditional": "PSA_API_TEST_IPC",
"version_major": 0,