blob: 33f5d7f848cda298bfe4f82b91aed4fb67a04c62 [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
Brian Carlstromced4bff2013-11-14 23:44:56 -080014DEX2OAT_DEPENDENCY += $(DEX2OAT)
Brian Carlstromced4bff2013-11-14 23:44:56 -080015
Ying Wang0c9b3ba2014-11-13 15:19:12 -080016# Use the first preloaded-classes file in PRODUCT_COPY_FILES.
17PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
18 $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
Brian Carlstromced4bff2013-11-14 23:44:56 -080019
Andreas Gampe96a52202014-11-18 11:45:10 -080020# Use the first compiled-classes file in PRODUCT_COPY_FILES.
21COMPILED_CLASSES := $(call word-colon,1,$(firstword \
22 $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
23
Jeff Hao4ae165c2017-08-02 16:45:49 -070024# Use the first dirty-image-objects file in PRODUCT_COPY_FILES.
25DIRTY_IMAGE_OBJECTS := $(call word-colon,1,$(firstword \
26 $(filter %system/etc/dirty-image-objects,$(PRODUCT_COPY_FILES))))
27
Colin Crossdd2ff552014-07-09 22:09:50 -070028define get-product-default-property
29$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
Brian Carlstromcffe2892014-07-08 10:35:29 -070030endef
31
Colin Crossdd2ff552014-07-09 22:09:50 -070032DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
33DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
34DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
35DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
Brian Carlstromcffe2892014-07-08 10:35:29 -070036
Nikola Veljkovica57aaa32014-12-23 13:50:18 +010037ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
Ian Rogers7d70f832014-07-16 18:06:02 -070038# MIPS specific overrides.
39# For MIPS the ART image is loaded at a lower address. This causes issues
40# with the image overlapping with memory on the host cross-compiling and
41# building the image. We therefore limit the Xmx value. This isn't done
42# via a property as we want the larger Xmx value if we're running on a
43# MIPS device.
Ian Rogers87f0d002014-07-16 22:25:35 -070044DEX2OAT_XMX := 128m
Ian Rogers7d70f832014-07-16 18:06:02 -070045endif
46
Brian Carlstromced4bff2013-11-14 23:44:56 -080047########################################################################
48# The full system boot classpath
49
Ying Wangb9aa5d42014-05-13 13:57:28 -070050# 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
Richard Uhler820fe322015-03-16 14:38:17 -070054$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
Ying Wangb9aa5d42014-05-13 13:57:28 -070055endef
56
Alex Light4e358ab2016-06-16 14:47:10 -070057# Returns the full path to the installed .odex file.
58# This handles BOARD_USES_SYSTEM_OTHER_ODEX to install odex files into another
59# partition.
60# $(1): the arch name.
61# $(2): the full install path (including file name) of the corresponding .apk.
62ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
63define get-odex-installed-file-path
Nicolas Geoffraycdd43432017-03-24 14:45:59 +000064$(if $(call install-on-system-other, $(2)),
Alex Light4e358ab2016-06-16 14:47:10 -070065 $(call get-odex-file-path,$(1),$(patsubst $(TARGET_OUT)/%,$(TARGET_OUT_SYSTEM_OTHER)/%,$(2))),
66 $(call get-odex-file-path,$(1),$(2)))
67endef
68else
69get-odex-installed-file-path = $(get-odex-file-path)
70endif
71
Ying Wangb9aa5d42014-05-13 13:57:28 -070072# Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
73# $(1): the arch name (such as "arm")
74# $(2): the image location (such as "/system/framework/boot.art")
75define get-image-file-path
76$(dir $(2))$(1)/$(notdir $(2))
77endef
78
Brian Carlstromced4bff2013-11-14 23:44:56 -080079# note we use core-libart.jar in place of core.jar for ART.
80LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
81LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
82LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
83
Colin Cross52dcb2f2016-03-08 13:21:49 -080084# dex preopt on the bootclasspath produces multiple files. The first dex file
85# is converted into to boot.art (to match the legacy assumption that boot.art
86# exists), and the rest are converted to boot-<name>.art.
87# In addition, each .art file has an associated .oat file.
David Brazdil70470162016-08-25 13:50:15 +010088LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat boot-$(jar).vdex)
89LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat boot.vdex
Colin Cross52dcb2f2016-03-08 13:21:49 -080090
Mathieu Chartier77226f62017-06-28 18:23:37 -070091# If we use a boot image profile.
92my_use_profile_for_boot_image := $(PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE)
93ifeq (,$(my_use_profile_for_boot_image))
Mathieu Chartier83bae862017-10-24 15:22:57 -070094# If not set, set the default to true if we are not a PDK build. PDK builds
95# can't build the profile since they don't have frameworks/base.
96ifneq (true,$(TARGET_BUILD_PDK))
Mathieu Chartierbf9023a2017-08-28 18:42:02 -070097my_use_profile_for_boot_image := true
Mathieu Chartier77226f62017-06-28 18:23:37 -070098endif
Mathieu Chartier83bae862017-10-24 15:22:57 -070099endif
Mathieu Chartier77226f62017-06-28 18:23:37 -0700100
101ifeq (true,$(my_use_profile_for_boot_image))
102
103# Location of text based profile for the boot image.
104my_boot_image_profile_location := $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION)
105ifeq (,$(my_boot_image_profile_location))
106# If not set, use the default.
Mathieu Chartier75edf542017-08-28 18:42:02 -0700107my_boot_image_profile_location := frameworks/base/config/boot-image-profile.txt
Mathieu Chartier77226f62017-06-28 18:23:37 -0700108endif
109
110# Code to create the boot image profile, not in dex_preopt_libart_boot.mk since the profile is the same for all archs.
111my_out_boot_image_profile_location := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.prof
112$(my_out_boot_image_profile_location): PRIVATE_PROFILE_INPUT_LOCATION := $(my_boot_image_profile_location)
113$(my_out_boot_image_profile_location): $(PROFMAN) $(LIBART_TARGET_BOOT_DEX_FILES) $(my_boot_image_profile_location)
114 @echo "target profman: $@"
115 @mkdir -p $(dir $@)
116 ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
117 --create-profile-from=$(PRIVATE_PROFILE_INPUT_LOCATION) \
118 $(addprefix --apk=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
119 $(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
120 --reference-profile-file=$@
121
122# We want to install the profile even if we are not using preopt since it is required to generate
123# the image on the device.
124my_installed_profile := $(TARGET_OUT)/etc/boot-image.prof
125$(eval $(call copy-one-file,$(my_out_boot_image_profile_location),$(my_installed_profile)))
126ALL_DEFAULT_INSTALLED_MODULES += $(my_installed_profile)
127
128endif
129
Ying Wangb9aa5d42014-05-13 13:57:28 -0700130my_2nd_arch_prefix :=
131include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
Brian Carlstromced4bff2013-11-14 23:44:56 -0800132
Ying Wang87538e42016-03-16 19:53:19 -0700133ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
Ying Wangb9aa5d42014-05-13 13:57:28 -0700134ifdef TARGET_2ND_ARCH
135my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
136include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
137my_2nd_arch_prefix :=
138endif
Ying Wang87538e42016-03-16 19:53:19 -0700139endif
Brian Carlstromced4bff2013-11-14 23:44:56 -0800140
141
142########################################################################
143# For a single jar or APK
144
Ying Wangb9aa5d42014-05-13 13:57:28 -0700145# $(1): the input .jar or .apk file
146# $(2): the output .odex file
Brian Carlstromced4bff2013-11-14 23:44:56 -0800147define dex2oat-one-file
Ying Wangb9aa5d42014-05-13 13:57:28 -0700148$(hide) rm -f $(2)
149$(hide) mkdir -p $(dir $(2))
Joe Onorato401ffae2016-03-09 14:48:46 -0800150$(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
Colin Crossdd2ff552014-07-09 22:09:50 -0700151 --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
Andreas Gampe1207c862017-08-31 19:24:32 -0700152 --class-loader-context=$(PRIVATE_DEX2OAT_CLASS_LOADER_CONTEXT) \
Ying Wangb9aa5d42014-05-13 13:57:28 -0700153 --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
154 --dex-file=$(1) \
155 --dex-location=$(PRIVATE_DEX_LOCATION) \
156 --oat-file=$(2) \
Brian Carlstromced4bff2013-11-14 23:44:56 -0800157 --android-root=$(PRODUCT_OUT)/system \
Ying Wangb9aa5d42014-05-13 13:57:28 -0700158 --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
Ian Rogersa18a2832014-10-17 01:05:50 -0700159 --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
Alex Lightce090d32014-07-24 16:26:13 -0700160 --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
Richard Uhler41408b02017-02-28 17:05:12 +0000161 --runtime-arg -Xnorelocate --compile-pic \
Alexey Alexandrove4690632016-09-19 10:54:21 -0700162 --no-generate-debug-info --generate-build-id \
Andreas Gampe06d86e92015-03-05 19:18:18 -0800163 --abort-on-hard-verifier-error \
Nicolas Geoffraya5bb1802017-04-28 15:00:28 +0100164 --force-determinism \
Jeff Haod1d3fd92015-12-16 17:20:11 -0800165 --no-inline-from=core-oj.jar \
Ying Wang3a61eeb2016-03-11 10:32:01 -0800166 $(PRIVATE_DEX_PREOPT_FLAGS) \
Mathieu Chartier192b91c2017-02-08 18:30:31 -0800167 $(PRIVATE_ART_FILE_PREOPT_FLAGS) \
Mathieu Chartiera4b993b2017-02-28 11:17:32 -0800168 $(PRIVATE_PROFILE_PREOPT_FLAGS) \
Ying Wang3a61eeb2016-03-11 10:32:01 -0800169 $(GLOBAL_DEXPREOPT_FLAGS)
Brian Carlstromced4bff2013-11-14 23:44:56 -0800170endef