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>
This commit is contained in:
Ronald Cron
2024-06-10 09:16:26 +02:00
parent 623c1b4532
commit 030b14c2bc
3 changed files with 43 additions and 6 deletions
+9 -1
View File
@@ -51,9 +51,17 @@ class PSAWrapperGenerator(c_wrapper_generator.Base):
_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([
+25 -4
View File
@@ -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 @@ class Information:
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 @@ def read_implemented_dependencies(filename: str) -> FrozenSet[str]:
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):
+9 -1
View File
@@ -10,6 +10,7 @@ before changing how test data is constructed or validated.
# 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 @@ class Expr:
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(