Tools: Combine manifest lists and extra manifest lists
The manifest tool takes two manifest lists:
The default manifest list and the extra manifest list for out-of-tree
build partitions.
The processing is actually the same on the two lists.
The difference part is on the paths.
Paths used in the default manifest list are relative paths to TFM root
dir while paths used in extra manifest lists are relative path to the
manifest lists.
So the default manifest list (TFM_MANIFEST_LIST) can be only set to
manifest lists with TF-M repo.
This patch unifies paths usage and then the manifest lists can be
combined together.
With this patch, all manifest lists - whether within TF-M or out of
TF-M - are together pre-processed by CMake and passed to manifest tool.
And the default manifest list can be set to any manifest list.
Change-Id: Id2ae2a4407b1c191f175e7a5ad54edbaecc19523
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 6207bb5..c081c30 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -77,17 +77,19 @@
return partition_manifest
-def process_partition_manifests(manifest_list_files, extra_manifests_list):
+def process_partition_manifests(manifest_lists):
"""
- Parse the input manifest, generate the data base for genereated files
+ Parse the input manifest lists, generate the data base for genereated files
and generate manifest header files.
Parameters
----------
- manifest_list_files:
- The manifest lists to parse.
- extra_manifests_list:
- The extra manifest list to parse and its original path.
+ manifest_lists:
+ A list of Secure Partition manifest lists and their original paths.
+ The manifest lists might be processed by CMake and the paths might be
+ different to the original ones. Original paths are needed to handle
+ relative paths in the lists.
+ The format must be [list A, orignal path A, list B, orignal path B, ...]
Returns
-------
@@ -97,37 +99,37 @@
context = {}
partition_list = []
- manifest_list = []
+ all_manifests = []
ipc_partition_num = 0
sfn_partition_num = 0
pid_list = []
no_pid_manifest_idx = []
- for f in manifest_list_files:
- with open(f) as manifest_list_yaml_file:
- manifest_dic = yaml.safe_load(manifest_list_yaml_file)
- manifest_list.extend(manifest_dic['manifest_list'])
- manifest_list_yaml_file.close()
+ # Get all the manifests information as a dictionary
+ for i, item in enumerate(manifest_lists):
+ if i % 2 == 0 and not os.path.isfile(item):
+ print('Manifest list item [{}] must be a file'.format(i))
+ exit(1)
- # Out-of-tree secure partition build
- if extra_manifests_list is not None:
- for i, item in enumerate(extra_manifests_list):
- # Skip if current item is the original manifest path
- if os.path.isdir(item):
- continue
+ if i % 2 == 1:
+ if not os.path.isdir(item):
+ print('Manifest list item [{}] must be a directory'.format(i))
+ exit(1)
- # The manifest list file generated by configure_file()
- with open(item) as manifest_list_yaml_file:
- manifest_dic = yaml.safe_load(manifest_list_yaml_file)
- extra_manifest_dic = manifest_dic['manifest_list']
- for dict in extra_manifest_dic:
- # Append original directory of out-of-tree partition's
- # manifest list source code
- dict['extra_path'] = extra_manifests_list[i + 1]
- manifest_list.append(dict)
- manifest_list_yaml_file.close()
+ # Skip original manifest paths
+ continue
- for i, manifest_item in enumerate(manifest_list):
+ # The manifest list file generated by configure_file()
+ with open(item) as manifest_list_yaml_file:
+ manifest_dic = yaml.safe_load(manifest_list_yaml_file)['manifest_list']
+ for dict in manifest_dic:
+ # Add original path of manifest list.
+ # The validation will be done in the next loop.
+ dict['list_path'] = manifest_lists[i + 1]
+ all_manifests.append(dict)
+
+ # Parse the manifests
+ for i, manifest_item in enumerate(all_manifests):
valid_enabled_conditions = ['on', 'true', 'enabled']
valid_disabled_conditions = ['off', 'false', 'disabled']
is_enabled = ''
@@ -158,13 +160,8 @@
# Replace environment variables in the manifest path
manifest_path = os.path.expandvars(manifest_item['manifest'])
-
- # Handle out-of-tree secure partition manifest file path
- if 'extra_path' in manifest_item:
- if not os.path.isabs(manifest_path):
- # manifest file path provided by manifest list is relative to
- # manifest list path
- manifest_path = os.path.join(manifest_item['extra_path'], manifest_path).replace('\\', '/')
+ # Convert to absolute path. If it's already abspath, the path will not be changed.
+ manifest_path = os.path.join(manifest_item['list_path'], manifest_path).replace('\\', '/')
with open(manifest_path) as manifest_file:
manifest = manifest_validation(yaml.safe_load(manifest_file))
@@ -178,15 +175,12 @@
# This is only to skip Library Model Partitions
ipc_partition_num += 1
- manifest_dir, manifest_name = os.path.split(manifest_path)
- manifest_out_basename = manifest_name.replace('.yaml', '').replace('.json', '')
+ manifest_out_basename = os.path.splitext(os.path.basename(manifest_path))[0]
if 'output_path' in manifest_item:
- # Build up generated files directory accroding to the relative
- # path specified in output_path by the partition
output_path = os.path.expandvars(manifest_item['output_path'])
else:
- output_path = manifest_dir
+ output_path = ''
manifest_head_file = os.path.join(OUT_DIR, output_path, 'psa_manifest',
'{}.h'.format(manifest_out_basename))\
@@ -209,7 +203,7 @@
for idx in no_pid_manifest_idx:
while pid in pid_list:
pid += 1
- manifest_list[idx]['pid'] = pid
+ all_manifests[idx]['pid'] = pid
pid_list.append(pid)
context['partitions'] = partition_list
@@ -415,8 +409,11 @@
, nargs='+'
, dest='manifest_lists'
, required=True
- , metavar='manifest-lists'
- , help='A set of secure partition manifest lists to parse')
+ , metavar='manifest list'
+ , help='A list of Secure Partition manifest lists and their original paths.\n\
+ The manifest lists might be processed by CMake and\n\
+ the path might be different to the original one\n\
+ The format must be [list A, orignal path A, list B, orignal path B, ...]')
parser.add_argument('-f', '--file-list'
, nargs='+'
@@ -425,16 +422,13 @@
, metavar='file-list'
, help='These files descripe the file list to generate')
- parser.add_argument('-e', '--extra-manifest'
- , nargs='*'
- , dest='extra_manifests_args'
- , required=False
- , default=None
- , metavar='out-of-tree-manifest-list'
- , help='Optional. Manifest lists and original paths for out-of-tree secure partitions.')
-
args = parser.parse_args()
+ if len(args.manifest_lists) % 2 != 0:
+ print('Invalid structure in manifest lists.\n'
+ 'Each element shall consist of a manifest list and its original path')
+ exit(1)
+
return args
ENV = Environment(
@@ -456,17 +450,11 @@
args = parse_args()
- extra_manifests_args = args.extra_manifests_args
OUT_DIR = os.path.abspath(args.outdir)
manifest_lists = [os.path.abspath(x) for x in args.manifest_lists]
gen_file_lists = [os.path.abspath(x) for x in args.gen_file_args]
- if extra_manifests_args is not None:
- extra_manifests_lists = [os.path.abspath(x) for x in extra_manifests_args]
- else:
- extra_manifests_lists = None
-
"""
Relative path to TF-M root folder is supported in the manifests
and default value of manifest list and generated file list are relative to TF-M root folder as well,
@@ -476,7 +464,7 @@
"""
os.chdir(os.path.join(sys.path[0], '..'))
- context = process_partition_manifests(manifest_lists, extra_manifests_lists)
+ context = process_partition_manifests(manifest_lists)
utilities = {}
utilities['donotedit_warning'] = donotedit_warning