Support dx generating multiple dex files.

Dx is now capable of generating multiple dex file in one run.
This capability is not compatible with --output=*.dex so this CL
changes the --output argument to be a directory. This CL also
includes the packaging of the multiple dex files when dx generates
more than one dex file.

Change-Id: I1ddc91b416de5929d4d4b41824c6012b32f94deb
This commit is contained in:
Yohann Roussel 2013-08-20 17:05:27 +02:00
parent 43e3a9de0e
commit 8ffe9c3e79
2 changed files with 10 additions and 11 deletions

View File

@ -1589,9 +1589,10 @@ endef
define transform-classes.jar-to-dex
@echo "target Dex: $(PRIVATE_MODULE)"
@mkdir -p $(dir $@)
$(hide) rm -f $(dir $@)/classes*.dex
$(hide) $(DX) \
$(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx2048M) \
--dex --output=$@ \
--dex --output=$(dir $@) \
$(incremental_dex) \
$(if $(NO_OPTIMIZE_DX), \
--no-optimize) \
@ -1651,11 +1652,7 @@ endef
#TODO: update the manifest to point to the dex file
define add-dex-to-package
$(if $(filter classes.dex,$(notdir $(PRIVATE_DEX_FILE))),\
$(hide) zip -qj $@ $(PRIVATE_DEX_FILE),\
$(hide) _adtp_classes_dex=$(dir $(PRIVATE_DEX_FILE))classes.dex; \
cp $(PRIVATE_DEX_FILE) $$_adtp_classes_dex && \
zip -qj $@ $$_adtp_classes_dex && rm -f $$_adtp_classes_dex)
$(hide) zip -qj $@ $(dir $(PRIVATE_DEX_FILE))/classes*.dex
endef
# Add java resources added by the current module.

View File

@ -82,10 +82,10 @@ intermediates.COMMON := $(call local-intermediates-dir,COMMON)
# Choose leaf name for the compiled jar file.
ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
full_classes_compiled_jar_leaf := classes-no-debug-var.jar
built_dex_intermediate_leaf := classes-no-local.dex
built_dex_intermediate_leaf := no-local
else
full_classes_compiled_jar_leaf := classes-full-debug.jar
built_dex_intermediate_leaf := classes-with-local.dex
built_dex_intermediate_leaf := with-local
endif
LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
@ -115,12 +115,12 @@ emma_intermediates_dir := $(intermediates.COMMON)/emma_out
# only the output directory can be changed
full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf)
full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf)
built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)
built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)/classes.dex
full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
# full_classes_jar and built_dex are cleared below, and re-set if we really need them.
full_classes_jar := $(intermediates.COMMON)/classes.jar
built_dex := $(intermediates.COMMON)/$(built_dex_leaf)
built_dex := $(intermediates.COMMON)/$(built_dex_leaf)/classes.dex
LOCAL_INTERMEDIATE_TARGETS += \
$(full_classes_compiled_jar) \
@ -441,7 +441,9 @@ $(built_dex_intermediate): $(full_classes_proguard_jar) $(DX)
$(transform-classes.jar-to-dex)
$(built_dex): $(built_dex_intermediate) | $(ACP)
@echo Copying: $@
$(hide) $(ACP) -fp $< $@
$(hide) mkdir -p $(dir $@)
$(hide) rm -f $(dir $@)/classes*.dex
$(hide) $(ACP) -fp $(dir $<)/classes*.dex $(dir $@)
ifneq ($(GENERATE_DEX_DEBUG),)
$(install-dex-debug)
endif