Optimize out extra jar copies
Don't copy jar files for disabled stages. Instead, set the name of the output to the name of the input so the next stage will directly pick up the output of the previous stage. Test: m -j ANDROID_COMPILE_WITH_JACK=false java Change-Id: Ib7268cbff7ea7ff2ad2caf994aa145e1b7a12b83
This commit is contained in:
@@ -118,14 +118,10 @@ $(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) |
|
|||||||
@echo JarJar: $@
|
@echo JarJar: $@
|
||||||
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
||||||
else
|
else
|
||||||
$(full_classes_jarjar_jar): $(full_classes_desugar_jar) | $(ACP)
|
full_classes_jarjar_jar := $(full_classes_desugar_jar)
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
|
$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
|
|
||||||
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
|
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
|
||||||
# No dex; all we want are the .class files with resources.
|
# No dex; all we want are the .class files with resources.
|
||||||
|
@@ -82,9 +82,7 @@ $(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) |
|
|||||||
@echo JarJar: $@
|
@echo JarJar: $@
|
||||||
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
||||||
else
|
else
|
||||||
$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
|
full_classes_jarjar_jar := $(full_classes_compiled_jar)
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
||||||
@@ -101,13 +99,8 @@ endif
|
|||||||
# $(full_classes_emma_jar)
|
# $(full_classes_emma_jar)
|
||||||
$(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
|
$(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
|
||||||
$(transform-classes.jar-to-emma)
|
$(transform-classes.jar-to-emma)
|
||||||
|
|
||||||
$(LOCAL_BUILT_MODULE) : $(full_classes_emma_jar)
|
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
|
|
||||||
else # LOCAL_EMMA_INSTRUMENT
|
else # LOCAL_EMMA_INSTRUMENT
|
||||||
$(LOCAL_BUILT_MODULE) : $(full_classes_jarjar_jar) | $(ACP)
|
full_classes_emma_jar := $(full_classes_jarjar_jar)
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
endif # LOCAL_EMMA_INSTRUMENT
|
endif # LOCAL_EMMA_INSTRUMENT
|
||||||
|
|
||||||
|
$(eval $(call copy-one-file,$(full_classes_emma_jar),$(LOCAL_BUILT_MODULE)))
|
||||||
|
43
core/java.mk
43
core/java.mk
@@ -109,12 +109,6 @@ ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
|
|||||||
LOCAL_PROGUARD_ENABLED :=
|
LOCAL_PROGUARD_ENABLED :=
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef LOCAL_PROGUARD_ENABLED
|
|
||||||
proguard_jar_leaf := proguard.classes.jar
|
|
||||||
else
|
|
||||||
proguard_jar_leaf := noproguard.classes.jar
|
|
||||||
endif
|
|
||||||
|
|
||||||
full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_jar_leaf)
|
full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_jar_leaf)
|
||||||
full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar
|
full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar
|
||||||
jarjar_leaf := classes-jarjar.jar
|
jarjar_leaf := classes-jarjar.jar
|
||||||
@@ -123,7 +117,7 @@ emma_intermediates_dir := $(intermediates.COMMON)/emma_out
|
|||||||
# emma is hardcoded to use the leaf name of its input for the output file --
|
# emma is hardcoded to use the leaf name of its input for the output file --
|
||||||
# only the output directory can be changed
|
# only the output directory can be changed
|
||||||
full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf)
|
full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf)
|
||||||
full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf)
|
full_classes_proguard_jar := $(intermediates.COMMON)/proguard.classes.jar
|
||||||
built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)/classes.dex
|
built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)/classes.dex
|
||||||
full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
|
full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
|
||||||
|
|
||||||
@@ -411,15 +405,7 @@ ifdef full_classes_jar
|
|||||||
# Droiddoc isn't currently able to generate stubs for modules, so we're just
|
# Droiddoc isn't currently able to generate stubs for modules, so we're just
|
||||||
# allowing it to use the classes.jar as the "stubs" that would be use to link
|
# allowing it to use the classes.jar as the "stubs" that would be use to link
|
||||||
# against, for the cases where someone needs the jar to link against.
|
# against, for the cases where someone needs the jar to link against.
|
||||||
# - Use the classes.jar instead of the handful of other intermediates that
|
$(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar)))
|
||||||
# we have, because it's the most processed, but still hasn't had dex run on
|
|
||||||
# it, so it's closest to what's on the device.
|
|
||||||
# - This extra copy, with the dependency on LOCAL_BUILT_MODULE allows the
|
|
||||||
# PRIVATE_ vars to be preserved.
|
|
||||||
$(full_classes_stubs_jar): PRIVATE_SOURCE_FILE := $(full_classes_jar)
|
|
||||||
$(full_classes_stubs_jar) : $(full_classes_jar) | $(ACP)
|
|
||||||
@echo Copying $(PRIVATE_SOURCE_FILE)
|
|
||||||
$(hide) $(ACP) -fp $(PRIVATE_SOURCE_FILE) $@
|
|
||||||
ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
|
ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
|
||||||
|
|
||||||
# The layers file allows you to enforce a layering between java packages.
|
# The layers file allows you to enforce a layering between java packages.
|
||||||
@@ -466,16 +452,14 @@ ifndef my_desugaring
|
|||||||
full_classes_desugar_jar := $(full_classes_compiled_jar)
|
full_classes_desugar_jar := $(full_classes_compiled_jar)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Run jarjar if necessary, otherwise just copy the file.
|
# Run jarjar if necessary
|
||||||
ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
|
ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
|
||||||
$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
|
$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
|
||||||
$(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
|
$(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
|
||||||
@echo JarJar: $@
|
@echo JarJar: $@
|
||||||
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
|
||||||
else
|
else
|
||||||
$(full_classes_jarjar_jar): $(full_classes_desugar_jar) | $(ACP)
|
full_classes_jarjar_jar := $(full_classes_desugar_jar)
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
|
ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
|
||||||
@@ -496,20 +480,16 @@ $(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(EMMA_JAR)
|
|||||||
$(transform-classes.jar-to-emma)
|
$(transform-classes.jar-to-emma)
|
||||||
|
|
||||||
else
|
else
|
||||||
$(full_classes_emma_jar): $(full_classes_jarjar_jar)
|
full_classes_emma_jar := $(full_classes_jarjar_jar)
|
||||||
@echo Copying: $@
|
|
||||||
$(copy-file-to-target)
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Keep a copy of the jar just before proguard processing.
|
# Keep a copy of the jar just before proguard processing.
|
||||||
# TODO: this should depend on full_classes_emma_jar once coverage works again
|
# TODO: this should depend on full_classes_emma_jar once coverage works again
|
||||||
$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
|
$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
|
|
||||||
$(call define-jar-to-toc-rule, $(full_classes_jar))
|
$(call define-jar-to-toc-rule, $(full_classes_jar))
|
||||||
|
|
||||||
# Run proguard if necessary, otherwise just copy the file.
|
# Run proguard if necessary
|
||||||
ifdef LOCAL_PROGUARD_ENABLED
|
ifdef LOCAL_PROGUARD_ENABLED
|
||||||
ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
|
ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
|
||||||
$(warning while processing: $(LOCAL_MODULE))
|
$(warning while processing: $(LOCAL_MODULE))
|
||||||
@@ -642,10 +622,7 @@ $(full_classes_proguard_jar) : $(full_classes_jar) $(extra_input_jar) $(my_suppo
|
|||||||
$(call transform-jar-to-proguard)
|
$(call transform-jar-to-proguard)
|
||||||
|
|
||||||
else # LOCAL_PROGUARD_ENABLED not defined
|
else # LOCAL_PROGUARD_ENABLED not defined
|
||||||
$(full_classes_proguard_jar) : $(full_classes_jar) | $(ACP)
|
full_classes_proguard_jar := $(full_classes_jar)
|
||||||
@echo Copying: $@
|
|
||||||
$(hide) $(ACP) -fp $< $@
|
|
||||||
|
|
||||||
endif # LOCAL_PROGUARD_ENABLED defined
|
endif # LOCAL_PROGUARD_ENABLED defined
|
||||||
|
|
||||||
ifndef LOCAL_JACK_ENABLED
|
ifndef LOCAL_JACK_ENABLED
|
||||||
@@ -663,11 +640,11 @@ $(built_dex_intermediate): $(full_classes_proguard_jar) $(DX)
|
|||||||
$(transform-classes.jar-to-dex)
|
$(transform-classes.jar-to-dex)
|
||||||
endif # LOCAL_JACK_ENABLED is disabled
|
endif # LOCAL_JACK_ENABLED is disabled
|
||||||
|
|
||||||
$(built_dex): $(built_dex_intermediate) | $(ACP)
|
$(built_dex): $(built_dex_intermediate)
|
||||||
@echo Copying: $@
|
@echo Copying: $@
|
||||||
$(hide) mkdir -p $(dir $@)
|
$(hide) mkdir -p $(dir $@)
|
||||||
$(hide) rm -f $(dir $@)/classes*.dex
|
$(hide) rm -f $(dir $@)/classes*.dex
|
||||||
$(hide) $(ACP) -fp $(dir $<)/classes*.dex $(dir $@)
|
$(hide) cp -fp $(dir $<)/classes*.dex $(dir $@)
|
||||||
|
|
||||||
findbugs_xml := $(intermediates.COMMON)/findbugs.xml
|
findbugs_xml := $(intermediates.COMMON)/findbugs.xml
|
||||||
$(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
|
$(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
|
||||||
|
Reference in New Issue
Block a user