Merge pull request #253 from gilles-peskine-arm/all.sh-cleanup-cmake-only-in-tree

Only clean CMake artifacts in-tree
This commit is contained in:
Valerio Setti
2026-01-08 10:49:05 +01:00
committed by GitHub
+30 -19
View File
@@ -369,6 +369,19 @@ Tool path options:
EOF
}
# list_git_files PATTERN...
# List files known to git, matching pattern.
# Equivalent to `git ls-files --recurse-submodules PATTERN...`, but
# works with older Git (especially on Ubuntu 16.04) that understand
# submodules but not `git ls-files --recurse-submodules`.
list_git_files ()
{
git ls-files -- "$@"
for d in $(git submodule status --recursive | awk '{print $2}'); do
git ls-files "$@" | sed "s!^!$d/!"
done
}
# Cleanup before/after running a component.
# Remove built files as well as the cmake cache/config.
# Does not remove generated source files.
@@ -378,25 +391,23 @@ cleanup()
command $MAKE_COMMAND clean
fi
# Remove CMake artefacts
find . -name .git -prune -o \
-iname CMakeFiles -exec rm -rf {} \+ -o \
\( -iname cmake_install.cmake -o \
-iname CTestTestfile.cmake -o \
-iname CMakeCache.txt -o \
-path './cmake/*.cmake' \) -exec rm -f {} \+
# Remove Makefiles generated by in-tree CMake builds
# (Not all files will exist in all branches, but that's OK.)
rm -f 3rdparty/Makefile 3rdparty/*/Makefile
rm -f pkgconfig/Makefile framework/Makefile
rm -f include/Makefile programs/!(fuzz)/Makefile
rm -f tf-psa-crypto/Makefile tf-psa-crypto/include/Makefile
rm -f tf-psa-crypto/core/Makefile tf-psa-crypto/drivers/Makefile
rm -f tf-psa-crypto/tests/Makefile
rm -f tf-psa-crypto/drivers/everest/Makefile
rm -f tf-psa-crypto/drivers/p256-m/Makefile
rm -f tf-psa-crypto/drivers/builtin/Makefile
rm -f tf-psa-crypto/drivers/builtin/src/Makefile
# Remove files left over by an in-tree CMake build.
# Take care to only hit in-tree builds, not out-of-tree builds in
# subdirectories.
# Remove **/Makefile only if it looks like it was created by an in-tree
# CMake build.
local cmakelists=($(list_git_files 'CMakeLists.txt' '**/CMakeLists.txt'))
for f in "${cmakelists[@]}"; do
local d="$(dirname -- "$f")"
if [ -d "$d/CMakeFiles" ]; then
rm -rf "$d/CMakeFiles" \
"$d/cmake_install.cmake" \
"$d/CTestTestfile.cmake" \
"$d/CMakeCache.txt" \
"$d/Makefile"
rm -rf "$d/cmake"/*.cmake
fi
done
# Remove any artifacts from the component_test_cmake_as_subdirectory test.
rm -rf programs/test/cmake_subproject/build