blob: acd4a02dd95a51767f46f1f418eb37314a0614cf [file] [log] [blame]
Brian Carlstromced4bff2013-11-14 23:44:56 -08001####################################
2# dexpreopt support for ART
3#
4####################################
5
Fredrik Roubert8a3dd242015-07-27 21:48:39 +02006# Default to debug version to help find bugs.
7# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
8ifeq ($(USE_DEX2OAT_DEBUG),false)
Brian Carlstromced4bff2013-11-14 23:44:56 -08009DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
Fredrik Roubert8a3dd242015-07-27 21:48:39 +020010else
11DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
12endif
Brian Carlstromced4bff2013-11-14 23:44:56 -080013
Jeff Haob00263f2016-06-13 16:53:11 -070014# Pass special classpath to skip uses library check.
15# Should modify build system to pass used libraries properly later.
16DEX2OAT_CLASSPATH := "&"
17
Brian Carlstromced4bff2013-11-14 23:44:56 -080018DEX2OAT_DEPENDENCY += $(DEX2OAT)
Brian Carlstromced4bff2013-11-14 23:44:56 -080019
Ying Wang0c9b3ba2014-11-13 15:19:12 -080020# Use the first preloaded-classes file in PRODUCT_COPY_FILES.
21PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
22 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
Brian Carlstromced4bff2013-11-14 23:44:56 -080023
Andreas Gampe96a52202014-11-18 11:45:10 -080024# Use the first compiled-classes file in PRODUCT_COPY_FILES.
25COMPILED_CLASSES := $(call word-colon,1,$(firstword \
26 $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
27
Brian Carlstromced4bff2013-11-14 23:44:56 -080028# start of image reserved address space
29LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000
Mathieu Chartier3408ca02014-03-05 14:45:18 -080030LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
Brian Carlstromced4bff2013-11-14 23:44:56 -080031
Colin Crossdd2ff552014-07-09 22:09:50 -070032define get-product-default-property
33$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
Brian Carlstromcffe2892014-07-08 10:35:29 -070034endef
35
Colin Crossdd2ff552014-07-09 22:09:50 -070036DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
37DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
38DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
39DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
Brian Carlstromcffe2892014-07-08 10:35:29 -070040
Nikola Veljkovica57aaa32014-12-23 13:50:18 +010041ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
Ian Rogers7d70f832014-07-16 18:06:02 -070042# 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.
48LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
Ian Rogers87f0d002014-07-16 22:25:35 -070049DEX2OAT_XMX := 128m
Ian Rogers7d70f832014-07-16 18:06:02 -070050endif
51
Brian Carlstromced4bff2013-11-14 23:44:56 -080052########################################################################
53# The full system boot classpath
54
Ying Wangb9aa5d42014-05-13 13:57:28 -070055# 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.
58define get-odex-file-path
Richard Uhler820fe322015-03-16 14:38:17 -070059$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
Ying Wangb9aa5d42014-05-13 13:57:28 -070060endef
61
Alex Light4e358ab2016-06-16 14:47:10 -070062# 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.
67ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
68define 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)))
72endef
73else
74get-odex-installed-file-path = $(get-odex-file-path)
75endif
76
Ying Wangb9aa5d42014-05-13 13:57:28 -070077# 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")
80define get-image-file-path
81$(dir $(2))$(1)/$(notdir $(2))
82endef
83
Brian Carlstromced4bff2013-11-14 23:44:56 -080084# note we use core-libart.jar in place of core.jar for ART.
85LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
86LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
87LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
88
Colin Cross52dcb2f2016-03-08 13:21:49 -080089# 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.
Ying Wang222ebac2016-03-15 12:13:56 -070093LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat)
94LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat
Colin Cross52dcb2f2016-03-08 13:21:49 -080095
Ying Wangb9aa5d42014-05-13 13:57:28 -070096my_2nd_arch_prefix :=
97include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
Brian Carlstromced4bff2013-11-14 23:44:56 -080098
Ying Wangb9aa5d42014-05-13 13:57:28 -070099ifdef TARGET_2ND_ARCH
100my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
101include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
102my_2nd_arch_prefix :=
103endif
Brian Carlstromced4bff2013-11-14 23:44:56 -0800104
105
106########################################################################
107# For a single jar or APK
108
Ying Wangb9aa5d42014-05-13 13:57:28 -0700109# $(1): the input .jar or .apk file
110# $(2): the output .odex file
Brian Carlstromced4bff2013-11-14 23:44:56 -0800111define dex2oat-one-file
Ying Wangb9aa5d42014-05-13 13:57:28 -0700112$(hide) rm -f $(2)
113$(hide) mkdir -p $(dir $(2))
Joe Onorato401ffae2016-03-09 14:48:46 -0800114$(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
Colin Crossdd2ff552014-07-09 22:09:50 -0700115 --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
Jeff Haob00263f2016-06-13 16:53:11 -0700116 --runtime-arg -classpath --runtime-arg $(DEX2OAT_CLASSPATH) \
Ying Wangb9aa5d42014-05-13 13:57:28 -0700117 --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
118 --dex-file=$(1) \
119 --dex-location=$(PRIVATE_DEX_LOCATION) \
120 --oat-file=$(2) \
Brian Carlstromced4bff2013-11-14 23:44:56 -0800121 --android-root=$(PRODUCT_OUT)/system \
Ying Wangb9aa5d42014-05-13 13:57:28 -0700122 --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
Ian Rogersa18a2832014-10-17 01:05:50 -0700123 --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
Alex Lightce090d32014-07-24 16:26:13 -0700124 --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
David Srbeckyd8fae9a2015-05-28 16:32:55 +0100125 --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
Andreas Gampe06d86e92015-03-05 19:18:18 -0800126 --abort-on-hard-verifier-error \
Jeff Haod1d3fd92015-12-16 17:20:11 -0800127 --no-inline-from=core-oj.jar \
Ying Wang3a61eeb2016-03-11 10:32:01 -0800128 $(PRIVATE_DEX_PREOPT_FLAGS) \
129 $(GLOBAL_DEXPREOPT_FLAGS)
Brian Carlstromced4bff2013-11-14 23:44:56 -0800130endef