Skip to content
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

make clean: split file list into manageable chunks #1897

Merged
merged 1 commit into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ include mk/cleandirs.mk
.PHONY: clean
clean:
@$(cmd-echo-silent) ' CLEAN $(out-dir)'
${q}rm -f $(cleanfiles)
$(call do-rm-f, $(cleanfiles))
${q}dirs="$(call cleandirs-for-rmdir)"; if [ "$$dirs" ]; then $(RMDIR) $$dirs; fi
@if [ "$(out-dir)" != "$(O)" ]; then $(cmd-echo-silent) ' CLEAN $(O)'; fi
${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi
Expand Down
14 changes: 14 additions & 0 deletions mk/cleandirs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ $(eval _O:=$(if $(O),$(O),.))$(wildcard $(addprefix $(_O)/,$(call _reverse,
endef

RMDIR := rmdir --ignore-fail-on-non-empty

# Remove files with "rm -f".
# Split (possibly huge) file list into more manageable lines
# (200 files at a time), to minimize the odds of having:
# "/bin/bash: Argument list too long"
define do-rm-f
$(call _do-rm-f, $(wordlist 1, 200, $(1)))
$(eval _tail := $(wordlist 201, $(words $(1)), $(1)))
$(if $(_tail), $(call do-rm-f, $(_tail)))
endef

define _do-rm-f
${q}rm -f $1
endef