2021-08-09 13:10:31 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
#
|
|
|
|
# Copyright The Mbed TLS Contributors
|
2023-11-02 20:47:20 +01:00
|
|
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2021-08-09 13:10:31 +02:00
|
|
|
|
|
|
|
"""
|
2021-08-10 16:09:16 +02:00
|
|
|
This script generates a file called identifiers that contains all Mbed TLS
|
2021-08-09 13:10:31 +02: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 16:49:25 +02:00
|
|
|
It uses the CodeParser class from check_names.py to perform the parsing.
|
2021-08-09 13:10:31 +02:00
|
|
|
|
2021-08-09 16:49:25 +02:00
|
|
|
The script returns 0 on success, 1 if there is a script error.
|
2021-08-09 13:10:31 +02:00
|
|
|
Must be run from Mbed TLS root.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import argparse
|
2021-08-09 16:35:19 +02:00
|
|
|
import logging
|
|
|
|
from check_names import CodeParser
|
2021-08-09 13:10:31 +02:00
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
|
|
description=(
|
|
|
|
"This script writes a list of parsed identifiers in internal "
|
2021-08-10 16:09:16 +02:00
|
|
|
"headers to \"identifiers\". This is useful for generating a list "
|
2021-08-09 16:49:25 +02:00
|
|
|
"of names to exclude from API/ABI compatibility checking. "))
|
2021-08-09 13:10:31 +02:00
|
|
|
|
|
|
|
parser.parse_args()
|
|
|
|
|
2021-08-16 11:39:24 +02:00
|
|
|
name_check = CodeParser(logging.getLogger())
|
|
|
|
result = name_check.parse_identifiers([
|
|
|
|
"include/mbedtls/*_internal.h",
|
|
|
|
"library/*.h"
|
2023-01-16 17:36:31 +01:00
|
|
|
])[0]
|
2021-08-16 11:39:24 +02: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 13:10:31 +02:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|