Skip to content

Commit 030b14c

Browse files
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 <[email protected]>
1 parent 623c1b4 commit 030b14c

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

scripts/generate_psa_wrappers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,17 @@ class PSAWrapperGenerator(c_wrapper_generator.Base):
5151
_WRAPPER_NAME_SUFFIX = ''
5252

5353
def gather_data(self) -> None:
54+
"""Gather PSA Crypto API function names."""
5455
root_dir = build_tree.guess_mbedtls_root()
5556
for header_name in ['crypto.h', 'crypto_extra.h']:
56-
header_path = os.path.join(root_dir, 'include', 'psa', header_name)
57+
# Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto
58+
# build system to build its crypto library. When it does, the first
59+
# case can just be removed.
60+
if os.path.isdir(os.path.join(root_dir, 'tf-psa-crypto')):
61+
header_path = os.path.join(root_dir, 'tf-psa-crypto',
62+
'include', 'psa', header_name)
63+
else:
64+
header_path = os.path.join(root_dir, 'include', 'psa', header_name)
5765
c_parsing_helper.read_function_declarations(self.functions, header_path)
5866

5967
_SKIP_FUNCTIONS = frozenset([

scripts/mbedtls_framework/psa_information.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
66
#
77

8+
import os
89
import re
910
from collections import OrderedDict
1011
from typing import FrozenSet, List, Optional
@@ -30,8 +31,16 @@ def remove_unwanted_macros(
3031
def read_psa_interface(self) -> macro_collector.PSAMacroEnumerator:
3132
"""Return the list of known key types, algorithms, etc."""
3233
constructors = macro_collector.InputsForTest()
33-
header_file_names = ['include/psa/crypto_values.h',
34-
'include/psa/crypto_extra.h']
34+
# Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto
35+
# build system to build its crypto library. When it does, the first
36+
# case can just be removed.
37+
if os.path.isdir('tf-psa-crypto'):
38+
header_file_names = ['tf-psa-crypto/include/psa/crypto_values.h',
39+
'tf-psa-crypto/include/psa/crypto_extra.h']
40+
else:
41+
header_file_names = ['include/psa/crypto_values.h',
42+
'include/psa/crypto_extra.h']
43+
3544
test_suites = ['tests/suites/test_suite_psa_crypto_metadata.data']
3645
for header_file_name in header_file_names:
3746
constructors.parse_header(header_file_name)
@@ -124,10 +133,22 @@ def read_implemented_dependencies(filename: str) -> FrozenSet[str]:
124133
for symbol in re.findall(r'\bPSA_WANT_\w+\b', line))
125134
_implemented_dependencies = None #type: Optional[FrozenSet[str]] #pylint: disable=invalid-name
126135
def hack_dependencies_not_implemented(dependencies: List[str]) -> None:
136+
"""
137+
Hack dependencies to skip test cases for which at least one dependency
138+
symbol is not available yet.
139+
"""
127140
global _implemented_dependencies #pylint: disable=global-statement,invalid-name
128141
if _implemented_dependencies is None:
129-
_implemented_dependencies = \
130-
read_implemented_dependencies('include/psa/crypto_config.h')
142+
# Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto
143+
# build system to build its crypto library. When it does, the first
144+
# case can just be removed.
145+
if os.path.isdir('tf-psa-crypto'):
146+
_implemented_dependencies = \
147+
read_implemented_dependencies('tf-psa-crypto/include/psa/crypto_config.h')
148+
else:
149+
_implemented_dependencies = \
150+
read_implemented_dependencies('include/psa/crypto_config.h')
151+
131152
if not all((dep.lstrip('!') in _implemented_dependencies or
132153
not dep.lstrip('!').startswith('PSA_WANT'))
133154
for dep in dependencies):

scripts/mbedtls_framework/psa_storage.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
1111
#
1212

13+
import os
1314
import re
1415
import struct
1516
from typing import Dict, List, Optional, Set, Union
@@ -41,7 +42,14 @@ def __init__(self, content: Union[int, str]):
4142
def update_cache(self) -> None:
4243
"""Update `value_cache` for expressions registered in `unknown_values`."""
4344
expressions = sorted(self.unknown_values)
44-
includes = ['include']
45+
# Temporary, while Mbed TLS does not just rely on the TF-PSA-Crypto
46+
# build system to build its crypto library. When it does, the first
47+
# case can just be removed.
48+
if os.path.isdir('tf-psa-crypto'):
49+
includes = ['include', 'tf-psa-crypto/include']
50+
else:
51+
includes = ['include']
52+
4553
if build_tree.looks_like_tf_psa_crypto_root('.'):
4654
includes.append('drivers/builtin/include')
4755
values = c_build_helper.get_c_expression_values(

0 commit comments

Comments
 (0)