From a9c381ed4517993175a5bb6741ecf2aac3e8040c Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Sat, 2 Oct 2010 18:35:51 -0700 Subject: [PATCH] Any intermediate targets between Progaurd and the built_dex should be differently named. Change-Id: Ifb01b1fcf24ba0c5b98aa02dd604cd81918e1841 To do that, we have to move classes.jar step before proguard, so classes.jar is always with the full names. --- core/base_rules.mk | 4 ++-- core/java.mk | 21 +++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/base_rules.mk b/core/base_rules.mk index 0505f83f9..5bb6b77bb 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -403,8 +403,8 @@ ifdef LOCAL_INSTRUMENTATION_FOR APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON) # link against the jar with full original names (before proguard processing). - full_java_libs += $(link_instr_intermediates_dir.COMMON)/classes-full-names.jar - full_java_lib_deps += $(link_instr_intermediates_dir.COMMON)/classes-full-names.jar + full_java_libs += $(link_instr_intermediates_dir.COMMON)/classes.jar + full_java_lib_deps += $(link_instr_intermediates_dir.COMMON)/classes.jar endif ifneq ($(strip $(LOCAL_JAR_MANIFEST)),) diff --git a/core/java.mk b/core/java.mk index ab68214ed..6b8d04dae 100644 --- a/core/java.mk +++ b/core/java.mk @@ -73,11 +73,15 @@ endif # By giving different file name, files can be updated correctly when switching # between builds with and without Proguard enabled. +# Note that ANY intermediate targets between the proguard and +# the final built_dex should be differently named! ifdef LOCAL_PROGUARD_ENABLED proguard_jar_leaf := proguard.classes.jar +built_dex_intermediate_leaf := proguard.$(built_dex_intermediate_leaf) built_dex_leaf := progaurd.classes.dex else proguard_jar_leaf := noproguard.classes.jar +built_dex_intermediate_leaf := noproguard.$(built_dex_intermediate_leaf) built_dex_leaf := noproguard.classes.dex endif @@ -88,7 +92,6 @@ emma_intermediates_dir := $(intermediates.COMMON)/emma_out # emma is hardcoded to use the leaf name of its input for the output file -- # only the output directory can be changed full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf) -full_classes_full_names_jar := $(intermediates.COMMON)/classes-full-names.jar full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf) built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf) full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar @@ -101,9 +104,8 @@ LOCAL_INTERMEDIATE_TARGETS += \ $(full_classes_compiled_jar) \ $(full_classes_jarjar_jar) \ $(full_classes_emma_jar) \ - $(full_classes_full_names_jar) \ - $(full_classes_proguard_jar) \ $(full_classes_jar) \ + $(full_classes_proguard_jar) \ $(built_dex_intermediate) \ $(built_dex) \ $(full_classes_stubs_jar) @@ -224,12 +226,11 @@ $(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(ACP) endif # Keep a copy of the jar just before proguard processing. -$(full_classes_full_names_jar): $(full_classes_emma_jar) | $(ACP) +$(full_classes_jar): $(full_classes_emma_jar) | $(ACP) @echo Copying: $@ $(hide) $(ACP) $< $@ -# Run proguard if necessary, otherwise just copy the file. This is the last -# part of this step, so the output of this command is full_classes_jar. +# Run proguard if necessary, otherwise just copy the file. proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary # Proguard doesn't like a class in both library and the jar to be processed. proguard_full_java_libs := $(filter-out $(full_static_java_libs),$(full_java_libs)) @@ -266,15 +267,11 @@ LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files)) $(full_classes_proguard_jar): PRIVATE_PROGUARD_ENABLED:=$(LOCAL_PROGUARD_ENABLED) $(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(proguard_flags) $(LOCAL_PROGUARD_FLAGS) $(full_classes_proguard_jar): PRIVATE_INSTRUMENTATION_FOR:=$(strip $(LOCAL_INSTRUMENTATION_FOR)) -$(full_classes_proguard_jar) : $(full_classes_full_names_jar) $(proguard_flag_files) | $(ACP) $(PROGUARD) +$(full_classes_proguard_jar) : $(full_classes_jar) $(proguard_flag_files) | $(ACP) $(PROGUARD) $(call transform-jar-to-proguard) ALL_MODULES.$(LOCAL_MODULE).PROGUARD_ENABLED:=$(LOCAL_PROGUARD_ENABLED) -$(full_classes_jar) : $(full_classes_proguard_jar) - @echo Copying: $@ - $(hide) $(ACP) $< $@ - # If you instrument class files that have local variable debug information in # them emma does not correctly maintain the local variable table. # This will cause an error when you try to convert the class files for Android. @@ -289,7 +286,7 @@ $(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) ifneq ($(LOCAL_NO_EMMA_COMPILE),true) $(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals endif -$(built_dex_intermediate): $(full_classes_jar) $(DX) +$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX) $(transform-classes.jar-to-dex) $(built_dex): $(built_dex_intermediate) | $(ACP) @echo Copying: $@