-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add out of source build functions for TF-PSA-Crypto #77
base: main
Are you sure you want to change the base?
Add out of source build functions for TF-PSA-Crypto #77
Conversation
db35a71
to
6db9018
Compare
efa612e
to
8902bd5
Compare
scripts/all-core.sh
Outdated
in_tf_psa_crypto_repo | ||
running_tf_psa_crypto_test="$?" | ||
if [ "$running_tf_psa_crypto_test" -eq 0 ]; then | ||
pre_create_tf_psa_crypto_out_of_source_directory | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We run the script with set -e
active. This means that if any command exit with a nonzero status, the script exits. Note that this has a lot of limitations and pitfalls, but those limitations aren't a concern here. Also, we run parts of the script with an EXIT trap which catches some here, but that too is not relevant at this particular point in the script.
When all.sh
is running in the mbedtls repository, the command in_tf_psa_crypto_repo
exits with the status 1. This causes the whole script to exit with 1.
Here the fix is to put the command directly in an if statement. Untested:
in_tf_psa_crypto_repo | |
running_tf_psa_crypto_test="$?" | |
if [ "$running_tf_psa_crypto_test" -eq 0 ]; then | |
pre_create_tf_psa_crypto_out_of_source_directory | |
fi | |
if in_tf_psa_crypto_repo; then | |
running_tf_psa_crypto_test=1 | |
pre_create_tf_psa_crypto_out_of_source_directory | |
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for saving me that debugging headache, that makes a lot more sense to me now.
26a98cb
to
8879d15
Compare
I've ran a few various test cases for |
a8ce45b
to
d09782c
Compare
d09782c
to
1797ef2
Compare
1797ef2
to
6638abf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that can be removed now that all-core.sh does not cd automatically to the directory for the out of tree build, otherwise this looks good to me.
I think the component test_tf_psa_crypto_cmake_out_of_source of the CI against mbedtls:development fails because the component tries (as in version 9e4ac374e2 of TF-PSA-Crypto) to create the out of tree build directory while it already exists.
An update of the TF-PSA-Crypto submodule in mbedtls:development will probably be necessary.
The CI against mbedtls:mbedtls-3.6 fails completely but that does not seem to be related to the content of this PR. Error line 232 in framework/scripts/mbedtls_framework/config_common.py
but I do not understand the root cause.
scripts/all-core.sh
Outdated
# Reset working directory to TF_PSA_Crypto as it is build out of source.. | ||
if [ $running_tf_psa_crypto_test -eq 1 ]; then | ||
cd "$TF_PSA_CRYPTO_ROOT_DIR" | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be kept as components which build out of source or change directory can be reset to source directory without additional code required in those tests. Components which don't change directory will be unaffected by this line as they should already be in the source directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check with @mpg but I think components are run in a sub-shell thus if they change directory it does not matter to the calling shell and thus to all-core.sh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't read this PR and haven't investigated whether this particular cd
call is still needed. But I can confirm that components do run in a subshell, so if a component calls cd
(or sets environment variables, and a few other things), this has no impact on subsequent components.
scripts/all-core.sh
Outdated
@@ -165,13 +165,19 @@ pre_initialize_variables () { | |||
PSA_CORE_PATH='tf-psa-crypto/core' | |||
BUILTIN_SRC_PATH='tf-psa-crypto/drivers/builtin/src' | |||
CONFIG_TEST_DRIVER_H='tf-psa-crypto/tests/configs/crypto_config_test_driver.h' | |||
MBEDTLS_ROOT_DIR="$PWD" | |||
TF_PSA_CRYPTO_ROOT_DIR="$PWD/tf-psa-crypto" | |||
MBEDTLS_FRAMEWORK_ROOT_DIR="$PWD/framework" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: we already have a variable FRAMEWORK
defined in the top-level file (all.sh
), why do we need that one in addition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that I added this before it was finalised where FRAMEWORK was going to be set as a temporary workaround. I can remove that now.
This commit adds helper functions to build TF-PSA-Crypto out of source using CMake. Signed-off-by: Harry Ramsey <[email protected]>
This commit adds MBEDTLS_ROOT_DIR as a variable to the bash script. This will be used in later commits when migrating to an independent TF-PSA-Crypto testing suite. Signed-off-by: Harry Ramsey <[email protected]>
This commit fixes out of source directory builds, where in_tf_psa_crypto_repo would fail due to project_name.txt not existing. Signed-off-by: Harry Ramsey <[email protected]>
This commit adds a variable for locating Mbed TLS framework which is used to run multiple test scripts between Mbed TLS and TF-PSA-Crypto. Signed-off-by: Harry Ramsey <[email protected]>
This commit reverts changing the directory to the out of source directory, enabling tests which require source code to run. Tests that require building TF-PSA-Crypto will have to change directory to OUT_OF_SOURCE_DIR. Signed-off-by: Harry Ramsey <[email protected]>
This commit removes unnecessary directory changes as the commands for components run in subshells which do not affect the main scripts directory. Signed-off-by: Harry Ramsey <[email protected]>
This commit replaces the relative Mbed TLS out of source build path with a more generic named absolute out of source build path for both Mbed TLS and TF-PSA-Crypto. Signed-off-by: Harry Ramsey <[email protected]>
This commit removes a duplicate variable MBEDTLS_FRAMEWORK_ROOT_DIR as it is now previously defined as FRAMEWORK. Signed-off-by: Harry Ramsey <[email protected]>
2ff9ae9
to
f3044f8
Compare
This commit adds helper functions to build TF-PSA-Crypto out of source using CMake.
This commit is used for: Mbed-TLS/mbedtls#9767