Tools: Make parameter '-o, --outdir' mandatory
The tool is not handling None out_dir correctly.
Making 'output directory' mandatory would simplify the logic much.
Change-Id: I0602b660c1bfb8721e075a60572f5080df22c656
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 4d34316..3f1e269 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -173,33 +173,32 @@
manifest_dir, manifest_name = os.path.split(manifest_path)
manifest_out_basename = manifest_name.replace('.yaml', '').replace('.json', '')
- if OUT_DIR is not None:
- 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'])
- manifest_head_file = os.path.join(output_path, "psa_manifest", manifest_out_basename + '.h')
- intermedia_file = os.path.join(output_path, "auto_generated", 'intermedia_' + manifest_out_basename + '.c')
- load_info_file = os.path.join(output_path, "auto_generated", 'load_info_' + manifest_out_basename + '.c')
- else:
- manifest_head_file = os.path.join(manifest_dir, "psa_manifest", manifest_out_basename + '.h')
- intermedia_file = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + manifest_out_basename + '.c')
- load_info_file = os.path.join(manifest_dir, "auto_generated", 'load_info_' + manifest_out_basename + '.c')
+ 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'])
+ manifest_head_file = os.path.join(output_path, "psa_manifest", manifest_out_basename + '.h')
+ intermedia_file = os.path.join(output_path, "auto_generated", 'intermedia_' + manifest_out_basename + '.c')
+ load_info_file = os.path.join(output_path, "auto_generated", 'load_info_' + manifest_out_basename + '.c')
+ else:
+ manifest_head_file = os.path.join(manifest_dir, "psa_manifest", manifest_out_basename + '.h')
+ intermedia_file = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + manifest_out_basename + '.c')
+ load_info_file = os.path.join(manifest_dir, "auto_generated", 'load_info_' + manifest_out_basename + '.c')
- """
- Remove the `source_path` portion of the filepaths, so that it can be
- interpreted as a relative path from the OUT_DIR.
- """
- if 'source_path' in manifest_item:
- # Replace environment variables in the source path
- source_path = os.path.expandvars(manifest_item['source_path'])
- manifest_head_file = os.path.relpath(manifest_head_file, start = source_path)
- intermedia_file = os.path.relpath(intermedia_file, start = source_path)
- load_info_file = os.path.relpath(load_info_file, start = source_path)
+ """
+ Remove the `source_path` portion of the filepaths, so that it can be
+ interpreted as a relative path from the OUT_DIR.
+ """
+ if 'source_path' in manifest_item:
+ # Replace environment variables in the source path
+ source_path = os.path.expandvars(manifest_item['source_path'])
+ manifest_head_file = os.path.relpath(manifest_head_file, start = source_path)
+ intermedia_file = os.path.relpath(intermedia_file, start = source_path)
+ load_info_file = os.path.relpath(load_info_file, start = source_path)
- manifest_head_file = os.path.join(OUT_DIR, manifest_head_file).replace('\\', '/')
- intermedia_file = os.path.join(OUT_DIR, intermedia_file).replace('\\', '/')
- load_info_file = os.path.join(OUT_DIR, load_info_file).replace('\\', '/')
+ manifest_head_file = os.path.join(OUT_DIR, manifest_head_file).replace('\\', '/')
+ intermedia_file = os.path.join(OUT_DIR, intermedia_file).replace('\\', '/')
+ load_info_file = os.path.join(OUT_DIR, load_info_file).replace('\\', '/')
partition_list.append({"manifest": manifest, "attr": manifest_item,
"manifest_out_basename": manifest_out_basename,
@@ -306,8 +305,7 @@
# Replace environment variables in the template filepath
templatefile_name = os.path.expandvars(file["template"])
- if OUT_DIR is not None:
- manifest_out_file = os.path.join(OUT_DIR, manifest_out_file)
+ manifest_out_file = os.path.join(OUT_DIR, manifest_out_file)
print ("Generating " + manifest_out_file)
@@ -417,10 +415,9 @@
parser.add_argument('-o', '--outdir'
, dest='outdir'
- , required=False
- , default=None
+ , required=True
, metavar='out_dir'
- , help='The root directory for generated files, the default is TF-M root folder.')
+ , help='The root directory for generated files')
parser.add_argument('-m', '--manifest'
, nargs='+'