Fix and enable proguard on packages.
This commit is contained in:
46
core/java.mk
46
core/java.mk
@@ -70,6 +70,7 @@ emma_intermediates_dir := $(intermediates.COMMON)/emma_out
|
||||
full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(full_classes_compiled_jar_leaf)
|
||||
full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
|
||||
full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
|
||||
full_classes_full_names_jar := $(intermediates.COMMON)/classes-full-names.jar
|
||||
full_classes_proguard_jar := $(full_classes_jar)
|
||||
built_dex := $(intermediates.COMMON)/classes.dex
|
||||
|
||||
@@ -193,39 +194,52 @@ $(full_classes_jarjar_jar): $(full_classes_emma_jar) | $(ACP)
|
||||
$(hide) $(ACP) $< $@
|
||||
endif
|
||||
|
||||
# Keep a copy of the jar just before proguard processing.
|
||||
$(full_classes_full_names_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.
|
||||
ifneq ($(strip $(LOCAL_PROGUARD_ENABLED)),)
|
||||
proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
|
||||
proguard_flags := $(addprefix -libraryjars ,$(full_java_libs)) \
|
||||
# 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))
|
||||
proguard_flags := $(addprefix -libraryjars ,$(proguard_full_java_libs)) \
|
||||
-include $(BUILD_SYSTEM)/proguard.flags \
|
||||
-forceprocessing \
|
||||
-printmapping $(proguard_dictionary)
|
||||
ifeq ($(strip $(LOCAL_PROGUARD_ENABLED)),full)
|
||||
# If this is a test package, add proguard keep flags for tests.
|
||||
ifneq ($(strip $(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS))$(filter android.test.runner,$(LOCAL_JAVA_LIBRARIES))),)
|
||||
proguard_flags := $(proguard_flags) -include $(BUILD_SYSTEM)/proguard_tests.flags
|
||||
endif # test package
|
||||
|
||||
LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
|
||||
ifneq ($(LOCAL_PROGUARD_ENABLED),)
|
||||
ifeq ($(LOCAL_PROGUARD_ENABLED),full)
|
||||
# full
|
||||
else
|
||||
ifeq ($(strip $(LOCAL_PROGUARD_ENABLED)),optonly)
|
||||
ifeq ($(LOCAL_PROGUARD_ENABLED),optonly)
|
||||
# optonly
|
||||
proguard_flags += -dontobfuscate
|
||||
else
|
||||
ifeq ($(strip $(LOCAL_PROGUARD_ENABLED)),custom)
|
||||
ifeq ($(LOCAL_PROGUARD_ENABLED),custom)
|
||||
# custom
|
||||
else
|
||||
$(warning while processing: $(LOCAL_MODULE))
|
||||
$(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif # custom
|
||||
endif # optonly
|
||||
endif # full
|
||||
endif # LOCAL_PROGUARD_ENABLED
|
||||
|
||||
$(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): $(full_classes_emma_jar) | $(PROGUARD)
|
||||
@echo Proguard: $@
|
||||
$(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS)
|
||||
else
|
||||
$(full_classes_proguard_jar): $(full_classes_emma_jar) | $(ACP)
|
||||
@echo Copying: $@
|
||||
$(hide) $(ACP) $< $@
|
||||
endif
|
||||
$(full_classes_proguard_jar): PRIVATE_INSTRUMENTATION_FOR:=$(strip $(LOCAL_INSTRUMENTATION_FOR))
|
||||
|
||||
$(full_classes_proguard_jar): $(full_classes_full_names_jar) | $(ACP) $(PROGUARD)
|
||||
$(call transform-jar-to-proguard)
|
||||
|
||||
ALL_MODULES.$(LOCAL_MODULE).PROGUARD_ENABLED:=$(LOCAL_PROGUARD_ENABLED)
|
||||
|
||||
# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
|
||||
# will work even when intermediates != intermediates.COMMON.
|
||||
|
Reference in New Issue
Block a user