dex_preopt_libart.mk revision f318cc436a0d7db372e03424a344c8dc9839d183
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
19PRELOADED_CLASSES := frameworks/base/preloaded-classes
20
21# Use the first compiled-classes file in PRODUCT_COPY_FILES.
22COMPILED_CLASSES := $(call word-colon,1,$(firstword \
23    $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
24
25# start of image reserved address space
26LIBART_IMG_HOST_BASE_ADDRESS   := 0x60000000
27LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
28
29define get-product-default-property
30$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
31endef
32
33DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
34DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
35DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
36DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
37
38ifeq ($(TARGET_ARCH),mips)
39# MIPS specific overrides.
40# For MIPS the ART image is loaded at a lower address. This causes issues
41# with the image overlapping with memory on the host cross-compiling and
42# building the image. We therefore limit the Xmx value. This isn't done
43# via a property as we want the larger Xmx value if we're running on a
44# MIPS device.
45LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
46DEX2OAT_XMX := 128m
47endif
48
49########################################################################
50# The full system boot classpath
51
52# Returns the path to the .odex file
53# $(1): the arch name.
54# $(2): the full path (including file name) of the corresponding .jar or .apk.
55define get-odex-file-path
56$(dir $(2))$(1)/$(basename $(notdir $(2))).odex
57endef
58
59# Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
60# $(1): the arch name (such as "arm")
61# $(2): the image location (such as "/system/framework/boot.art")
62define get-image-file-path
63$(dir $(2))$(1)/$(notdir $(2))
64endef
65
66# note we use core-libart.jar in place of core.jar for ART.
67LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
68LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
69LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
70
71my_2nd_arch_prefix :=
72include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
73
74ifdef TARGET_2ND_ARCH
75my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
76include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
77my_2nd_arch_prefix :=
78endif
79
80
81########################################################################
82# For a single jar or APK
83
84# $(1): the input .jar or .apk file
85# $(2): the output .odex file
86define dex2oat-one-file
87$(hide) rm -f $(2)
88$(hide) mkdir -p $(dir $(2))
89$(hide) $(DEX2OATD) \
90	--runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
91	--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
92	--dex-file=$(1) \
93	--dex-location=$(PRIVATE_DEX_LOCATION) \
94	--oat-file=$(2) \
95	--android-root=$(PRODUCT_OUT)/system \
96	--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
97	--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
98	--include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols \
99	$(PRIVATE_DEX_PREOPT_FLAGS)
100endef
101