Merge pull request #9437 from tom-daubney-arm/bp_3-6_standardise_proj_detection

[3.6 Backport] Standardise Project Detection
This commit is contained in:
Tom Cosgrove 2024-08-07 07:18:43 +00:00 committed by GitHub
commit 4306a69931
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 6 deletions

View File

@ -30,9 +30,15 @@ EOF
set -eu set -eu
# Repository detection # Project detection
in_mbedtls_build_dir () { PROJECT_NAME_FILE='./scripts/project_name.txt'
test -d library 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. # Collect stats and build a HTML report.
@ -68,7 +74,7 @@ if [ $# -gt 0 ] && [ "$1" = "--help" ]; then
exit exit
fi fi
if in_mbedtls_build_dir; then if in_mbedtls_repo; then
library_dir='library' library_dir='library'
title='Mbed TLS' title='Mbed TLS'
else else

1
scripts/project_name.txt Normal file
View File

@ -0,0 +1 @@
Mbed TLS

View File

@ -115,15 +115,23 @@ set -e -o pipefail -u
# Enable ksh/bash extended file matching patterns # Enable ksh/bash extended file matching patterns
shopt -s extglob shopt -s extglob
# For project detection
in_mbedtls_repo () { 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 () { 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 () { 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 if in_mbedtls_repo || in_tf_psa_crypto_repo; then :; else
echo "Must be run from Mbed TLS / TF-PSA-Crypto root" >&2 echo "Must be run from Mbed TLS / TF-PSA-Crypto root" >&2
exit 1 exit 1