1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-05 19:35:48 +03:00

all.sh: improve check for clean config files

The existing check only took care of CONFIG_H. This was both not enough
and too much:
- not enough because config.py can also modify CRYPTO_CONFIG_H and we
want to know about it just as much as CONFIG_H;
- too much because CONFIG_H does not exist in tf-psa-crypto.

Check a list of files instead of a single one, and adjust that list.

Also update an outdated comment about Makefiles

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard
2024-10-23 09:53:54 +02:00
parent 621c96a71f
commit 69fe0e8bf4

View File

@@ -109,11 +109,12 @@
# means that components can assume that the working directory is in a # means that components can assume that the working directory is in a
# cleaned-up state, and don't need to perform the cleanup themselves. # cleaned-up state, and don't need to perform the cleanup themselves.
# * Run `make clean`. # * Run `make clean`.
# * Restore `include/mbedtls/mbedtls_config.h` from a backup made before running # * Restore the various config files (potentially modified by config.py) from
# the component. # a backup made when starting the script.
# * Check out `Makefile`, `library/Makefile`, `programs/Makefile`, # * If in Mbed TLS, restore the various `Makefile`s (potentially modified by
# `tests/Makefile` and `programs/fuzz/Makefile` from git. # in-tree use of CMake) from a backup made when starting the script. (Note:
# This cleans up after an in-tree use of CMake. # if the files look generated when starting the script, they will be
# restored from the git index before making the backup.)
################################################################ ################################################################
@@ -165,6 +166,7 @@ pre_load_components () {
pre_initialize_variables () { pre_initialize_variables () {
if in_mbedtls_repo; then if in_mbedtls_repo; then
CONFIG_H='include/mbedtls/mbedtls_config.h' CONFIG_H='include/mbedtls/mbedtls_config.h'
CONFIG_TEST_DRIVER_H='tests/include/test/drivers/config_test_driver.h'
if [ -d tf-psa-crypto ]; then if [ -d tf-psa-crypto ]; then
CRYPTO_CONFIG_H='tf-psa-crypto/include/psa/crypto_config.h' CRYPTO_CONFIG_H='tf-psa-crypto/include/psa/crypto_config.h'
PSA_CORE_PATH='tf-psa-crypto/core' PSA_CORE_PATH='tf-psa-crypto/core'
@@ -176,20 +178,21 @@ pre_initialize_variables () {
PSA_CORE_PATH='' PSA_CORE_PATH=''
BUILTIN_SRC_PATH='' BUILTIN_SRC_PATH=''
fi fi
config_files="$CONFIG_H $CRYPTO_CONFIG_H $CONFIG_TEST_DRIVER_H"
else else
CONFIG_H='drivers/builtin/include/mbedtls/mbedtls_config.h'
CRYPTO_CONFIG_H='include/psa/crypto_config.h' CRYPTO_CONFIG_H='include/psa/crypto_config.h'
PSA_CORE_PATH='core' PSA_CORE_PATH='core'
BUILTIN_SRC_PATH='drivers/builtin/src' BUILTIN_SRC_PATH='drivers/builtin/src'
config_files="$CRYPTO_CONFIG_H"
fi fi
CONFIG_TEST_DRIVER_H='tests/include/test/drivers/config_test_driver.h'
# Files that are clobbered by some jobs will be backed up. Use a different # Files that are clobbered by some jobs will be backed up. Use a different
# suffix from auxiliary scripts so that all.sh and auxiliary scripts can # suffix from auxiliary scripts so that all.sh and auxiliary scripts can
# independently decide when to remove the backup file. # independently decide when to remove the backup file.
backup_suffix='.all.bak' backup_suffix='.all.bak'
# Files clobbered by config.py # Files clobbered by config.py
files_to_back_up="$CONFIG_H $CRYPTO_CONFIG_H $CONFIG_TEST_DRIVER_H" files_to_back_up="$config_files"
if in_mbedtls_repo; then if in_mbedtls_repo; then
# Files clobbered by in-tree cmake # Files clobbered by in-tree cmake
files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile" files_to_back_up="$files_to_back_up Makefile library/Makefile programs/Makefile tests/Makefile programs/fuzz/Makefile"
@@ -623,7 +626,7 @@ pre_parse_command_line () {
pre_check_git () { pre_check_git () {
if [ $FORCE -eq 1 ]; then if [ $FORCE -eq 1 ]; then
rm -rf "$OUT_OF_SOURCE_DIR" rm -rf "$OUT_OF_SOURCE_DIR"
git checkout-index -f -q $CONFIG_H git checkout-index -f -q $config_files
cleanup cleanup
else else
@@ -634,12 +637,14 @@ pre_check_git () {
exit 1 exit 1
fi fi
if ! git diff --quiet "$CONFIG_H"; then for config in $config_files; do
err_msg "Warning - the configuration file '$CONFIG_H' has been edited. " if ! git diff --quiet "$config"; then
err_msg "Warning - the configuration file '$config' has been edited. "
echo "You can either delete or preserve your work, or force the test by rerunning the" echo "You can either delete or preserve your work, or force the test by rerunning the"
echo "script as: $0 --force" echo "script as: $0 --force"
exit 1 exit 1
fi fi
done
fi fi
} }