Make dump-many-vars work for large variables

When printing a large variable like PRODUCT_PACKAGES,
dump-many-vars could fail because the command line is
too long. This is seen as a E2BIG error on the execve
in kati.

To solve this, split the printing up by word in the
variable.

Change-Id: I49db726d7a4769a2f02028194d79934ed5655adf
Fixes: 172287533
Test: lunch bonito-userdebug; get_build_var PRODUCT_PACKAGES
This commit is contained in:
Cole Faust 2020-11-03 23:59:50 +00:00
parent c0f701287c
commit 2ce1fd907b

View file

@ -24,9 +24,14 @@ ANDROID_CLANG_PREBUILTS := prebuilts/clang/host/$(HOST_PREBUILT_TAG)
# Input variables: # Input variables:
# DUMP_MANY_VARS: the list of variable names. # DUMP_MANY_VARS: the list of variable names.
# DUMP_VAR_PREFIX: an optional prefix of the variable name added to the output. # DUMP_VAR_PREFIX: an optional prefix of the variable name added to the output.
# The value is printed in parts because large variables like PRODUCT_PACKAGES
# can exceed the maximum linux command line size
.PHONY: dump-many-vars .PHONY: dump-many-vars
dump-many-vars : dump-many-vars :
@$(foreach v, $(DUMP_MANY_VARS),\ @$(foreach v, $(DUMP_MANY_VARS),\
printf "%s='%s'\n" '$(DUMP_VAR_PREFIX)$(v)' '$($(v))';) printf "%s='%s" '$(DUMP_VAR_PREFIX)$(v)' '$(firstword $($(v)))'; \
$(foreach part, $(wordlist 2, $(words $($(v))), $($(v))),\
printf " %s" '$(part)'$(newline))\
printf "'\n";)
endif # CALLED_FROM_SETUP endif # CALLED_FROM_SETUP