dex_preopt_libart.mk revision 820fe32d467b7b8b25ef1645eec8876492619f75
1####################################
2# dexpreopt support for ART
3#
4####################################
5
6DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
7DEX2OATD := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
8
9# By default, do not run rerun dex2oat if the tool changes.
10# Comment out the | to force dex2oat to rerun on after all changes.
11DEX2OAT_DEPENDENCY := art/runtime/oat.cc # dependency on oat version number
12DEX2OAT_DEPENDENCY += art/runtime/image.cc # dependency on image version number
13DEX2OAT_DEPENDENCY += |
14DEX2OAT_DEPENDENCY += $(DEX2OAT)
15
16DEX2OATD_DEPENDENCY := $(DEX2OAT_DEPENDENCY)
17DEX2OATD_DEPENDENCY += $(DEX2OATD)
18
19# Use the first preloaded-classes file in PRODUCT_COPY_FILES.
20PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
21    $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
22
23# Use the first compiled-classes file in PRODUCT_COPY_FILES.
24COMPILED_CLASSES := $(call word-colon,1,$(firstword \
25    $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
26
27# Default to debug version to help find bugs.
28# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
29ifneq ($(USE_DEX2OAT_DEBUG), false)
30DEX2OAT = $(DEX2OATD)
31DEX2OAT_DEPENDENCY = $(DEX2OATD_DEPENDENCY)
32endif
33
34# start of image reserved address space
35LIBART_IMG_HOST_BASE_ADDRESS   := 0x60000000
36LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
37
38define get-product-default-property
39$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
40endef
41
42DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
43DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
44DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
45DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
46
47ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
48# MIPS specific overrides.
49# For MIPS the ART image is loaded at a lower address. This causes issues
50# with the image overlapping with memory on the host cross-compiling and
51# building the image. We therefore limit the Xmx value. This isn't done
52# via a property as we want the larger Xmx value if we're running on a
53# MIPS device.
54LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
55DEX2OAT_XMX := 128m
56endif
57
58########################################################################
59# The full system boot classpath
60
61# Returns the path to the .odex file
62# $(1): the arch name.
63# $(2): the full path (including file name) of the corresponding .jar or .apk.
64define get-odex-file-path
65$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
66endef
67
68# Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
69# $(1): the arch name (such as "arm")
70# $(2): the image location (such as "/system/framework/boot.art")
71define get-image-file-path
72$(dir $(2))$(1)/$(notdir $(2))
73endef
74
75# note we use core-libart.jar in place of core.jar for ART.
76LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
77LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
78LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
79
80my_2nd_arch_prefix :=
81include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
82
83ifdef TARGET_2ND_ARCH
84my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
85include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
86my_2nd_arch_prefix :=
87endif
88
89
90########################################################################
91# For a single jar or APK
92
93# $(1): the input .jar or .apk file
94# $(2): the output .odex file
95define dex2oat-one-file
96$(hide) rm -f $(2)
97$(hide) mkdir -p $(dir $(2))
98$(hide) $(DEX2OAT) \
99	--runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
100	--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
101	--dex-file=$(1) \
102	--dex-location=$(PRIVATE_DEX_LOCATION) \
103	--oat-file=$(2) \
104	--android-root=$(PRODUCT_OUT)/system \
105	--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
106	--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
107	--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
108	--include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols \
109	--abort-on-hard-verifier-error \
110	$(PRIVATE_DEX_PREOPT_FLAGS)
111endef
112