blob: a2a174bb4cb8ba7b71c31a5cd20c49ecb0720136 [file] [log] [blame]
Gilles Peskine3374f6e2025-07-31 21:09:39 +02001#!/usr/bin/env python3
2
3"""Generate C preprocessor code to check for bad configurations.
4"""
5
Gilles Peskine8e44a942025-09-15 15:27:20 +02006from typing import Iterator
7
Gilles Peskine3374f6e2025-07-31 21:09:39 +02008import framework_scripts_path # pylint: disable=unused-import
9from mbedtls_framework.config_checks_generator import * \
10 #pylint: disable=wildcard-import,unused-wildcard-import
Gilles Peskine8e44a942025-09-15 15:27:20 +020011from mbedtls_framework import config_history
Gilles Peskine3374f6e2025-07-31 21:09:39 +020012
Gilles Peskine24273c02025-07-16 22:27:09 +020013class CryptoInternal(SubprojectInternal):
14 SUBPROJECT = 'TF-PSA-Crypto'
15
16class CryptoOption(SubprojectOption):
17 SUBPROJECT = 'psa/crypto_config.h'
18
Gilles Peskine8e44a942025-09-15 15:27:20 +020019def checkers_for_removed_options() -> Iterator[Checker]:
20 """Discover removed options. Yield corresponding checkers."""
21 history = config_history.ConfigHistory()
22 old_public = history.options('mbedtls', '3.6')
23 new_public = history.options('mbedtls', '4.0')
24 crypto_public = history.options('tfpsacrypto', '1.0')
25 crypto_internal = history.internal('tfpsacrypto', '1.0')
26 for option in sorted(old_public - new_public):
27 if option in crypto_public:
28 yield CryptoOption(option)
29 elif option in crypto_internal:
30 yield CryptoInternal(option)
31 else:
32 yield Removed(option, 'Mbed TLS 4.0')
33
34def all_checkers() -> Iterator[Checker]:
35 """Yield all checkers."""
36 yield from checkers_for_removed_options()
37
Gilles Peskine3374f6e2025-07-31 21:09:39 +020038MBEDTLS_CHECKS = BranchData(
39 header_directory='library',
40 header_prefix='mbedtls_',
41 project_cpp_prefix='MBEDTLS',
Gilles Peskine8e44a942025-09-15 15:27:20 +020042 checkers=list(all_checkers()),
Gilles Peskine3374f6e2025-07-31 21:09:39 +020043)
44
45if __name__ == '__main__':
46 main(MBEDTLS_CHECKS)