summaryrefslogtreecommitdiff
path: root/top/maint.mk
diff options
context:
space:
mode:
authorRoman Bolshakov <r.bolshakov@yadro.com>2018-12-13 18:34:52 +0300
committerEric Blake <eblake@redhat.com>2019-01-02 14:06:45 -0600
commit64e5ddb08f39360494b8298c1d249c8813949749 (patch)
tree0b51978bd655d471957cd68edc1500fc2518a8ef /top/maint.mk
parent4652c7bafa60332145f1e05a7de5f48e1bc56226 (diff)
downloadgnulib-64e5ddb08f39360494b8298c1d249c8813949749.tar.gz
maint.mk: Split long argument lists
$(VC_LIST_EXCEPT) is usually expanded into arguments for a command. When a project contains too many, some operating systems can't pass all the arguments because they hit the limit of arguments. FreeBSD and macOS are known to have the exec limit of 256k memory used by arguments. More on the issue: http://lists.gnu.org/archive/html/bug-gnulib/2015-08/msg00019.html https://www.redhat.com/archives/libvir-list/2015-August/msg00758.html xargs without flags can be used to limit number of arguments, coupled with use of the shell's built-in echo which is not subject to the exec limits. Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com> Message-Id: <20181213153453.38123-2-r.bolshakov@yadro.com> Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'top/maint.mk')
-rw-r--r--top/maint.mk135
1 files changed, 86 insertions, 49 deletions
diff --git a/top/maint.mk b/top/maint.mk
index cce0628fd5..4087490ef3 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -302,32 +302,46 @@ define _sc_search_regexp
fi; \
\
: Filter by content; \
- test -n "$$files" && test -n "$$containing" \
- && { files=$$(grep -l "$$containing" $$files); } || :; \
- test -n "$$files" && test -n "$$non_containing" \
- && { files=$$(grep -vl "$$non_containing" $$files); } || :; \
+ test -n "$$files" \
+ && test -n "$$containing" \
+ && { files=$$(echo "$$files" | xargs grep -l "$$containing"); } \
+ || :; \
+ test -n "$$files" \
+ && test -n "$$non_containing" \
+ && { files=$$(echo "$$files" | xargs grep -vl "$$non_containing"); } \
+ || :; \
\
: Check for the construct; \
if test -n "$$files"; then \
if test -n "$$prohibit"; then \
- grep $$with_grep_options $(_ignore_case) -nE "$$prohibit" $$files \
+ echo "$$files"
+ | xargs grep $$with_grep_options $(_ignore_case) -nE \
+ "$$prohibit" /dev/null \
| grep -vE "$${exclude:-^$$}" \
- && { msg="$$halt" $(_sc_say_and_exit) } || :; \
+ && { msg="$$halt" $(_sc_say_and_exit) } \
+ || :; \
else \
- grep $$with_grep_options $(_ignore_case) -LE "$$require" $$files \
- | grep . \
- && { msg="$$halt" $(_sc_say_and_exit) } || :; \
+ echo "$$files" \
+ | xargs \
+ grep $$with_grep_options $(_ignore_case) -LE "$$require" \
+ | grep . \
+ && { msg="$$halt" $(_sc_say_and_exit) } \
+ || :; \
fi \
else :; \
fi || :;
endef
sc_avoid_if_before_free:
- @$(srcdir)/$(_build-aux)/useless-if-before-free \
- $(useless_free_options) \
- $$($(VC_LIST_EXCEPT) | grep -v useless-if-before-free) && \
- { echo '$(ME): found useless "if" before "free" above' 1>&2; \
- exit 1; } || :
+ @$(VC_LIST_EXCEPT) \
+ | grep -v useless-if-before-free \
+ | xargs \
+ $(srcdir)/$(_build-aux)/useless-if-before-free \
+ $(useless_free_options) \
+ && { printf '$(ME): found useless "if"' \
+ ' before "free" above\n' 1>&2; \
+ exit 1; } \
+ || :
sc_cast_of_argument_to_free:
@prohibit='\<free *\( *\(' halt="don't cast free argument" \
@@ -399,25 +413,31 @@ sc_error_exit_success:
# "FATAL:" should be fully upper-cased in error messages
# "WARNING:" should be fully upper-cased, or fully lower-cased
sc_error_message_warn_fatal:
- @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
- | grep -E '"Warning|"Fatal|"fatal' && \
- { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
- exit 1; } || :
+ @$(VC_LIST_EXCEPT) \
+ | xargs grep -nEA2 '[^rp]error *\(' /dev/null \
+ | grep -E '"Warning|"Fatal|"fatal' \
+ && { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
+ exit 1; } \
+ || :
# Error messages should not start with a capital letter
sc_error_message_uppercase:
- @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
- | grep -E '"[A-Z]' \
- | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
- { echo '$(ME): found capitalized error message' 1>&2; \
- exit 1; } || :
+ @$(VC_LIST_EXCEPT) \
+ | xargs grep -nEA2 '[^rp]error *\(' /dev/null \
+ | grep -E '"[A-Z]' \
+ | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' \
+ && { echo '$(ME): found capitalized error message' 1>&2; \
+ exit 1; } \
+ || :
# Error messages should not end with a period
sc_error_message_period:
- @grep -nEA2 '[^rp]error *\(' $$($(VC_LIST_EXCEPT)) \
- | grep -E '[^."]\."' && \
- { echo '$(ME): found error message ending in period' 1>&2; \
- exit 1; } || :
+ @$(VC_LIST_EXCEPT) \
+ | xargs grep -nEA2 '[^rp]error *\(' /dev/null \
+ | grep -E '[^."]\."' \
+ && { echo '$(ME): found error message ending in period' 1>&2; \
+ exit 1; } \
+ || :
sc_file_system:
@prohibit=file''system \
@@ -845,9 +865,14 @@ sc_prohibit_always-defined_macros:
case $$(echo all: | grep -l -f - Makefile) in Makefile);; *) \
echo '$(ME): skipping $@: you lack GNU grep' 1>&2; exit 0;; \
esac; \
- $(def_sym_regex) | grep -E -f - $$($(VC_LIST_EXCEPT)) \
- && { echo '$(ME): define the above via some gnulib .h file' \
- 1>&2; exit 1; } || :; \
+ regex=$$($(def_sym_regex)); export regex; \
+ $(VC_LIST_EXCEPT) \
+ | xargs sh -c 'echo $$regex | grep -E -f - "$$@"' \
+ dummy /dev/null \
+ && { printf '$(ME): define the above' \
+ ' via some gnulib .h file\n' 1>&2; \
+ exit 1; } \
+ || :; \
fi
# ==================================================================
@@ -927,9 +952,11 @@ require_exactly_one_NL_at_EOF_ = \
} \
END { exit defined $$fail }
sc_prohibit_empty_lines_at_EOF:
- @perl -le '$(require_exactly_one_NL_at_EOF_)' $$($(VC_LIST_EXCEPT)) \
- || { echo '$(ME): empty line(s) or no newline at EOF' \
- 1>&2; exit 1; } || :
+ @$(VC_LIST_EXCEPT) \
+ | xargs perl -le '$(require_exactly_one_NL_at_EOF_)' \
+ || { echo '$(ME): empty line(s) or no newline at EOF' 1>&2; \
+ exit 1; } \
+ || :
# Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
# This is a bit of a kludge, since it prevents use of the string
@@ -972,9 +999,12 @@ prohibit_doubled_word_ = \
ignore_doubled_word_match_RE_ ?= ^$$
sc_prohibit_doubled_word:
- @perl -n -0777 $(prohibit_doubled_word_) $$($(VC_LIST_EXCEPT)) \
+ @$(VC_LIST_EXCEPT) \
+ | xargs perl -n -0777 $(prohibit_doubled_word_) \
| grep -vE '$(ignore_doubled_word_match_RE_)' \
- | grep . && { echo '$(ME): doubled words' 1>&2; exit 1; } || :
+ | grep . \
+ && { echo '$(ME): doubled words' 1>&2; exit 1; } \
+ || :
# A regular expression matching undesirable combinations of words like
# "can not"; this matches them even when the two words appear on different
@@ -998,10 +1028,12 @@ prohibit_undesirable_word_seq_ = \
ignore_undesirable_word_sequence_RE_ ?= ^$$
sc_prohibit_undesirable_word_seq:
- @perl -n -0777 $(prohibit_undesirable_word_seq_) \
- $$($(VC_LIST_EXCEPT)) \
- | grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep . \
- && { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
+ @$(VC_LIST_EXCEPT) \
+ | xargs perl -n -0777 $(prohibit_undesirable_word_seq_) \
+ | grep -vE '$(ignore_undesirable_word_sequence_RE_)' \
+ | grep . \
+ && { echo '$(ME): undesirable word sequence' >&2; exit 1; } \
+ || :
# Except for shell files and for loops, double semicolon is probably a mistake
sc_prohibit_double_semicolon:
@@ -1033,7 +1065,8 @@ sc_prohibit_test_double_equal:
# definition of LDADD from the appropriate Makefile.am and exits 0
# when it contains "ICONV".
sc_proper_name_utf8_requires_ICONV:
- @progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
+ @progs=$$($(VC_LIST_EXCEPT) \
+ | xargs grep -l 'proper_name_utf8 ''("'); \
if test "x$$progs" != x; then \
fail=0; \
for p in $$progs; do \
@@ -1155,10 +1188,11 @@ sc_po_check:
@if test -f $(po_file); then \
grep -E -v '^(#|$$)' $(po_file) \
| grep -v '^src/false\.c$$' | sort > $@-1; \
- files=$$(perl $(perl_translatable_files_list_) \
- $$($(VC_LIST_EXCEPT)) $(generated_files)); \
- grep -E -l '$(_gl_translatable_string_re)' $$files \
- | $(SED) 's|^$(_dot_escaped_srcdir)/||' | sort -u > $@-2; \
+ { $(VC_LIST_EXCEPT); echo $(generated_files); } \
+ | xargs perl $(perl_translatable_files_list_) \
+ | xargs grep -E -l '$(_gl_translatable_string_re)' \
+ | $(SED) 's|^$(_dot_escaped_srcdir)/||' \
+ | sort -u > $@-2; \
diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
|| { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
rm -f $@-1 $@-2; \
@@ -1229,11 +1263,14 @@ sc_cross_check_PATH_usage_in_tests:
|| { echo "$@: $(_hv_file) lacks conforming use of init.sh" 1>&2; \
exit 1; }; \
good=$$(grep -E '$(_hv_regex_strong)' $(_hv_file)); \
- grep -LFx "$$good" \
- $$(grep -lE '$(_hv_regex_weak)' $$($(VC_LIST_EXCEPT))) \
- | grep . && \
- { echo "$(ME): the above files use path_prepend_ inconsistently" \
- 1>&2; exit 1; } || :; \
+ $(VC_LIST_EXCEPT) \
+ | xargs grep -lE '$(_hv_regex_weak)' \
+ | xargs grep -LFx "$$good" \
+ | grep . \
+ && { printf "$(ME): the above files use" \
+ " path_prepend_ inconsistently\n" 1>&2; \
+ exit 1; } \
+ || :; \
fi
# BRE regex of file contents to identify a test script.