Build: Conditional include of psa manifest headers
If more than one partitions provides the same service the macros can
collide in generated files. So the psa manifest headers are included
only if the matching partition is built.
Change-Id: Ie622466c1a4663a7ed2f188e3b6552136eb4c900
Signed-off-by: Mark Horvath <mark.horvath@arm.com>
diff --git a/secure_fw/partitions/tfm_service_list.inc.template b/secure_fw/partitions/tfm_service_list.inc.template
index e784b66..a16e066 100644
--- a/secure_fw/partitions/tfm_service_list.inc.template
+++ b/secure_fw/partitions/tfm_service_list.inc.template
@@ -10,8 +10,11 @@
#ifndef __TFM_SERVICE_LIST_INC__
#define __TFM_SERVICE_LIST_INC__
-{% for header in utilities.manifest_header_list %}
-#include "{{header}}"
+{% for manifest in manifests %}
+#ifdef {{manifest.attr.conditional}}
+#include "{{manifest.header_file}}"
+#endif /* {{manifest.attr.conditional}} */
+
{% endfor %}
const struct tfm_spm_service_db_t service_db[] =
diff --git a/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template
index 9db5d64..b41e7a5 100644
--- a/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template
+++ b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template
@@ -7,8 +7,10 @@
{{utilities.donotedit_warning}}
-{% for header in utilities.manifest_header_list %}
-#include "{{header}}"
+{% for manifest in manifests %}
+#ifdef {{manifest.attr.conditional}}
+#include "{{manifest.header_file}}"
+#endif /* {{manifest.attr.conditional}} */
{% endfor %}
#include "psa_manifest/pid.h"
{% macro _irq_record(partition_name, signal, line, priority) -%}
diff --git a/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template
index e5a7d6b..b38c9c1 100644
--- a/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template
+++ b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template
@@ -7,9 +7,13 @@
{{utilities.donotedit_warning}}
-{% for header in utilities.manifest_header_list %}
-#include "{{header}}"
+{% for manifest in manifests %}
+#ifdef {{manifest.attr.conditional}}
+#include "{{manifest.header_file}}"
+#endif /* {{manifest.attr.conditional}} */
+
{% endfor %}
+
#include "cmsis_compiler.h"
{% macro _irq_record(partition_name, signal, line, priority) -%}
{ {{ partition_name }}, {{ signal }}, {{ line }}, {{ priority }} },
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 1d6b64a..b346f6f 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -66,7 +66,6 @@
"""
db = []
- manifest_header_list = []
manifest_list = []
for f in manifest_list_files:
@@ -84,8 +83,6 @@
file = open(manifest_path)
manifest = yaml.safe_load(file)
- db.append({"manifest": manifest, "attr": manifest_item})
-
utilities = {}
utilities['donotedit_warning']=donotedit_warning
@@ -108,7 +105,7 @@
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)
+ db.append({"manifest": manifest, "attr": manifest_item, "header_file": outfile_name})
if OUT_DIR is not None:
outfile_name = os.path.join(OUT_DIR, outfile_name)
@@ -123,7 +120,7 @@
outfile.write(template.render(context))
outfile.close()
- return manifest_header_list, db
+ return db
def gen_files(context, gen_file_lists):
"""
@@ -236,13 +233,12 @@
"""
os.chdir(os.path.join(sys.path[0], ".."))
- manifest_header_list, db = process_manifest(manifest_list)
+ db = process_manifest(manifest_list)
utilities = {}
context = {}
utilities['donotedit_warning']=donotedit_warning
- utilities['manifest_header_list']=manifest_header_list
context['manifests'] = db
context['utilities'] = utilities