Build: Generate manifest file name header file
According to PSA FF, the 'manifestfilename.h' need be created by tools:
- Add generate_manifestfilename() function to generate this header file.
- The template file is put in 'secure_fw/services'.
- The related header files of secure partition and test partition are
created by tools.
Change-Id: Ic53ad481860fea018f29b7eca5a9548d074c19ae
Signed-off-by: Edison Ai <edison.ai@arm.com>
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 1ed8b81..102ff13 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -16,6 +16,12 @@
print ("pip install PyYAML")
exit(1)
+donotedit_warning = \
+ "/*********** " + \
+ "WARNING: This is an auto-generated file. Do not edit!" + \
+ " ***********/"
+manifest_list_yaml_file_path = os.path.join('tools', 'tfm_manifest_list.yaml')
+
class TemplateLoader(BaseLoader):
"""
Template loader class.
@@ -69,6 +75,51 @@
return db
+def generate_manifestfilename(env):
+ """
+ Generate manifestfilename header file.
+
+ Parameters
+ ----------
+ env :
+ The instance of Environment.
+ """
+ with open(manifest_list_yaml_file_path) as manifest_list_yaml_file:
+ manifest_list = yaml.load(manifest_list_yaml_file)
+ templatefile_name = 'secure_fw/services/manifestfilename.template'
+ template = env.get_template(templatefile_name)
+
+ for manifest_file in manifest_list["manifest_list"]:
+ manifest_path = manifest_file['manifest']
+ file = open(manifest_path)
+ manifest = yaml.load(file)
+
+ utilities = {}
+ utilities['donotedit_warning']=donotedit_warning
+
+ context = {}
+ context['manifest'] = manifest
+ context['attr'] = manifest_file
+ context['utilities'] = utilities
+
+ manifest_dir, sep, manifest_name = manifest_path.rpartition('/')
+ outfile_name = manifest_name.replace('yaml', 'h')
+ outfile_path = manifest_dir + sep + "psa_manifest/" + outfile_name
+
+ context['file_name'] = outfile_name.replace('.h', '')
+
+ print ("Generating " + outfile_path)
+
+ if not os.path.exists(os.path.dirname(outfile_path)):
+ try:
+ os.makedirs(os.path.dirname(outfile_path))
+ except OSError:
+ raise Exception ("Failed to create folder" + os.path.dirname(outfile_path))
+
+ outfile = io.open(outfile_path, "w", newline='\n')
+ outfile.write(template.render(context))
+ outfile.close()
+ return
def main():
"""
@@ -76,11 +127,6 @@
Generates the output files based on the templates and the manifests.
"""
- donotedit_warning = \
- "/*********** " + \
- "WARNING: This is an auto-generated file. Do not edit!" + \
- " ***********/"
-
env = Environment(
loader = TemplateLoader(),
autoescape = select_autoescape(['html', 'xml']),
@@ -89,8 +135,7 @@
keep_trailing_newline = True
)
- with open(os.path.join('tools', 'tfm_manifest_list.yaml')) \
- as manifest_list_yaml_file:
+ with open(manifest_list_yaml_file_path) as manifest_list_yaml_file:
# Read manifest list file, build database
db = load_manifest_list(manifest_list_yaml_file)
@@ -117,6 +162,10 @@
outfile = io.open(outfile_name, "w", newline='\n')
outfile.write(template.render(context))
outfile.close()
+
+ # Generate manifestfilename
+ generate_manifestfilename(env)
+
print ("Generation of files done")
if __name__ == "__main__":