1 ####################################
2 # dexpreopt support for ART
4 ####################################
6 DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
7 DEX2OATD := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
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.
11 DEX2OAT_DEPENDENCY := art/runtime/oat.cc # dependency on oat version number
12 DEX2OAT_DEPENDENCY += art/runtime/image.cc # dependency on image version number
13 DEX2OAT_DEPENDENCY += |
14 DEX2OAT_DEPENDENCY += $(DEX2OAT)
16 DEX2OATD_DEPENDENCY := $(DEX2OAT_DEPENDENCY)
17 DEX2OATD_DEPENDENCY += $(DEX2OATD)
19 # Use the first preloaded-classes file in PRODUCT_COPY_FILES.
20 PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
21 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
23 # Use the first compiled-classes file in PRODUCT_COPY_FILES.
24 COMPILED_CLASSES := $(call word-colon,1,$(firstword \
25 $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
27 # Default to debug version to help find bugs.
28 # Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
29 ifneq ($(USE_DEX2OAT_DEBUG), false)
31 DEX2OAT_DEPENDENCY = $(DEX2OATD_DEPENDENCY)
34 # start of image reserved address space
35 LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000
36 LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
38 define get-product-default-property
39 $(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
42 DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
43 DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
44 DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
45 DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
47 ifeq ($(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
54 LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
58 ########################################################################
59 # The full system boot classpath
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.
64 define get-odex-file-path
65 $(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
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")
71 define get-image-file-path
72 $(dir $(2))$(1)/$(notdir $(2))
75 # note we use core-libart.jar in place of core.jar for ART.
76 LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
77 LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
78 LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
81 include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
84 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
85 include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
90 ########################################################################
91 # For a single jar or APK
93 # $(1): the input .jar or .apk file
94 # $(2): the output .odex file
95 define dex2oat-one-file
97 $(hide) mkdir -p $(dir $(2))
99 --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
100 --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
102 --dex-location=$(PRIVATE_DEX_LOCATION) \
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-generate-debug-info \
109 --abort-on-hard-verifier-error \
110 $(PRIVATE_DEX_PREOPT_FLAGS)