Adjust temporarily the location of PSA headers In the pre-split situation where PSA headers are in tf-psa-crypto/include/psa and Mbed TLS does not just rely on the TF-PSA-Crypto build system to build its crypto library, adjust the location of PSA headers. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
diff --git a/scripts/generate_psa_wrappers.py b/scripts/generate_psa_wrappers.py index 701747d..ea01daf 100755 --- a/scripts/generate_psa_wrappers.py +++ b/scripts/generate_psa_wrappers.py
@@ -51,9 +51,17 @@ _WRAPPER_NAME_SUFFIX = '' def gather_data(self) -> None: + """Gather PSA Crypto API function names.""" root_dir = build_tree.guess_mbedtls_root() for header_name in ['crypto.h', 'crypto_extra.h']: - header_path = os.path.join(root_dir, 'include', 'psa', header_name) + # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto + # build system to build its crypto library. When it does, the first + # case can just be removed. + if os.path.isdir(os.path.join(root_dir, 'tf-psa-crypto')): + header_path = os.path.join(root_dir, 'tf-psa-crypto', + 'include', 'psa', header_name) + else: + header_path = os.path.join(root_dir, 'include', 'psa', header_name) c_parsing_helper.read_function_declarations(self.functions, header_path) _SKIP_FUNCTIONS = frozenset([
diff --git a/scripts/mbedtls_framework/psa_information.py b/scripts/mbedtls_framework/psa_information.py index 6080386..0a49893 100644 --- a/scripts/mbedtls_framework/psa_information.py +++ b/scripts/mbedtls_framework/psa_information.py
@@ -5,6 +5,7 @@ # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # +import os import re from collections import OrderedDict from typing import FrozenSet, List, Optional @@ -30,8 +31,16 @@ def read_psa_interface(self) -> macro_collector.PSAMacroEnumerator: """Return the list of known key types, algorithms, etc.""" constructors = macro_collector.InputsForTest() - header_file_names = ['include/psa/crypto_values.h', - 'include/psa/crypto_extra.h'] + # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto + # build system to build its crypto library. When it does, the first + # case can just be removed. + if os.path.isdir('tf-psa-crypto'): + header_file_names = ['tf-psa-crypto/include/psa/crypto_values.h', + 'tf-psa-crypto/include/psa/crypto_extra.h'] + else: + header_file_names = ['include/psa/crypto_values.h', + 'include/psa/crypto_extra.h'] + test_suites = ['tests/suites/test_suite_psa_crypto_metadata.data'] for header_file_name in header_file_names: constructors.parse_header(header_file_name) @@ -124,10 +133,22 @@ for symbol in re.findall(r'\bPSA_WANT_\w+\b', line)) _implemented_dependencies = None #type: Optional[FrozenSet[str]] #pylint: disable=invalid-name def hack_dependencies_not_implemented(dependencies: List[str]) -> None: + """ + Hack dependencies to skip test cases for which at least one dependency + symbol is not available yet. + """ global _implemented_dependencies #pylint: disable=global-statement,invalid-name if _implemented_dependencies is None: - _implemented_dependencies = \ - read_implemented_dependencies('include/psa/crypto_config.h') + # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto + # build system to build its crypto library. When it does, the first + # case can just be removed. + if os.path.isdir('tf-psa-crypto'): + _implemented_dependencies = \ + read_implemented_dependencies('tf-psa-crypto/include/psa/crypto_config.h') + else: + _implemented_dependencies = \ + read_implemented_dependencies('include/psa/crypto_config.h') + if not all((dep.lstrip('!') in _implemented_dependencies or not dep.lstrip('!').startswith('PSA_WANT')) for dep in dependencies):
diff --git a/scripts/mbedtls_framework/psa_storage.py b/scripts/mbedtls_framework/psa_storage.py index b1fc377..3f0a371 100644 --- a/scripts/mbedtls_framework/psa_storage.py +++ b/scripts/mbedtls_framework/psa_storage.py
@@ -10,6 +10,7 @@ # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # +import os import re import struct from typing import Dict, List, Optional, Set, Union @@ -41,7 +42,14 @@ def update_cache(self) -> None: """Update `value_cache` for expressions registered in `unknown_values`.""" expressions = sorted(self.unknown_values) - includes = ['include'] + # Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto + # build system to build its crypto library. When it does, the first + # case can just be removed. + if os.path.isdir('tf-psa-crypto'): + includes = ['include', 'tf-psa-crypto/include'] + else: + includes = ['include'] + if build_tree.looks_like_tf_psa_crypto_root('.'): includes.append('drivers/builtin/include') values = c_build_helper.get_c_expression_values(