forked from openkylin/platform_build
Add support for testing obfuscated app with Jack
Bug: 17481317
Bug: 27215871
Bug: 27215868
(cherry picked from commit 505dafb03b
)
Change-Id: Ia12fb92585cfcc595eef6cd096d27e779e596f7d
This commit is contained in:
parent
61ec9aed12
commit
b7de0fb1ed
|
@ -124,7 +124,7 @@ endif
|
|||
$(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack)
|
||||
$(built_dex): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
|
||||
$(built_dex): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
|
||||
$(built_dex): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
|
||||
$(built_dex): $(java_sources) $(java_resource_sources) $(full_jack_deps) \
|
||||
$(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_MODULE_MAKEFILE_DEP) \
|
||||
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK) | setup-jack-server
|
||||
@echo Building with Jack: $@
|
||||
|
|
|
@ -46,7 +46,7 @@ else
|
|||
$(full_classes_jack): \
|
||||
PRIVATE_JACK_INCREMENTAL_DIR :=
|
||||
endif
|
||||
$(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
|
||||
$(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_deps) \
|
||||
$(jar_manifest_file) $(layers_file) $(LOCAL_MODULE_MAKEFILE_DEP) \
|
||||
$(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
|
||||
$(JACK) | setup-jack-server
|
||||
|
|
23
core/java.mk
23
core/java.mk
|
@ -470,6 +470,7 @@ ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(
|
|||
$(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
|
||||
endif
|
||||
proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
|
||||
jack_dictionary := $(intermediates.COMMON)/jack_dictionary
|
||||
|
||||
# Hack: see b/20667396
|
||||
# When an app's LOCAL_SDK_VERSION is lower than the support library's LOCAL_SDK_VERSION,
|
||||
|
@ -493,9 +494,11 @@ endif
|
|||
|
||||
# jack already has the libraries in its classpath and doesn't support jars
|
||||
legacy_proguard_flags := $(addprefix -libraryjars ,$(my_support_library_sdk_raise) $(full_shared_java_libs))
|
||||
common_proguard_flags := \
|
||||
-forceprocessing \
|
||||
-printmapping $(proguard_dictionary)
|
||||
|
||||
legacy_proguard_flags += -printmapping $(proguard_dictionary)
|
||||
jack_proguard_flags := -printmapping $(jack_dictionary)
|
||||
|
||||
common_proguard_flags := -forceprocessing
|
||||
|
||||
ifeq ($(filter nosystem,$(LOCAL_PROGUARD_ENABLED)),)
|
||||
common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.flags
|
||||
|
@ -538,9 +541,9 @@ legacy_proguard_flags := -injars $(link_instr_classes_jar) \
|
|||
-applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \
|
||||
-verbose \
|
||||
$(legacy_proguard_flags)
|
||||
# not supported with jack
|
||||
ifdef LOCAL_JACK_ENABLED
|
||||
$(error $(LOCAL_MODULE): Build with jack of instrumentation when obfuscating is not yet supported)
|
||||
jack_proguard_flags += -applymapping $(link_instr_intermediates_dir.COMMON)/jack_dictionary
|
||||
full_jack_deps += $(link_instr_intermediates_dir.COMMON)/jack_dictionary
|
||||
endif
|
||||
|
||||
# Sometimes (test + main app) uses different keep rules from the main app -
|
||||
|
@ -649,7 +652,13 @@ ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
|
|||
$(error $(LOCAL_MODULE): Build with jack when LOCAL_TEST_MODULE_TO_PROGUARD_WITH is defined is not yet implemented)
|
||||
endif
|
||||
|
||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS := $(common_proguard_flags) $(LOCAL_JACK_PROGUARD_FLAGS)
|
||||
# $(jack_dictionary) is just by-product of $(built_dex_intermediate).
|
||||
# The dummy command was added because, without it, make misses the fact the $(built_dex) also
|
||||
# change $(jack_dictionary).
|
||||
$(jack_dictionary): $(full_classes_jack)
|
||||
$(hide) touch $@
|
||||
|
||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS := $(common_proguard_flags) $(jack_proguard_flags) $(LOCAL_JACK_PROGUARD_FLAGS)
|
||||
else # LOCAL_PROGUARD_ENABLED not defined
|
||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS :=
|
||||
endif # LOCAL_PROGUARD_ENABLED defined
|
||||
|
@ -657,7 +666,7 @@ endif # LOCAL_PROGUARD_ENABLED defined
|
|||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
|
||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
|
||||
|
||||
jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_lib_deps) \
|
||||
jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
|
||||
$(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) $(proguard_flag_files) \
|
||||
$(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
|
||||
$(LOCAL_MODULE_MAKEFILE_DEP) $(JACK)
|
||||
|
|
|
@ -306,10 +306,10 @@ endif # LOCAL_SDK_VERSION
|
|||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(my_bootclasspath)
|
||||
|
||||
full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
full_jack_lib_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
full_jack_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
# Turn off .toc optimization for apps build as we cannot build dexdump.
|
||||
ifeq (,$(TARGET_BUILD_APPS))
|
||||
full_jack_lib_deps := $(patsubst %.jack, %.dex.toc, $(full_jack_lib_deps))
|
||||
full_jack_deps := $(patsubst %.jack, %.dex.toc, $(full_jack_deps))
|
||||
endif
|
||||
|
||||
else # LOCAL_IS_HOST_MODULE
|
||||
|
@ -321,16 +321,18 @@ else
|
|||
my_bootclasspath := $(call jack-lib-files,core-oj-hostdex core-libart-hostdex,$(LOCAL_IS_HOST_MODULE))
|
||||
endif
|
||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(my_bootclasspath)
|
||||
# Compiling against the final jack library. If we want to add support for obfuscated library
|
||||
# we'll need to change that to compile against the not obfuscated jack library.
|
||||
full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
full_jack_lib_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
full_jack_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
else
|
||||
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES :=
|
||||
full_shared_jack_libs := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
|
||||
full_jack_lib_deps := $(full_shared_jack_libs)
|
||||
full_jack_deps := $(full_shared_jack_libs)
|
||||
endif # USE_CORE_LIB_BOOTCLASSPATH
|
||||
endif # !LOCAL_IS_HOST_MODULE
|
||||
full_jack_libs := $(full_shared_jack_libs) $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
|
||||
full_jack_lib_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
|
||||
full_jack_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
|
||||
|
||||
ifndef LOCAL_IS_HOST_MODULE
|
||||
# This is set by packages that are linking to other packages that export
|
||||
|
@ -344,7 +346,7 @@ ifneq ($(apk_libraries),)
|
|||
# link against the jar with full original names (before proguard processing).
|
||||
full_shared_jack_libs += $(link_apk_jack_libraries)
|
||||
full_jack_libs += $(link_apk_jack_libraries)
|
||||
full_jack_lib_deps += $(link_apk_jack_libraries)
|
||||
full_jack_deps += $(link_apk_jack_libraries)
|
||||
endif
|
||||
|
||||
# This is set by packages that contain instrumentation, allowing them to
|
||||
|
@ -354,7 +356,7 @@ ifdef LOCAL_INSTRUMENTATION_FOR
|
|||
# link against the jar with full original names (before proguard processing).
|
||||
link_instr_classes_jack := $(link_instr_intermediates_dir.COMMON)/classes.noshrob.jack
|
||||
full_jack_libs += $(link_instr_classes_jack)
|
||||
full_jack_lib_deps += $(link_instr_classes_jack)
|
||||
full_jack_deps += $(link_instr_classes_jack)
|
||||
endif # LOCAL_INSTRUMENTATION_FOR
|
||||
endif # !LOCAL_IS_HOST_MODULE
|
||||
|
||||
|
|
Loading…
Reference in New Issue