Build: Put generated header files to 'build' directory

In new build system, all auto-generated files are put to the build
directory. This patch modifies the tool script to generate and
output psa manifest header files to build directory.

Adds a "source_path" item in manifest file to enable the tool output
tf-m-tests and arch-test psa header files to build directory.

Change-Id: I6034007b300e4504454834a0ffe08b78421bba74
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
diff --git a/tools/tfm_manifest_list.yaml.in b/tools/tfm_manifest_list.yaml.in
index 6b73b0b..f0093ec 100644
--- a/tools/tfm_manifest_list.yaml.in
+++ b/tools/tfm_manifest_list.yaml.in
@@ -108,6 +108,7 @@
       "name": "TFM Core Test Service",
       "short_name": "TFM_SP_CORE_TEST",
       "manifest": "@TFM_TEST_PATH@/test_services/tfm_core_test/tfm_test_core.yaml",
+      "source_path": "@TFM_TEST_PATH@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE",
       "version_major": 0,
@@ -123,6 +124,7 @@
       "name": "TFM Core Test Service 2",
       "short_name": "TFM_SP_CORE_TEST_2",
       "manifest": "@TFM_TEST_PATH@/test_services/tfm_core_test_2/tfm_test_core_2.yaml",
+      "source_path": "@TFM_TEST_PATH@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE",
       "version_major": 0,
@@ -138,6 +140,7 @@
       "name": "TFM Secure Client Service",
       "short_name": "TFM_SP_SECURE_TEST_PARTITION",
       "manifest": "@TFM_TEST_PATH@/test_services/tfm_secure_client_service/tfm_test_client_service.yaml",
+      "source_path": "@TFM_TEST_PATH@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
       "version_major": 0,
@@ -161,6 +164,7 @@
       "name": "TFM IPC Service Test",
       "short_name": "TFM_SP_IPC_SERVICE_TEST",
       "manifest": "@TFM_TEST_PATH@/test_services/tfm_ipc_service/tfm_ipc_service_partition.yaml",
+      "source_path": "@TFM_TEST_PATH@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE_IPC",
       "version_major": 0,
@@ -176,6 +180,7 @@
       "name": "TFM IPC Client Service",
       "short_name": "TFM_SP_IPC_CLIENT_TEST",
       "manifest": "@TFM_TEST_PATH@/test_services/tfm_ipc_client/tfm_ipc_client_partition.yaml",
+      "source_path": "@TFM_TEST_PATH@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE_IPC",
       "version_major": 0,
@@ -191,6 +196,7 @@
       "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@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_ENABLE_IRQ_TEST",
       "version_major": 0,
@@ -207,6 +213,7 @@
       "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@",
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_PS",
       "version_major": 0,
@@ -222,6 +229,7 @@
       "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@",
       "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 e631823..a2628d6 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -98,6 +98,13 @@
         context['file_name'] = outfile_name.replace('.h', '')
         outfile_name = os.path.join(manifest_dir, "psa_manifest", outfile_name).replace('\\', '/')
 
+        """
+        Remove the `source_path` portion of the filepaths, so that it can be
+        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'])
+
         manifest_header_list.append(outfile_name)
 
         if OUT_DIR is not None:
diff --git a/tools/tfm_psa_ff_test_manifest_list.yaml.in b/tools/tfm_psa_ff_test_manifest_list.yaml.in
index 62c63f5..7fc4965 100644
--- a/tools/tfm_psa_ff_test_manifest_list.yaml.in
+++ b/tools/tfm_psa_ff_test_manifest_list.yaml.in
@@ -15,6 +15,7 @@
       "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@",
       "tfm_partition_ipc": true,
       "conditional": "PSA_API_TEST_IPC",
       "version_major": 0,
@@ -30,6 +31,7 @@
       "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@",
       "tfm_partition_ipc": true,
       "conditional": "PSA_API_TEST_IPC",
       "version_major": 0,
@@ -45,6 +47,7 @@
       "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@",
       "tfm_partition_ipc": true,
       "conditional": "PSA_API_TEST_IPC",
       "version_major": 0,