From 8932404c456abfde51fac9b818120255018ec303 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Thu, 23 Nov 2023 10:14:12 +0000 Subject: [PATCH] Introduce project_crypto_name in build_tree.py Add new function to build_tree.py to return the crypto name for the project; either tfpsacrypto or mbedcrypto. Deploy this function where needed. Signed-off-by: Thomas Daubney --- scripts/mbedtls_dev/build_tree.py | 10 ++++++++++ tests/scripts/test_psa_compliance.py | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/mbedtls_dev/build_tree.py b/scripts/mbedtls_dev/build_tree.py index da455a7f2..f506c4142 100644 --- a/scripts/mbedtls_dev/build_tree.py +++ b/scripts/mbedtls_dev/build_tree.py @@ -32,6 +32,16 @@ def crypto_core_directory(root: Optional[str] = None) -> str: else: raise Exception('Neither Mbed TLS nor TF-PSA-Crypto source tree found') +def project_crypto_name(root: Optional[str] = None) -> str: + if root is None: + root = guess_project_root() + if looks_like_tf_psa_crypto_root(root): + return "tfpsacrypto" + elif looks_like_mbedtls_root(root): + return "mbedcrypto" + else: + raise Exception('Neither Mbed TLS nor TF-PSA-Crypto source tree found') + def check_repo_path(): """ Check that the current working directory is the project root, and throw diff --git a/tests/scripts/test_psa_compliance.py b/tests/scripts/test_psa_compliance.py index 2482d032a..82cc1b1db 100755 --- a/tests/scripts/test_psa_compliance.py +++ b/tests/scripts/test_psa_compliance.py @@ -50,10 +50,7 @@ def main(library_build_dir: str): in_tf_psa_crypto_repo = build_tree.looks_like_tf_psa_crypto_root(root_dir) - if in_tf_psa_crypto_repo: - crypto_name = 'tfpsacrypto' - else: - crypto_name = 'mbedcrypto' + crypto_name = build_tree.project_crypto_name() library_subdir = build_tree.crypto_core_directory()