summaryrefslogtreecommitdiffstats
path: root/core/package_internal.mk
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2015-01-14 14:23:56 -0800
committerYing Wang <wangying@google.com>2015-01-21 11:54:13 -0800
commit33360dd56925276e4526f5f52c26423e2bb1a670 (patch)
tree8f5f1f80febcc28c2f72cbf2dcd2ebcf835a50d5 /core/package_internal.mk
parent350c662aafb6f899af60722d38ac5ec8f6479886 (diff)
downloadbuild-33360dd56925276e4526f5f52c26423e2bb1a670.zip
build-33360dd56925276e4526f5f52c26423e2bb1a670.tar.gz
build-33360dd56925276e4526f5f52c26423e2bb1a670.tar.bz2
Running jarjar on Java resources.
Before this change, Java resources are added as a separate step (add-java-resources-to-package) after dex is run, so jarjar isn't run on the resource files. With this change, we add Java resources immediately after we call javac, so jarjar is run on the resource files (the module's own resource, as well as resources carried by static Java libraries). When we generate the final apk/jar, we use the jarjar'ed jar as the inital pacakge file, with class files and empty folders removed. When jack is enabled, in jack-java-to-dex we add the Java resources to a temp jar using the PRIVATE_EXTRA_JAR_ARGS, and extrac the files in a temp dir. Jack will process the resource files and output the result to PRIVATE_JACK_INTERMEDIATES_DIR. When we package the final apk/jar, we need to call add-carried-jack-resources to readd the resources. (TODO: if jack can output all resources to a jar/zip file, we can use that file as the initial package file as well.) Bug: 18837479 Change-Id: I8d7296e30ec8d005054cf04c4f2aed6d7a0d823b
Diffstat (limited to 'core/package_internal.mk')
-rw-r--r--core/package_internal.mk22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 898a8df..059f121 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -162,7 +162,7 @@ endif # need_compile_res
endif # !custom
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
-ifeq ($(strip $(LOCAL_USE_JACK)),true)
+ifeq ($(LOCAL_USE_JACK),true)
ifndef LOCAL_JACK_PROGUARD_FLAGS
LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
endif
@@ -278,7 +278,7 @@ endif
# they want to use this module's R.java file.
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
-ifeq ($(strip $(LOCAL_USE_JACK)),true)
+ifeq ($(LOCAL_USE_JACK),true)
ifneq ($(built_dex_intermediate),)
$(built_dex_intermediate): $(R_file_stamp)
endif
@@ -339,7 +339,12 @@ endif # LOCAL_NO_STANDARD_LIBRARIES
ifneq ($(full_classes_jar),)
$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+# Use the jarjar processed arhive as the initial package file.
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
$(LOCAL_BUILT_MODULE): $(built_dex)
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE :=
endif # full_classes_jar
include $(BUILD_SYSTEM)/install_jni_libs.mk
@@ -400,7 +405,13 @@ endif
endif
$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
@echo "target Package: $(PRIVATE_MODULE) ($@)"
+ifeq ($(LOCAL_USE_JACK),true)
$(create-empty-package)
+else
+ $(if $(PRIVATE_SOURCE_ARCHIVE),\
+ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
+ $(create-empty-package))
+endif
$(add-assets-to-package)
ifneq ($(jni_shared_libraries),)
$(add-jni-shared-libs-to-package)
@@ -408,14 +419,9 @@ endif
ifneq ($(full_classes_jar),)
$(add-dex-to-package)
endif
-ifneq ($(strip $(LOCAL_USE_JACK)),true)
- $(add-carried-java-resources)
-else
+ifeq ($(LOCAL_USE_JACK),true)
$(add-carried-jack-resources)
endif
-ifneq ($(extra_jar_args),)
- $(add-java-resources-to-package)
-endif
$(sign-package)
ifdef LOCAL_DEX_PREOPT
ifneq (nostripping,$(LOCAL_DEX_PREOPT))