1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-10-20 13:04:23 +08:00
Files
mbedtls/scripts/generate_config_checks.py
Gilles Peskine 8e44a94d39 Automatically generate checkers for removed options
Read the list of historical config options in 3.6, compare that to 1.0/4.0
and emit the appropriate checkers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-24 17:20:35 +02:00

47 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python3
"""Generate C preprocessor code to check for bad configurations.
"""
from typing import Iterator
import framework_scripts_path # pylint: disable=unused-import
from mbedtls_framework.config_checks_generator import * \
#pylint: disable=wildcard-import,unused-wildcard-import
from mbedtls_framework import config_history
class CryptoInternal(SubprojectInternal):
SUBPROJECT = 'TF-PSA-Crypto'
class CryptoOption(SubprojectOption):
SUBPROJECT = 'psa/crypto_config.h'
def checkers_for_removed_options() -> Iterator[Checker]:
"""Discover removed options. Yield corresponding checkers."""
history = config_history.ConfigHistory()
old_public = history.options('mbedtls', '3.6')
new_public = history.options('mbedtls', '4.0')
crypto_public = history.options('tfpsacrypto', '1.0')
crypto_internal = history.internal('tfpsacrypto', '1.0')
for option in sorted(old_public - new_public):
if option in crypto_public:
yield CryptoOption(option)
elif option in crypto_internal:
yield CryptoInternal(option)
else:
yield Removed(option, 'Mbed TLS 4.0')
def all_checkers() -> Iterator[Checker]:
"""Yield all checkers."""
yield from checkers_for_removed_options()
MBEDTLS_CHECKS = BranchData(
header_directory='library',
header_prefix='mbedtls_',
project_cpp_prefix='MBEDTLS',
checkers=list(all_checkers()),
)
if __name__ == '__main__':
main(MBEDTLS_CHECKS)