Merge "Engage Jack incremental on demand"

This commit is contained in:
Yohann Roussel 2015-02-05 11:01:21 +00:00 committed by Android (Google) Code Review
commit 9d528c778b
11 changed files with 83 additions and 28 deletions

View file

@ -43,6 +43,13 @@ endif
my_module_tags := $(LOCAL_MODULE_TAGS)
LOCAL_JACK_ENABLED := $(strip $(LOCAL_JACK_ENABLED))
ifneq ($(LOCAL_JACK_ENABLED),full)
ifneq ($(LOCAL_JACK_ENABLED),incremental)
LOCAL_JACK_ENABLED :=
endif
endif
###########################################################
## Validate and define fallbacks for input LOCAL_* variables.
###########################################################
@ -682,7 +689,7 @@ endif
###########################################################
# JACK
###########################################################
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
ifdef need_compile_java
full_static_jack_libs := \
@ -757,7 +764,7 @@ endif # need_compile_java
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JACK_LIBRARIES:= $(full_jack_libs)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED
###########################################################
## NOTICE files

View file

@ -256,8 +256,13 @@ clean-jack-files: clean-dex-files
.PHONY: clean-dex-files
clean-dex-files:
$(hide) find $(OUT_DIR) -name "*.dex" | xargs rm -f
$(hide) find $(OUT_DIR) -name "*.dex" ! -path "*/jack-incremental/*" | xargs rm -f
$(hide) for i in `find $(OUT_DIR) -name "*.jar" -o -name "*.apk"` ; do ((unzip -l $$i 2> /dev/null | \
grep -q "\.dex$$" && rm -f $$i) || continue ) ; done
@echo "All dex files and archives containing dex files have been removed."
.PHONY: clean-jack-incremental
clean-jack-incremental:
$(hide) find $(OUT_DIR) -name "jack-incremental" -type d | xargs rm -rf
@echo "All jack incremental dirs have been removed."

View file

@ -107,7 +107,7 @@ LOCAL_JARJAR_RULES:=
LOCAL_ADDITIONAL_JAVA_DIR:=
LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
LOCAL_DX_FLAGS:=
LOCAL_USE_JACK:= $(ANDROID_COMPILE_WITH_JACK)
LOCAL_JACK_ENABLED:=$(DEFAULT_JACK_ENABLED) # '' (ie disabled), disabled, full, incremental
LOCAL_JACK_VM_ARGS := $(DEFAULT_JACK_VM_ARGS)
LOCAL_JACK_EXTRA_ARGS := $(DEFAULT_JACK_EXTRA_ARGS)
LOCAL_JACK_FLAGS:=

View file

@ -406,6 +406,11 @@ TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
DEFAULT_JACK_ENABLED:=full
else
DEFAULT_JACK_ENABLED:=
endif
ifneq ($(strip $(ANDROID_JACK_VM)),)
JACK_VM := $(ANDROID_JACK_VM)
else

View file

@ -1731,6 +1731,7 @@ $(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR)
$(hide) mkdir -p $(dir $@)
$(hide) mkdir -p $(dir $(PRIVATE_CLASSES_JACK))
$(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
@ -1765,6 +1766,7 @@ $(call call-jack,$(PRIVATE_JACK_VM_ARGS),$(PRIVATE_JACK_EXTRA_ARGS)) \
-D jack.import.type.policy=keep-first \
--output-jack $(PRIVATE_CLASSES_JACK) \
-D jack.java.source.version=1.7 \
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
--output-dex $(PRIVATE_JACK_INTERMEDIATES_DIR) \
$(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \
$(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \
@ -1807,6 +1809,7 @@ $(hide) rm -f $@
$(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR)
$(hide) mkdir -p $(dir $@)
$(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
@ -1840,6 +1843,7 @@ $(call call-jack,$(PRIVATE_JACK_VM_ARGS),$(PRIVATE_JACK_EXTRA_ARGS)) \
-D jack.import.resource.policy=keep-first \
-D jack.import.type.policy=keep-first \
-D jack.java.source.version=1.7 \
$(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
--output-jack $@ \
$(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \
$(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \

View file

@ -98,7 +98,7 @@ $(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
@echo Copying: $@
$(hide) $(ACP) -fp $< $@
ifneq ($(LOCAL_USE_JACK),true)
ifndef LOCAL_JACK_ENABLED
$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
$(built_dex): $(full_classes_jar) $(DX)
@ -112,9 +112,17 @@ $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
$(add-dex-to-package)
else # LOCAL_USE_JACK
else # LOCAL_JACK_ENABLED
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jayces
PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
ifeq ($(LOCAL_JACK_ENABLED),incremental)
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
else
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_JACK_INCREMENTAL_DIR :=
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_DEBUG_FLAGS := -g
$(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack)
@ -134,7 +142,7 @@ $(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
$(add-dex-to-package)
$(add-carried-jack-resources)
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED
USE_CORE_LIB_BOOTCLASSPATH :=

View file

@ -35,7 +35,14 @@ include $(BUILD_SYSTEM)/host_java_library.mk
$(full_classes_jack): PRIVATE_JACK_FLAGS := $(LOCAL_JACK_FLAGS)
$(full_classes_jack): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
$(full_classes_jack): \
PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack
PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
ifeq ($(LOCAL_JACK_ENABLED),incremental)
$(full_classes_jack): \
PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
else
$(full_classes_jack): \
PRIVATE_JACK_INCREMENTAL_DIR :=
endif
$(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
$(jar_manifest_file) $(layers_file) $(LOCAL_MODULE_MAKEFILE) \
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \

View file

@ -471,7 +471,7 @@ legacy_proguard_flags := -injars $(link_instr_classes_jar) \
-verbose \
$(legacy_proguard_flags)
# not supported with jack
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(error $(LOCAL_MODULE): Build with jack of instrumentation when obfuscating is not yet supported)
endif
@ -506,7 +506,7 @@ $(full_classes_proguard_jar) : $(full_classes_jar)
endif # LOCAL_PROGUARD_ENABLED defined
ifneq ($(strip $(LOCAL_USE_JACK)),true)
ifndef LOCAL_JACK_ENABLED
# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
# will work even when intermediates != intermediates.COMMON.
$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
@ -522,7 +522,7 @@ $(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals
endif
$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX)
$(transform-classes.jar-to-dex)
endif # !LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED is disabled
$(built_dex): $(built_dex_intermediate) | $(ACP)
@echo Copying: $@
@ -562,9 +562,16 @@ $(LOCAL_MODULE)-findbugs : $(findbugs_html)
endif # full_classes_jar is defined
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack
PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
ifeq ($(LOCAL_JACK_ENABLED),incremental)
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
else
$(LOCAL_INTERMEDIATE_TARGETS): \
PRIVATE_JACK_INCREMENTAL_DIR :=
endif
ifdef full_classes_jar
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_DEBUG_FLAGS := -g
@ -607,10 +614,15 @@ $(full_classes_jack): $(built_dex_intermediate)
# nothing to do it's built as a side effect of $(built_dex_intermediate)
endif #LOCAL_IS_STATIC_JAVA_LIBRARY
$(noshrob_classes_jack): PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/noshrob
$(noshrob_classes_jack): PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-noshrob-rsc
ifeq ($(LOCAL_JACK_ENABLED),incremental)
$(noshrob_classes_jack): PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-noshrob-incremental
else
$(noshrob_classes_jack): PRIVATE_JACK_INCREMENTAL_DIR :=
endif
$(noshrob_classes_jack): PRIVATE_JACK_PROGUARD_FLAGS :=
$(noshrob_classes_jack): $(jack_all_deps)
@echo Building with Jack: $@
$(java-to-jack)
endif # full_classes_jar is defined
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED

View file

@ -69,13 +69,13 @@ $(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
$(common_javalib.jar) : $(built_dex) $(java_resource_sources)
@echo "target Jar: $(PRIVATE_MODULE) ($@)"
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(create-empty-package)
else
$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
endif
$(add-dex-to-package)
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(add-carried-jack-resources)
endif

View file

@ -57,6 +57,13 @@ $(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
endif
LOCAL_MODULE_CLASS := APPS
LOCAL_JACK_ENABLED := $(strip $(LOCAL_JACK_ENABLED))
ifneq ($(LOCAL_JACK_ENABLED),full)
ifneq ($(LOCAL_JACK_ENABLED),incremental)
LOCAL_JACK_ENABLED :=
endif
endif
# Package LOCAL_MODULE_TAGS default to optional
LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS))
ifeq ($(LOCAL_MODULE_TAGS),)
@ -162,12 +169,12 @@ endif # need_compile_res
endif # !custom
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
ifndef LOCAL_JACK_PROGUARD_FLAGS
LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
endif
LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS)
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED
ifeq (true,$(EMMA_INSTRUMENT))
ifndef LOCAL_EMMA_INSTRUMENT
@ -278,7 +285,7 @@ endif
# they want to use this module's R.java file.
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
ifneq ($(built_dex_intermediate),)
$(built_dex_intermediate): $(R_file_stamp)
endif
@ -288,7 +295,7 @@ endif
ifneq ($(full_classes_jack),)
$(full_classes_jack): $(R_file_stamp)
endif
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED
ifneq ($(full_classes_jar),)
# If full_classes_jar is non-empty, we're building sources.
@ -406,7 +413,7 @@ endif
$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
@echo "target Package: $(PRIVATE_MODULE) ($@)"
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(create-empty-package)
else
$(if $(PRIVATE_SOURCE_ARCHIVE),\
@ -420,7 +427,7 @@ endif
ifneq ($(full_classes_jar),)
$(add-dex-to-package)
endif
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(add-carried-jack-resources)
endif
$(sign-package)

View file

@ -59,12 +59,12 @@ endif
LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
ifndef LOCAL_JACK_PROGUARD_FLAGS
LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
endif
LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS)
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED
endif # LOCAL_RESOURCE_DIR
@ -123,10 +123,10 @@ $(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_
$(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@
$(LOCAL_BUILT_MODULE): $(R_file_stamp)
ifeq ($(LOCAL_USE_JACK),true)
ifdef LOCAL_JACK_ENABLED
$(noshrob_classes_jack): $(R_file_stamp)
$(full_classes_jack): $(R_file_stamp)
endif # LOCAL_USE_JACK
endif # LOCAL_JACK_ENABLED
$(full_classes_compiled_jar): $(R_file_stamp)
# Rule to build AAR, archive including classes.jar, resource, etc.