Use @arg-lsit-file for jar in add-carried-jack-resources
Don't pass the arg list as argument in any bash command;
Instead store the arg list to the arg list file and
run "jar @arg-lsit-file".
Note we need to quote the arguments in the arg list file.
This fixed "argument list too long" build error on Mac.
Bug: 24789595
Change-Id: I718f84e540d82bb83516824894a473b2961da278
diff --git a/core/definitions.mk b/core/definitions.mk
index edcc1b2..9c9cb67 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2105,11 +2105,11 @@
#
define add-carried-jack-resources
$(hide) if [ -d $(PRIVATE_JACK_INTERMEDIATES_DIR) ] ; then \
- jack_res_jar_flags=$$(find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f \
- | sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C $(PRIVATE_JACK_INTERMEDIATES_DIR) ?"); \
- if [ -n "$$jack_res_jar_flags" ] ; then \
- echo $$jack_res_jar_flags >$(dir $@)jack_res_jar_flags; \
- jar uf $@ $$jack_res_jar_flags; \
+ find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f \
+ | sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C \"$(PRIVATE_JACK_INTERMEDIATES_DIR)\" \"?" -e "s/$$/\"/" \
+ > $(dir $@)jack_res_jar_flags; \
+ if [ -s $(dir $@)jack_res_jar_flags ] ; then \
+ jar uf $@ @$(dir $@)jack_res_jar_flags; \
fi; \
fi
endef