2021-08-09 11:10:31 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# Copyright The Mbed TLS Contributors
|
2023-11-02 19:47:20 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2021-08-09 11:10:31 +00:00
|
|
|
|
|
|
|
"""
|
2021-08-10 14:09:16 +00:00
|
|
|
This script generates a file called identifiers that contains all Mbed TLS
|
2021-08-09 11:10:31 +00:00
|
|
|
identifiers found on internal headers. This is the equivalent of what was
|
|
|
|
previously `list-identifiers.sh --internal`, and is useful for generating an
|
|
|
|
exclusion file list for ABI/API checking, since we do not promise compatibility
|
|
|
|
for them.
|
|
|
|
|
2021-08-09 14:49:25 +00:00
|
|
|
It uses the CodeParser class from check_names.py to perform the parsing.
|
2021-08-09 11:10:31 +00:00
|
|
|
|
2021-08-09 14:49:25 +00:00
|
|
|
The script returns 0 on success, 1 if there is a script error.
|
2021-08-09 11:10:31 +00:00
|
|
|
Must be run from Mbed TLS root.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import argparse
|
2021-08-09 14:35:19 +00:00
|
|
|
import logging
|
|
|
|
from check_names import CodeParser
|
2021-08-09 11:10:31 +00:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
|
|
description=(
|
|
|
|
"This script writes a list of parsed identifiers in internal "
|
2021-08-10 14:09:16 +00:00
|
|
|
"headers to \"identifiers\". This is useful for generating a list "
|
2021-08-09 14:49:25 +00:00
|
|
|
"of names to exclude from API/ABI compatibility checking. "))
|
2021-08-09 11:10:31 +00:00
|
|
|
|
|
|
|
parser.parse_args()
|
|
|
|
|
2021-08-16 09:39:24 +00:00
|
|
|
name_check = CodeParser(logging.getLogger())
|
|
|
|
result = name_check.parse_identifiers([
|
|
|
|
"include/mbedtls/*_internal.h",
|
2024-07-03 13:08:16 +00:00
|
|
|
"library/*.h",
|
|
|
|
"tf-psa-crypto/core/*.h",
|
|
|
|
"tf-psa-crypto/drivers/builtin/src/*.h"
|
2023-01-16 16:36:31 +00:00
|
|
|
])[0]
|
2021-08-16 09:39:24 +00:00
|
|
|
result.sort(key=lambda x: x.name)
|
|
|
|
|
|
|
|
identifiers = ["{}\n".format(match.name) for match in result]
|
|
|
|
with open("identifiers", "w", encoding="utf-8") as f:
|
|
|
|
f.writelines(identifiers)
|
2021-08-09 11:10:31 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|