Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions scripts/all-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 cmake_dirs=($(list_git_files 'CMakeLists.txt' '**/CMakeLists.txt' |
sed -e 's![^/]*$!!'))
for d in "${cmake_dirs[@]}"; do
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
Expand Down