Tools: Decouple output and template of template tool

Templates are found by suffixing ".template " to "output".
This patch adds a new item "templates" in generated file list
to explicitly show where templates are so that outputs and templates
can have different paths.

Change-Id: Ic1ad242681fccdd5b8cad01e2f3ac15726b115ab
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/tools/tfm_generated_file_list.yaml b/tools/tfm_generated_file_list.yaml
index fc1dc0a..0ec7198 100644
--- a/tools/tfm_generated_file_list.yaml
+++ b/tools/tfm_generated_file_list.yaml
@@ -5,6 +5,10 @@
 #
 #-------------------------------------------------------------------------------
 
+# The path of "template" can be relative path to TF-M root or absolute path
+# The path of "output" must be relative path to the root for generated files
+# Both can contain environment variables
+
 {
   "name": "TF-M generated file list",
   "type": "generated_file_list",
@@ -14,51 +18,61 @@
     {
         "name": "Secure Partition declarations",
         "short_name": "tfm_partition_list",
+        "template": "secure_fw/spm/tfm_spm_db.inc.template",
         "output": "secure_fw/spm/tfm_spm_db.inc"
     },
     {
         "name": "Secure Service list",
         "short_name": "tfm_service_list",
+        "template": "secure_fw/services/tfm_service_list.inc.template",
         "output": "secure_fw/services/tfm_service_list.inc"
     },
     {
         "name": "Common secure ld file",
         "short_name": "tfm_common_s.ld",
+        "template": "platform/ext/common/gcc/tfm_common_s.ld.template",
         "output": "platform/ext/common/gcc/tfm_common_s.ld"
     },
     {
         "name": "Common secure sct file",
         "short_name": "tfm_common_s.sct",
+        "template": "platform/ext/common/armclang/tfm_common_s.sct.template",
         "output": "platform/ext/common/armclang/tfm_common_s.sct"
     },
     {
         "name": "Secure Veneers C file",
         "short_name": "tfm_veneers_c",
+        "template": "secure_fw/ns_callable/tfm_veneers.c.template",
         "output": "secure_fw/ns_callable/tfm_veneers.c"
     },
     {
         "name": "Secure Veneers H file",
         "short_name": "tfm_veneers_h",
+        "template": "interface/include/tfm_veneers.h.template",
         "output": "interface/include/tfm_veneers.h"
     },
     {
         "name": "Secure IRQ handlers",
         "short_name": "tfm_secure_irq_handlers",
+        "template": "secure_fw/core/tfm_secure_irq_handlers.inc.template",
         "output": "secure_fw/core/tfm_secure_irq_handlers.inc"
     },
     {
         "name": "Secure IRQ handlers for PSA API",
         "short_name": "tfm_secure_irq_handlers_ipc",
+        "template": "secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc.template",
         "output": "secure_fw/core/ipc/tfm_secure_irq_handlers_ipc.inc"
     },
     {
         "name": "SID H file",
         "short_name": "sid.h",
+        "template": "interface/include/psa_manifest/sid.h.template",
         "output": "interface/include/psa_manifest/sid.h"
     },
     {
         "name": "PID H file",
         "short_name": "pid.h",
+        "template": "interface/include/psa_manifest/pid.h.template",
         "output": "interface/include/psa_manifest/pid.h"
     }
   ]
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 9ea5f7d..9805cc5 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -150,7 +150,7 @@
 
     for file in file_list:
         outfile_name = os.path.expandvars(file["output"])
-        templatefile_name = outfile_name + '.template'
+        templatefile_name = os.path.expandvars(file["template"])
 
         if OUT_DIR is not None:
             outfile_name = os.path.join(OUT_DIR, outfile_name)