1 #################################### 2 # dexpreopt support for ART 3 # 4 #################################### 5 6 # Default to debug version to help find bugs. 7 # Set USE_DEX2OAT_DEBUG to false for only building non-debug versions. 8 ifeq ($(USE_DEX2OAT_DEBUG),false) 9 DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX) 10 else 11 DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX) 12 endif 13 14 # Pass special classpath to skip uses library check. 15 # Should modify build system to pass used libraries properly later. 16 DEX2OAT_CLASSPATH := "&" 17 18 DEX2OAT_DEPENDENCY += $(DEX2OAT) 19 20 # Use the first preloaded-classes file in PRODUCT_COPY_FILES. 21 PRELOADED_CLASSES := $(call word-colon,1,$(firstword \ 22 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES)))) 23 24 # Use the first compiled-classes file in PRODUCT_COPY_FILES. 25 COMPILED_CLASSES := $(call word-colon,1,$(firstword \ 26 $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES)))) 27 28 # start of image reserved address space 29 LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000 30 LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000 31 32 define get-product-default-property 33 $(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)))) 34 endef 35 36 DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms) 37 DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx) 38 DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms) 39 DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx) 40 41 ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64)) 42 # MIPS specific overrides. 43 # For MIPS the ART image is loaded at a lower address. This causes issues 44 # with the image overlapping with memory on the host cross-compiling and 45 # building the image. We therefore limit the Xmx value. This isn't done 46 # via a property as we want the larger Xmx value if we're running on a 47 # MIPS device. 48 LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000 49 DEX2OAT_XMX := 128m 50 endif 51 52 ######################################################################## 53 # The full system boot classpath 54 55 # Returns the path to the .odex file 56 # $(1): the arch name. 57 # $(2): the full path (including file name) of the corresponding .jar or .apk. 58 define get-odex-file-path 59 $(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex 60 endef 61 62 # Returns the full path to the installed .odex file. 63 # This handles BOARD_USES_SYSTEM_OTHER_ODEX to install odex files into another 64 # partition. 65 # $(1): the arch name. 66 # $(2): the full install path (including file name) of the corresponding .apk. 67 ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) 68 define get-odex-installed-file-path 69 $(if $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(2)), 70 $(call get-odex-file-path,$(1),$(patsubst $(TARGET_OUT)/%,$(TARGET_OUT_SYSTEM_OTHER)/%,$(2))), 71 $(call get-odex-file-path,$(1),$(2))) 72 endef 73 else 74 get-odex-installed-file-path = $(get-odex-file-path) 75 endif 76 77 # Returns the path to the image file (such as "/system/framework/<arch>/boot.art" 78 # $(1): the arch name (such as "arm") 79 # $(2): the image location (such as "/system/framework/boot.art") 80 define get-image-file-path 81 $(dir $(2))$(1)/$(notdir $(2)) 82 endef 83 84 # note we use core-libart.jar in place of core.jar for ART. 85 LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES)) 86 LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar) 87 LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar) 88 89 # dex preopt on the bootclasspath produces multiple files. The first dex file 90 # is converted into to boot.art (to match the legacy assumption that boot.art 91 # exists), and the rest are converted to boot-<name>.art. 92 # In addition, each .art file has an associated .oat file. 93 LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat) 94 LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat 95 96 my_2nd_arch_prefix := 97 include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk 98 99 ifdef TARGET_2ND_ARCH 100 my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) 101 include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk 102 my_2nd_arch_prefix := 103 endif 104 105 106 ######################################################################## 107 # For a single jar or APK 108 109 # $(1): the input .jar or .apk file 110 # $(2): the output .odex file 111 define dex2oat-one-file 112 $(hide) rm -f $(2) 113 $(hide) mkdir -p $(dir $(2)) 114 $(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \ 115 --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \ 116 --runtime-arg -classpath --runtime-arg $(DEX2OAT_CLASSPATH) \ 117 --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \ 118 --dex-file=$(1) \ 119 --dex-location=$(PRIVATE_DEX_LOCATION) \ 120 --oat-file=$(2) \ 121 --android-root=$(PRODUCT_OUT)/system \ 122 --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \ 123 --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \ 124 --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \ 125 --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \ 126 --abort-on-hard-verifier-error \ 127 --no-inline-from=core-oj.jar \ 128 $(PRIVATE_DEX_PREOPT_FLAGS) \ 129 $(GLOBAL_DEXPREOPT_FLAGS) 130 endef 131