|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | 3 | """ |
4 | | -Check that files with lists of config options are up-to-date, or update them. |
5 | | -
|
6 | | -This script checks the following file: |
7 | | -scripts/data_files/config-options-current.txt |
| 4 | +Check that TF-PSA-Crypto files that can be regenerated are up-to-date, or update them. |
8 | 5 | """ |
9 | 6 |
|
10 | 7 | # Copyright The Mbed TLS Contributors |
11 | 8 | # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
12 | 9 |
|
13 | | -import argparse |
14 | | -import sys |
15 | | - |
16 | 10 | import scripts_path # pylint: disable=unused-import |
17 | 11 | from mbedtls_framework import config_macros |
| 12 | +from mbedtls_framework import generate_files_helper |
18 | 13 |
|
| 14 | +GENERATORS = [ |
| 15 | + config_macros.Current(shadow_missing_ok=True), |
| 16 | +] |
19 | 17 |
|
20 | | -def main(): |
21 | | - parser = argparse.ArgumentParser(description=__doc__) |
22 | | - # For now this script only acts on one target file. |
23 | | - # If we check/update more files, we should add a way to select which |
24 | | - # file(s) to operate on. |
25 | | - parser.add_argument('--always-update', '-U', |
26 | | - action='store_true', |
27 | | - help=('Update target files unconditionally ' |
28 | | - '(overrides --update)')) |
29 | | - parser.add_argument('--update', '-u', |
30 | | - action='store_true', |
31 | | - help='Update target files if needed') |
32 | | - args = parser.parse_args() |
33 | | - data = config_macros.Current(shadow_missing_ok=True) |
34 | | - if args.update or args.always_update: |
35 | | - data.update_shadow_file(args.always_update) |
36 | | - else: |
37 | | - up_to_date = True |
38 | | - if not data.is_shadow_file_up_to_date(): |
39 | | - print(f'{data.shadow_file_path()} is out of date') |
40 | | - print(f'After adding or removing a config option, you need to run') |
41 | | - print(f'{sys.argv[0]} -u and commit the result.') |
42 | | - up_to_date = False |
43 | | - sys.exit(0 if up_to_date else 1) |
44 | | - |
45 | | -if __name__ == "__main__": |
46 | | - main() |
| 18 | +if __name__ == '__main__': |
| 19 | + generate_files_helper.main(generators=GENERATORS, |
| 20 | + description=__doc__) |
0 commit comments