Merge pull request #9437 from tom-daubney-arm/bp_3-6_standardise_proj_detection
[3.6 Backport] Standardise Project Detection
diff --git a/scripts/lcov.sh b/scripts/lcov.sh
index 9a0c582..2d2f42b 100755
--- a/scripts/lcov.sh
+++ b/scripts/lcov.sh
@@ -30,9 +30,15 @@
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.
@@ -68,7 +74,7 @@
exit
fi
-if in_mbedtls_build_dir; then
+if in_mbedtls_repo; then
library_dir='library'
title='Mbed TLS'
else
diff --git a/scripts/project_name.txt b/scripts/project_name.txt
new file mode 100644
index 0000000..a38cf26
--- /dev/null
+++ b/scripts/project_name.txt
@@ -0,0 +1 @@
+Mbed TLS
diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh
index ed097df..1a73020 100755
--- a/tests/scripts/all.sh
+++ b/tests/scripts/all.sh
@@ -115,15 +115,23 @@
# Enable ksh/bash extended file matching patterns
shopt -s extglob
+# For project detection
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 () {
+ # 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