Skip to content

Commit 84fe3f0

Browse files
Pick whether to pre-generate files solely based on the component
Whether a component started with configuration-independent platform-independent generated files present or not depended on the repository and on the state of the working directory: * In TF-PSA-Crypto, we started with whatever generated files were present before invoking the script, and didn't touch them between components. * In Mbed TLS, we always started with generated files present (for subsequent components, only if they hadn't been messed up). After this change, the behavior is the same across repositories and doesn't depend on the initial state of the working directory: * `check_xxx` components start with the generated files present. This is either indifferent or necessary depending on the component. (Without generated files, some components such as `check_names` fail, while others such as `check_test_cases` miss stuff that they should check.) * Other components (`build_xxx`, `test_xxx`, etc.) start with the generated files absent. This is generally desirable so that we test that the build scripts generate them as needed. Fix #188 Signed-off-by: Gilles Peskine <[email protected]>
1 parent a6c8d75 commit 84fe3f0

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

scripts/all-core.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,9 @@ EOF
365365
# Does not remove generated source files.
366366
cleanup()
367367
{
368+
# In Mbed TLS, we do in-tree builds, so clean up.
369+
# In TF-PSA-Crypto, in-tree builds are technically possible but discouraged
370+
# and not done in all.sh so we don't clean up.
368371
if in_mbedtls_repo; then
369372
command make clean
370373
fi
@@ -874,17 +877,6 @@ pre_check_tools () {
874877
"$@" "${BASH_SOURCE%/*}"/output_env.sh
875878
}
876879
877-
pre_generate_files() {
878-
# since make doesn't have proper dependencies, remove any possibly outdate
879-
# file that might be around before generating fresh ones
880-
make neat
881-
if [ $QUIET -eq 1 ]; then
882-
make generated_files >/dev/null
883-
else
884-
make generated_files
885-
fi
886-
}
887-
888880
pre_load_helpers () {
889881
# Use a path relative to the currently-sourced file.
890882
test_script_dir="${BASH_SOURCE%/*}"
@@ -951,6 +943,27 @@ run_component () {
951943
pre_create_tf_psa_crypto_out_of_source_directory
952944
fi
953945
946+
case ${current_component#component_} in
947+
check_*|tf_psa_crypto_check*)
948+
# Many check_xxx components expect generated files to be present,
949+
# and may silently check less if they aren't.
950+
if in_mbedtls_repo; then
951+
make generated_files
952+
else
953+
$FRAMEWORK/scripts/make_generated_files.py
954+
fi;;
955+
*)
956+
# Build (and build-and-test) components are supposed to work
957+
# whether generated files are already present or not.
958+
# Test with the generated files absent, since if this works,
959+
# it's likely to work with generated files present as well.
960+
if in_mbedtls_repo; then
961+
make neat
962+
else
963+
$FRAMEWORK/scripts/make_generated_files.py --clean
964+
fi
965+
esac
966+
954967
# Run the component in a subshell, with error trapping and output
955968
# redirection set up based on the relevant options.
956969
if [ $KEEP_GOING -eq 1 ]; then
@@ -1021,9 +1034,6 @@ main () {
10211034
pre_print_configuration
10221035
pre_check_tools
10231036
cleanup
1024-
if in_mbedtls_repo; then
1025-
pre_generate_files
1026-
fi
10271037
10281038
# Run the requested tests.
10291039
for ((error_test_i=1; error_test_i <= error_test; error_test_i++)); do

0 commit comments

Comments
 (0)