From ecb39368df1705b6390db303254f6011a73c4f2b Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 5 Dec 2023 11:02:30 +0000 Subject: [PATCH 1/4] Introduce project_name.txt This file is used for detecting which project a script is being run from. Signed-off-by: Thomas Daubney --- scripts/project_name.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 scripts/project_name.txt diff --git a/scripts/project_name.txt b/scripts/project_name.txt new file mode 100644 index 000000000..a38cf263b --- /dev/null +++ b/scripts/project_name.txt @@ -0,0 +1 @@ +Mbed TLS From 2f556400c320e6ef3fc9fe95e46ae8d9ec942c20 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 30 Jul 2024 15:52:58 +0100 Subject: [PATCH 2/4] Add functions to detect project Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 12 +++++++++--- tests/scripts/all.sh | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 9a0c58243..516d9e372 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -30,9 +30,15 @@ EOF set -eu -# Repository detection -in_mbedtls_build_dir () { - test -d library +# Project detection +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 () { + test "$PROJECT_NAME" = "Mbed TLS" } # Collect stats and build a HTML report. diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index d13456de7..5cf8e606c 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -115,12 +115,19 @@ set -e -o pipefail -u # Enable ksh/bash extended file matching patterns shopt -s extglob +# For project detection +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 () { - test -d include -a -d library -a -d programs -a -d tests + test "$PROJECT_NAME" = "Mbed TLS" } in_tf_psa_crypto_repo () { - test -d include -a -d core -a -d drivers -a -d programs -a -d tests + test "$PROJECT_NAME" = "TF-PSA-Crypto" } pre_check_environment () { From 5f0b64aadf029ed154d4b26593b1dbba805a6e64 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 6 Aug 2024 17:38:19 +0100 Subject: [PATCH 3/4] Move some proj detection code inside pre_check_environment Signed-off-by: Thomas Daubney --- tests/scripts/all.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 5cf8e606c..10dbe5627 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -116,12 +116,6 @@ set -e -o pipefail -u shopt -s extglob # For project detection -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 () { test "$PROJECT_NAME" = "Mbed TLS" } @@ -131,6 +125,13 @@ in_tf_psa_crypto_repo () { } pre_check_environment () { + # For project detection + 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 + if in_mbedtls_repo || in_tf_psa_crypto_repo; then :; else echo "Must be run from Mbed TLS / TF-PSA-Crypto root" >&2 exit 1 From a542420e6d40409d81a4ae6b7c2fb25dce09c00d Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 6 Aug 2024 18:01:42 +0100 Subject: [PATCH 4/4] Call in_mbedtls_repo Signed-off-by: Thomas Daubney --- scripts/lcov.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lcov.sh b/scripts/lcov.sh index 516d9e372..2d2f42bcb 100755 --- a/scripts/lcov.sh +++ b/scripts/lcov.sh @@ -74,7 +74,7 @@ if [ $# -gt 0 ] && [ "$1" = "--help" ]; then exit fi -if in_mbedtls_build_dir; then +if in_mbedtls_repo; then library_dir='library' title='Mbed TLS' else