blob: 76fb310a51e2dd327aa0d357eaa5d3fdc9a8c0e5 [file] [log] [blame]
Miklos Balint470919c2018-05-22 17:51:29 +02001#-------------------------------------------------------------------------------
2# Copyright (c) 2018, Arm Limited. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
8import os
Miklos Balint3a05c9d2018-05-31 09:31:27 +02009from keyword_substitution import Verbosity, log_print
10from generate_from_template import generate_from_template_file
Miklos Balint470919c2018-05-22 17:51:29 +020011
12try:
13 import yaml
14except ImportError as e:
15 print e, "To install it, type:"
16 print "pip install PyYAML"
17 exit(1)
18
19VERBOSITY = Verbosity.warning
20log_print(Verbosity.debug, "Setting verbosity to", VERBOSITY, verbosity=VERBOSITY)
21
Miklos Balint470919c2018-05-22 17:51:29 +020022# All operations assume tf-m repo root as active working directory
23
Miklos Balint470919c2018-05-22 17:51:29 +020024# Functions
25def load_manifest_list(file):
26 db = []
27 manifest_list = yaml.load(file)
28 for item in manifest_list["manifest_list"]:
Miklos Balint3a05c9d2018-05-31 09:31:27 +020029 manifest_path = item['manifest']
Miklos Balint470919c2018-05-22 17:51:29 +020030 try:
31 file = open(manifest_path)
32 manifest = yaml.load(file)
33 db.append({"manifest": manifest, "attr": item})
34 except IOError:
35 print "Manifest for "+item['name']+" cannot be opened at path "+item['manifest']
36 return db
Miklos Balint3a05c9d2018-05-31 09:31:27 +020037# def load_manifest_list
Miklos Balint470919c2018-05-22 17:51:29 +020038
39# main
40def main():
Miklos Balint3a05c9d2018-05-31 09:31:27 +020041 with open(os.path.join('tools', 'tfm_manifest_list.yaml')) \
42 as manifest_list_yaml_file:
Miklos Balint470919c2018-05-22 17:51:29 +020043 # Read manifest list file, build database
44 db = load_manifest_list(manifest_list_yaml_file)
45
Miklos Balint3a05c9d2018-05-31 09:31:27 +020046 with open(os.path.join('tools', 'tfm_generated_file_list.yaml')) \
47 as file_list_yaml_file:
48 # read list of files that need to be generated from templates using db
49 file_list_yaml = yaml.load(file_list_yaml_file)
50 file_list = file_list_yaml["file_list"]
51 generate_from_template_file(db, file_list)
Miklos Balint470919c2018-05-22 17:51:29 +020052
53if __name__ == "__main__":
54 main()