|
7 | 7 |
|
8 | 8 | import argparse |
9 | 9 | from mbedtls_framework.code_wrapper.psa_test_wrapper import PSATestWrapper, PSALoggingTestWrapper |
10 | | - |
11 | | -DEFAULT_C_OUTPUT_FILE_NAME = 'tests/src/psa_test_wrappers.c' |
12 | | -DEFAULT_H_OUTPUT_FILE_NAME = 'tests/include/test/psa_test_wrappers.h' |
| 10 | +from mbedtls_framework import build_tree |
13 | 11 |
|
14 | 12 | def main() -> None: |
| 13 | + default_c_output_file_name = 'tests/src/psa_test_wrappers.c' |
| 14 | + default_h_output_file_name = 'tests/include/test/psa_test_wrappers.h' |
| 15 | + |
| 16 | + project_root = build_tree.guess_project_root() |
| 17 | + if build_tree.looks_like_mbedtls_root(project_root) and \ |
| 18 | + not build_tree.is_mbedtls_3_6(): |
| 19 | + default_c_output_file_name = 'tf-psa-crypto/' + default_c_output_file_name |
| 20 | + default_h_output_file_name = 'tf-psa-crypto/' + default_h_output_file_name |
| 21 | + |
15 | 22 | parser = argparse.ArgumentParser(description=globals()['__doc__']) |
16 | 23 | parser.add_argument('--log', |
17 | 24 | help='Stream to log to (default: no logging code)') |
18 | 25 | parser.add_argument('--output-c', |
19 | 26 | metavar='FILENAME', |
20 | | - default=DEFAULT_C_OUTPUT_FILE_NAME, |
| 27 | + default=default_c_output_file_name, |
21 | 28 | help=('Output .c file path (default: {}; skip .c output if empty)' |
22 | | - .format(DEFAULT_C_OUTPUT_FILE_NAME))) |
| 29 | + .format(default_c_output_file_name))) |
23 | 30 | parser.add_argument('--output-h', |
24 | 31 | metavar='FILENAME', |
25 | | - default=DEFAULT_H_OUTPUT_FILE_NAME, |
| 32 | + default=default_h_output_file_name, |
26 | 33 | help=('Output .h file path (default: {}; skip .h output if empty)' |
27 | | - .format(DEFAULT_H_OUTPUT_FILE_NAME))) |
| 34 | + .format(default_h_output_file_name))) |
28 | 35 | options = parser.parse_args() |
| 36 | + |
29 | 37 | if options.log: |
30 | | - generator = PSALoggingTestWrapper(DEFAULT_H_OUTPUT_FILE_NAME, |
31 | | - DEFAULT_C_OUTPUT_FILE_NAME, |
| 38 | + generator = PSALoggingTestWrapper(default_h_output_file_name, |
| 39 | + default_c_output_file_name, |
32 | 40 | options.log) #type: PSATestWrapper |
33 | 41 | else: |
34 | | - generator = PSATestWrapper(DEFAULT_H_OUTPUT_FILE_NAME, |
35 | | - DEFAULT_C_OUTPUT_FILE_NAME) |
| 42 | + generator = PSATestWrapper(default_h_output_file_name, |
| 43 | + default_c_output_file_name) |
36 | 44 |
|
37 | 45 | if options.output_h: |
38 | 46 | generator.write_h_file(options.output_h) |
|
0 commit comments