From 194a8ec8aee8511d90354c4b97fecfd0df52c837 Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Mon, 6 Jun 2011 14:34:52 -0700 Subject: [PATCH] Use arg list file to pass arguments to jar. To fix error "/bin/bash: Argument list too long" Change-Id: Ie336b18f9a7eba38d94a6e32c07a88589ce9f1fd --- core/base_rules.mk | 5 +++-- core/definitions.mk | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 25564b285..02b04d67d 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -368,10 +368,11 @@ ifdef java_resource_file_groups ) \ ) # The arguments to jar that will include these files in a jar file. + # Quote the file name to handle special characters (such as #) correctly. extra_jar_args := \ $(foreach group,$(java_resource_file_groups), \ - $(addprefix -C $(word 1,$(subst :,$(space),$(group))) , \ - $(wordlist 2,9999,$(subst :,$(space),$(group))) \ + $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \ + $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \ ) \ ) java_resource_file_groups := diff --git a/core/definitions.mk b/core/definitions.mk index 89db88ea9..925101742 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1576,7 +1576,9 @@ rm -f $(_adtp_classes.dex)) endef define add-java-resources-to-package -$(hide) jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS) +$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(dir $@)jar-arg-list) +$(hide) jar uf $@ @$(dir $@)jar-arg-list +@rm -f $(dir $@)jar-arg-list endef # Sign a package using the specified key/cert. @@ -1619,7 +1621,7 @@ endef define transform-host-java-to-package @echo "host Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))" $(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH)) -$(hide) if [ ! -z "$(PRIVATE_EXTRA_JAR_ARGS)" ]; then jar uf $@ $(PRIVATE_EXTRA_JAR_ARGS); fi +$(if $(PRIVATE_EXTRA_JAR_ARGS), $(call add-java-resources-to-package)) endef ###########################################################