quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

list_internal_identifiers.py (1544B)


      1 #!/usr/bin/env python3
      2 #
      3 # Copyright The Mbed TLS Contributors
      4 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
      5 
      6 """
      7 This script generates a file called identifiers that contains all Mbed TLS
      8 identifiers found on internal headers. This is the equivalent of what was
      9 previously `list-identifiers.sh --internal`, and is useful for generating an
     10 exclusion file list for ABI/API checking, since we do not promise compatibility
     11 for them.
     12 
     13 It uses the CodeParser class from framework/scripts/check_names.py to perform
     14 the parsing.
     15 
     16 The script returns 0 on success, 1 if there is a script error.
     17 Must be run from Mbed TLS root.
     18 """
     19 
     20 import argparse
     21 import logging
     22 import scripts_path # pylint: disable=unused-import
     23 from check_names import CodeParser
     24 
     25 def main():
     26     parser = argparse.ArgumentParser(
     27         formatter_class=argparse.RawDescriptionHelpFormatter,
     28         description=(
     29             "This script writes a list of parsed identifiers in internal "
     30             "headers to \"identifiers\". This is useful for generating a list "
     31             "of names to exclude from API/ABI compatibility checking. "))
     32 
     33     parser.parse_args()
     34 
     35     name_check = CodeParser(logging.getLogger())
     36     result = name_check.parse_identifiers([
     37         "include/mbedtls/*_internal.h",
     38         "library/*.h"
     39     ])[0]
     40     result.sort(key=lambda x: x.name)
     41 
     42     identifiers = ["{}\n".format(match.name) for match in result]
     43     with open("identifiers", "w", encoding="utf-8") as f:
     44         f.writelines(identifiers)
     45 
     46 if __name__ == "__main__":
     47     main()