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