check_committed_generated_files.py: use the new generate_files_helper module

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2026-02-11 17:21:25 +01:00
parent 4a21496d6f
commit 260992c0f4

View File

@@ -1,46 +1,20 @@
#!/usr/bin/env python3
"""
Check that files with lists of config options are up-to-date, or update them.
This script checks the following file:
scripts/data_files/config-options-current.txt
Check that TF-PSA-Crypto files that can be regenerated are up-to-date, or update them.
"""
# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
import argparse
import sys
import scripts_path # pylint: disable=unused-import
from mbedtls_framework import config_macros
from mbedtls_framework import generate_files_helper
GENERATORS = [
config_macros.Current(shadow_missing_ok=True),
]
def main():
parser = argparse.ArgumentParser(description=__doc__)
# For now this script only acts on one target file.
# If we check/update more files, we should add a way to select which
# file(s) to operate on.
parser.add_argument('--always-update', '-U',
action='store_true',
help=('Update target files unconditionally '
'(overrides --update)'))
parser.add_argument('--update', '-u',
action='store_true',
help='Update target files if needed')
args = parser.parse_args()
data = config_macros.Current(shadow_missing_ok=True)
if args.update or args.always_update:
data.update_shadow_file(args.always_update)
else:
up_to_date = True
if not data.is_shadow_file_up_to_date():
print(f'{data.shadow_file_path()} is out of date')
print(f'After adding or removing a config option, you need to run')
print(f'{sys.argv[0]} -u and commit the result.')
up_to_date = False
sys.exit(0 if up_to_date else 1)
if __name__ == "__main__":
main()
if __name__ == '__main__':
generate_files_helper.main(generators=GENERATORS,
description=__doc__)