diff --git a/scripts/demo_common.sh b/scripts/demo_common.sh index 4ad4c7187..8f5c942d0 100644 --- a/scripts/demo_common.sh +++ b/scripts/demo_common.sh @@ -16,14 +16,13 @@ set -e -u -DEMO_COMMON_NEED_QUERY_COMPILE_TIME_CONFIG=${DEMO_COMMON_NEED_QUERY_COMPILE_TIME_CONFIG:-1} - -need_query_compile_time_config () { - if [ $DEMO_COMMON_NEED_QUERY_COMPILE_TIME_CONFIG -eq 1 ]; then - return 0; - else +# Check if the provided path ($1) can be a valid root for Mbed TLS or TF-PSA-Crypto. +# This is based on the fact that "scripts/project_name.txt" exists. +is_valid_root () { + if ! [ -f "$1/scripts/project_name.txt" ]; then return 1; fi + return 0; } ## At the end of the while loop below $root_dir will point to the root directory @@ -35,21 +34,15 @@ root_dir="${0%/*}" ## ## The code works no matter where the demo script is relative to the current ## directory, even if it is called with a relative path. -n=5 +n=4 while true; do # If we went up too many folders, then give up and return a failure. if [ $n -eq 0 ]; then echo >&2 "This doesn't seem to be an Mbed TLS source tree." exit 125 fi - # If we reached the Mbed TLS root folder then we're done. - if is_mbedtls_root "$root_dir"; then - break; - fi - # If we reached the TF-PSA-Crypto root folder and the script that sourced - # this file does not need query_compile_time_config (which is only available - # in Mbed TLS repo) then we're done. - if is_tf_psa_crypto_root "$root_dir" && ! need_query_compile_time_config; then + + if is_valid_root "$root_dir"; then break; fi @@ -63,6 +56,9 @@ while true; do esac done +# Now that we have a root path we can source the "project_detection.sh" script. +. "$root_dir/framework/scripts/project_detection.sh" + ## msg LINE... ## msg