Merge changes I06b8efa8,Id2fa2d18
* changes: Enable dexpreopt and dex stripping in soong jars Refactor removing classes.dex for dexpreopt
This commit is contained in:
commit
4d44c2dc12
6 changed files with 51 additions and 28 deletions
|
@ -2714,6 +2714,26 @@ $(3): | $(1)
|
|||
$(hide) ln -sf $(2) $$@
|
||||
endef
|
||||
|
||||
# Copy an apk to a target location while removing classes*.dex
|
||||
# $(1): source file
|
||||
# $(2): destination file
|
||||
# $(3): LOCAL_DEX_PREOPT, if nostripping then leave classes*.dex
|
||||
define dexpreopt-copy-jar
|
||||
$(2): $(1)
|
||||
@echo $(if $(filter nostripping,$(3)),"Copy: $$@","Copy without dex: $$@")
|
||||
$$(copy-file-to-target)
|
||||
$(if $(filter nostripping,$(3)),,$$(call dexpreopt-remove-classes.dex,$$@))
|
||||
endef
|
||||
|
||||
# $(1): the .jar or .apk to remove classes.dex
|
||||
define dexpreopt-remove-classes.dex
|
||||
$(hide) zip --quiet --delete $(1) classes.dex; \
|
||||
dex_index=2; \
|
||||
while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
|
||||
let dex_index=dex_index+1; \
|
||||
done
|
||||
endef
|
||||
|
||||
###########################################################
|
||||
## Commands to call Proguard
|
||||
###########################################################
|
||||
|
|
|
@ -48,15 +48,6 @@ endif
|
|||
|
||||
GLOBAL_DEXPREOPT_FLAGS :=
|
||||
|
||||
# $(1): the .jar or .apk to remove classes.dex
|
||||
define dexpreopt-remove-classes.dex
|
||||
$(hide) zip --quiet --delete $(1) classes.dex; \
|
||||
dex_index=2; \
|
||||
while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
|
||||
let dex_index=dex_index+1; \
|
||||
done
|
||||
endef
|
||||
|
||||
# Special rules for building stripped boot jars that override java_library.mk rules
|
||||
|
||||
# $(1): boot jar module name
|
||||
|
@ -64,11 +55,7 @@ define _dexpreopt-boot-jar-remove-classes.dex
|
|||
_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
|
||||
_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
|
||||
|
||||
$$(_dbj_jar_no_dex) : $$(_dbj_src_jar)
|
||||
$$(call copy-file-to-target)
|
||||
ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
|
||||
$$(call dexpreopt-remove-classes.dex,$$@)
|
||||
endif
|
||||
$(call dexpreopt-copy-jar,$$(_dbj_src_jar),$$(_dbj_jar_no_dex),$(DEX_PREOPT_DEFAULT))
|
||||
|
||||
_dbj_jar_no_dex :=
|
||||
_dbj_src_jar :=
|
||||
|
|
|
@ -30,7 +30,7 @@ endif
|
|||
ifdef LOCAL_UNINSTALLABLE_MODULE
|
||||
LOCAL_DEX_PREOPT :=
|
||||
endif
|
||||
ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code
|
||||
ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file)$(LOCAL_SOONG_DEX_JAR))) # contains no java code
|
||||
LOCAL_DEX_PREOPT :=
|
||||
endif
|
||||
# if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip
|
||||
|
|
|
@ -86,10 +86,7 @@ $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar)
|
|||
@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
|
||||
$(call dexpreopt-one-file,$<,$@)
|
||||
|
||||
$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
|
||||
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
|
||||
$(call dexpreopt-remove-classes.dex,$@)
|
||||
endif
|
||||
$(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT)))
|
||||
|
||||
endif # ! boot jar
|
||||
|
||||
|
|
|
@ -430,11 +430,7 @@ $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file)
|
|||
@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
|
||||
$(call dexpreopt-one-file,$<,$@)
|
||||
|
||||
$(built_module) : $(my_prebuilt_src_file)
|
||||
$(call copy-file-to-target)
|
||||
ifneq (nostripping,$(LOCAL_DEX_PREOPT))
|
||||
$(call dexpreopt-remove-classes.dex,$@)
|
||||
endif
|
||||
$(eval $(call dexpreopt-copy-jar,$(my_prebuilt_src_file),$(built_module),$(LOCAL_DEX_PREOPT)))
|
||||
endif # boot jar
|
||||
else # ! LOCAL_DEX_PREOPT
|
||||
$(built_module) : $(my_prebuilt_src_file)
|
||||
|
|
|
@ -35,11 +35,34 @@ endif
|
|||
endif # TURBINE_DISABLED != false
|
||||
|
||||
ifdef LOCAL_SOONG_DEX_JAR
|
||||
$(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar)))
|
||||
$(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(LOCAL_BUILT_MODULE)))
|
||||
java-dex : $(LOCAL_BUILT_MODULE)
|
||||
$(eval $(call copy-one-file,$(LOCAL_SOONG_DEX_JAR),$(common_javalib.jar)))
|
||||
|
||||
# defines built_odex along with rule to install odex
|
||||
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
|
||||
|
||||
ifdef LOCAL_DEX_PREOPT
|
||||
ifneq ($(dexpreopt_boot_jar_module),) # boot jar
|
||||
# boot jar's rules are defined in dex_preopt.mk
|
||||
dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
|
||||
$(eval $(call copy-one-file,$(dexpreopted_boot_jar),$(LOCAL_BUILT_MODULE)))
|
||||
|
||||
# For libart boot jars, we don't have .odex files.
|
||||
else # ! boot jar
|
||||
$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
|
||||
# Use pattern rule - we may have multiple built odex files.
|
||||
$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar)
|
||||
@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
|
||||
$(call dexpreopt-one-file,$<,$@)
|
||||
|
||||
$(eval $(call dexpreopt-copy-jar,$(common_javalib.jar),$(LOCAL_BUILT_MODULE),$(LOCAL_DEX_PREOPT)))
|
||||
endif # ! boot jar
|
||||
else # LOCAL_DEX_PREOPT
|
||||
$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
|
||||
endif # LOCAL_DEX_PREOPT
|
||||
|
||||
java-dex : $(LOCAL_BUILT_MODULE)
|
||||
else
|
||||
$(eval $(call copy-one-file,$(full_classes_jar),$(LOCAL_BUILT_MODULE)))
|
||||
$(eval $(call copy-one-file,$(full_classes_jar),$(LOCAL_BUILT_MODULE)))
|
||||
endif
|
||||
|
||||
javac-check : $(full_classes_jar)
|
||||
|
|
Loading…
Reference in a new issue