summaryrefslogtreecommitdiffstats
path: root/core/java.mk
diff options
context:
space:
mode:
authorJoe Onorato <joeo@android.com>2009-08-30 13:39:24 -0700
committerJoe Onorato <joeo@android.com>2009-08-30 13:43:00 -0700
commit2daa2b3b059ac755e8280741b23d65360ae233bc (patch)
tree815b7a47b228a15e19d9d0fddb3db4e3f321c92c /core/java.mk
parentc6646c9ac41122ecc022102efdcceb890a0ca529 (diff)
downloadbuild-2daa2b3b059ac755e8280741b23d65360ae233bc.zip
build-2daa2b3b059ac755e8280741b23d65360ae233bc.tar.gz
build-2daa2b3b059ac755e8280741b23d65360ae233bc.tar.bz2
Add the ability to turn on proguard for java targets, and to call aapt
to generate a rules file for proguard for stuff from the manifest and other resources that need to be kept.
Diffstat (limited to 'core/java.mk')
-rw-r--r--core/java.mk44
1 files changed, 39 insertions, 5 deletions
diff --git a/core/java.mk b/core/java.mk
index 658b173..19b4d63 100644
--- a/core/java.mk
+++ b/core/java.mk
@@ -68,7 +68,8 @@ emma_intermediates_dir := $(intermediates.COMMON)/emma_out
# the emma tool
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 := $(full_classes_jar)
+full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
+full_classes_proguard_jar := $(full_classes_jar)
built_dex := $(intermediates.COMMON)/classes.dex
LOCAL_INTERMEDIATE_TARGETS += \
@@ -174,15 +175,14 @@ $(full_classes_emma_jar): $(full_classes_compiled_jar)
$(PRIVATE_EMMA_COVERAGE_FILE): $(full_classes_emma_jar)
else
$(full_classes_emma_jar): $(full_classes_compiled_jar) | $(ACP)
- @echo Copying $<
+ @echo Copying: $<
$(copy-file-to-target)
endif
-# Run jarjar 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 jarjar if necessary, otherwise just copy the file.
ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
-$(full_classes_jarjar_jar): $(full_classes_emma_jar) | jarjar
+$(full_classes_jarjar_jar): $(full_classes_emma_jar) | $(JARJAR)
@echo JarJar: $@
$(hide) $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
else
@@ -191,6 +191,40 @@ $(full_classes_jarjar_jar): $(full_classes_emma_jar) | $(ACP)
$(hide) $(ACP) $< $@
endif
+# 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)) \
+ -include $(BUILD_SYSTEM)/proguard.flags \
+ -forceprocessing \
+ -printmapping $(proguard_dictionary)
+ifeq ($(strip $(LOCAL_PROGUARD_ENABLED)),full)
+ # full
+else
+ifeq ($(strip $(LOCAL_PROGUARD_ENABLED)),optonly)
+ # optonly
+ proguard_flags += -dontobfuscate
+else
+ifeq ($(strip $(LOCAL_PROGUARD_ENABLED)),custom)
+ # custom
+else
+ $(warning while processing: $(LOCAL_MODULE))
+ $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
+endif
+endif
+endif
+
+$(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
+
# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
# will work even when intermediates != intermediates.COMMON.
$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)