From 25405012ec246b33f0bdee0c67db2cb49659e258 Mon Sep 17 00:00:00 2001 From: Elena Uziunaite Date: Tue, 29 Oct 2024 17:08:09 +0000 Subject: [PATCH] Create project-detection.sh Move in_mbedtls_repo() and in_tf_psa_repo() there Signed-off-by: Elena Uziunaite --- scripts/project_detection.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/project_detection.sh diff --git a/scripts/project_detection.sh b/scripts/project_detection.sh new file mode 100755 index 000000000..34716f8b6 --- /dev/null +++ b/scripts/project_detection.sh @@ -0,0 +1,29 @@ +# project-detection.sh +# +# Copyright The Mbed TLS Contributors +# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +# +# Purpose +# +# This script contains functions for shell scripts to +# help detect which project (Mbed TLS, TF-PSA-Crypto) +# or which Mbed TLS branch they are in. + +# Project detection +read_project_name_file () { + PROJECT_NAME_FILE='../../scripts/project_name.txt' + if read -r PROJECT_NAME < "$PROJECT_NAME_FILE"; then :; else + echo "$PROJECT_NAME_FILE does not exist... Exiting..." >&2 + exit 1 + fi +} + +in_mbedtls_repo () { + read_project_name_file + test "$PROJECT_NAME" = "Mbed TLS" +} + +in_tf_psa_crypto_repo () { + read_project_name_file + test "$PROJECT_NAME" = "TF-PSA-Crypto" +}