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""" 7This script generates a file called identifiers that contains all Mbed TLS 8identifiers found on internal headers. This is the equivalent of what was 9previously `list-identifiers.sh --internal`, and is useful for generating an 10exclusion file list for ABI/API checking, since we do not promise compatibility 11for them. 12 13It uses the CodeParser class from framework/scripts/check_names.py to perform 14the parsing. 15 16The script returns 0 on success, 1 if there is a script error. 17Must be run from Mbed TLS root. 18""" 19 20import argparse 21import logging 22import scripts_path # pylint: disable=unused-import 23from check_names import CodeParser 24 25def 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 "tf-psa-crypto/core/*.h", 40 "tf-psa-crypto/drivers/builtin/src/*.h" 41 ])[0] 42 result.sort(key=lambda x: x.name) 43 44 identifiers = ["{}\n".format(match.name) for match in result] 45 with open("identifiers", "w", encoding="utf-8") as f: 46 f.writelines(identifiers) 47 48if __name__ == "__main__": 49 main() 50