To rebuild odex files of Java libraries and apps,
we store the jars/apks without stripping the classes.dex inside the
platform.zip. We also save the build variables that may affect how we
rebuild an odex in pdk_dexpreopt_config.mk in the platform.zip.
We store the files and configuration only for libraries/apps that get
installed to the system.img (or vendor.img).
In PDK fusion build, we auto-generate prebuilt module definitions for
the javalib.jar and package.dex.apk carried in the platform.zip, using
configuration stored in pdk_dexpreopt_config.mk.
With the prebult modules, we override the implicit rule that directly
copies the odex from the platform.zip.
To rebuild odex of javalib.jar, we added support for prebuilt shared Java
library to prebiult_internal.mk. An installable prebuilt Java library is
treated as shared Java library, i.e. with classes.dex in the jar instead
of a set of .class files.
For apks in the platform.zip, we install the stripped version from
platform files inside platform.zip, instead of the package.dex.apk,
using a new variable LOCAL_REPLACE_PREBUILT_APK_INSTALLED. We can't
strip package.dex.apk because we can't re-sign the stripped apk at this
point.
We generate prebuilt module only if it's not already defined in the
source tree.
Bug: 27543283
Change-Id: I9e146f8b713d6f57c397fd28d88c9ab700757ca1
(cherry-pick from commit 3a61eeb6cb
)
104 lines
4.0 KiB
Makefile
104 lines
4.0 KiB
Makefile
####################################
|
|
# dexpreopt support for ART
|
|
#
|
|
####################################
|
|
|
|
# Default to debug version to help find bugs.
|
|
# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
|
|
ifeq ($(USE_DEX2OAT_DEBUG),false)
|
|
DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
|
|
else
|
|
DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
|
|
endif
|
|
|
|
DEX2OAT_DEPENDENCY += $(DEX2OAT)
|
|
|
|
# Use the first preloaded-classes file in PRODUCT_COPY_FILES.
|
|
PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
|
|
$(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
|
|
|
|
# Use the first compiled-classes file in PRODUCT_COPY_FILES.
|
|
COMPILED_CLASSES := $(call word-colon,1,$(firstword \
|
|
$(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
|
|
|
|
# start of image reserved address space
|
|
LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000
|
|
LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
|
|
|
|
define get-product-default-property
|
|
$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
|
|
endef
|
|
|
|
DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
|
|
DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
|
|
DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
|
|
DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
|
|
|
|
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
|
|
# MIPS specific overrides.
|
|
# For MIPS the ART image is loaded at a lower address. This causes issues
|
|
# with the image overlapping with memory on the host cross-compiling and
|
|
# building the image. We therefore limit the Xmx value. This isn't done
|
|
# via a property as we want the larger Xmx value if we're running on a
|
|
# MIPS device.
|
|
LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
|
|
DEX2OAT_XMX := 128m
|
|
endif
|
|
|
|
########################################################################
|
|
# The full system boot classpath
|
|
|
|
# Returns the path to the .odex file
|
|
# $(1): the arch name.
|
|
# $(2): the full path (including file name) of the corresponding .jar or .apk.
|
|
define get-odex-file-path
|
|
$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
|
|
endef
|
|
|
|
# Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
|
|
# $(1): the arch name (such as "arm")
|
|
# $(2): the image location (such as "/system/framework/boot.art")
|
|
define get-image-file-path
|
|
$(dir $(2))$(1)/$(notdir $(2))
|
|
endef
|
|
|
|
# note we use core-libart.jar in place of core.jar for ART.
|
|
LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
|
|
LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
|
|
LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
|
|
|
|
my_2nd_arch_prefix :=
|
|
include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
|
|
|
|
ifdef TARGET_2ND_ARCH
|
|
my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
|
|
include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
|
|
my_2nd_arch_prefix :=
|
|
endif
|
|
|
|
|
|
########################################################################
|
|
# For a single jar or APK
|
|
|
|
# $(1): the input .jar or .apk file
|
|
# $(2): the output .odex file
|
|
define dex2oat-one-file
|
|
$(hide) rm -f $(2)
|
|
$(hide) mkdir -p $(dir $(2))
|
|
$(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
|
|
--runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
|
|
--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
|
|
--dex-file=$(1) \
|
|
--dex-location=$(PRIVATE_DEX_LOCATION) \
|
|
--oat-file=$(2) \
|
|
--android-root=$(PRODUCT_OUT)/system \
|
|
--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
|
|
--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
|
|
--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
|
|
--include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
|
|
--abort-on-hard-verifier-error \
|
|
--no-inline-from=core-oj.jar \
|
|
$(PRIVATE_DEX_PREOPT_FLAGS) \
|
|
$(GLOBAL_DEXPREOPT_FLAGS)
|
|
endef
|