2013-11-15 15:44:56 +08:00
|
|
|
####################################
|
|
|
|
# dexpreopt support for ART
|
|
|
|
#
|
|
|
|
####################################
|
|
|
|
|
2015-07-28 03:48:39 +08:00
|
|
|
# Default to debug version to help find bugs.
|
|
|
|
# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
|
|
|
|
ifeq ($(USE_DEX2OAT_DEBUG),false)
|
2013-11-15 15:44:56 +08:00
|
|
|
DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
|
2017-11-15 05:29:24 +08:00
|
|
|
PATCHOAT := $(HOST_OUT_EXECUTABLES)/patchoat$(HOST_EXECUTABLE_SUFFIX)
|
2015-07-28 03:48:39 +08:00
|
|
|
else
|
|
|
|
DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
|
2017-11-15 05:29:24 +08:00
|
|
|
PATCHOAT := $(HOST_OUT_EXECUTABLES)/patchoatd$(HOST_EXECUTABLE_SUFFIX)
|
2015-07-28 03:48:39 +08:00
|
|
|
endif
|
2013-11-15 15:44:56 +08:00
|
|
|
|
|
|
|
DEX2OAT_DEPENDENCY += $(DEX2OAT)
|
2017-11-15 05:29:24 +08:00
|
|
|
PATCHOAT_DEPENDENCY += $(PATCHOAT)
|
2013-11-15 15:44:56 +08:00
|
|
|
|
2014-11-14 07:19:12 +08:00
|
|
|
# Use the first preloaded-classes file in PRODUCT_COPY_FILES.
|
|
|
|
PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
|
|
|
|
$(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
|
2013-11-15 15:44:56 +08:00
|
|
|
|
2017-08-03 07:45:49 +08:00
|
|
|
# Use the first dirty-image-objects file in PRODUCT_COPY_FILES.
|
|
|
|
DIRTY_IMAGE_OBJECTS := $(call word-colon,1,$(firstword \
|
|
|
|
$(filter %system/etc/dirty-image-objects,$(PRODUCT_COPY_FILES))))
|
|
|
|
|
2014-07-10 13:09:50 +08:00
|
|
|
define get-product-default-property
|
2017-11-03 14:33:10 +08:00
|
|
|
$(strip \
|
|
|
|
$(eval _prop := $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))\
|
|
|
|
$(if $(_prop),$(_prop),$(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_SYSTEM_DEFAULT_PROPERTIES)))))
|
2014-07-09 01:35:29 +08:00
|
|
|
endef
|
|
|
|
|
2014-07-10 13:09:50 +08:00
|
|
|
DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
|
|
|
|
DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
|
|
|
|
DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
|
|
|
|
DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
|
2014-07-09 01:35:29 +08:00
|
|
|
|
2014-12-23 20:50:18 +08:00
|
|
|
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
|
2014-07-17 09:06:02 +08:00
|
|
|
# MIPS specific overrides.
|
|
|
|
# For MIPS the ART image is loaded at a lower address. This causes issues
|
|
|
|
# with the image overlapping with memory on the host cross-compiling and
|
|
|
|
# building the image. We therefore limit the Xmx value. This isn't done
|
|
|
|
# via a property as we want the larger Xmx value if we're running on a
|
|
|
|
# MIPS device.
|
2014-07-17 13:25:35 +08:00
|
|
|
DEX2OAT_XMX := 128m
|
2014-07-17 09:06:02 +08:00
|
|
|
endif
|
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
########################################################################
|
|
|
|
# The full system boot classpath
|
|
|
|
|
2014-05-14 04:57:28 +08:00
|
|
|
# Returns the path to the .odex file
|
|
|
|
# $(1): the arch name.
|
|
|
|
# $(2): the full path (including file name) of the corresponding .jar or .apk.
|
|
|
|
define get-odex-file-path
|
2015-03-17 05:38:17 +08:00
|
|
|
$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
|
2014-05-14 04:57:28 +08:00
|
|
|
endef
|
|
|
|
|
2016-06-17 05:47:10 +08:00
|
|
|
# Returns the full path to the installed .odex file.
|
|
|
|
# This handles BOARD_USES_SYSTEM_OTHER_ODEX to install odex files into another
|
|
|
|
# partition.
|
|
|
|
# $(1): the arch name.
|
|
|
|
# $(2): the full install path (including file name) of the corresponding .apk.
|
|
|
|
ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
|
|
|
|
define get-odex-installed-file-path
|
2017-03-24 22:45:59 +08:00
|
|
|
$(if $(call install-on-system-other, $(2)),
|
2016-06-17 05:47:10 +08:00
|
|
|
$(call get-odex-file-path,$(1),$(patsubst $(TARGET_OUT)/%,$(TARGET_OUT_SYSTEM_OTHER)/%,$(2))),
|
|
|
|
$(call get-odex-file-path,$(1),$(2)))
|
|
|
|
endef
|
|
|
|
else
|
|
|
|
get-odex-installed-file-path = $(get-odex-file-path)
|
|
|
|
endif
|
|
|
|
|
2014-05-14 04:57:28 +08:00
|
|
|
# Returns the path to the image file (such as "/system/framework/<arch>/boot.art"
|
|
|
|
# $(1): the arch name (such as "arm")
|
|
|
|
# $(2): the image location (such as "/system/framework/boot.art")
|
|
|
|
define get-image-file-path
|
|
|
|
$(dir $(2))$(1)/$(notdir $(2))
|
|
|
|
endef
|
|
|
|
|
2013-11-15 15:44:56 +08:00
|
|
|
# note we use core-libart.jar in place of core.jar for ART.
|
|
|
|
LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
|
|
|
|
LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
|
|
|
|
LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
|
|
|
|
|
2016-03-09 05:21:49 +08:00
|
|
|
# dex preopt on the bootclasspath produces multiple files. The first dex file
|
|
|
|
# is converted into to boot.art (to match the legacy assumption that boot.art
|
|
|
|
# exists), and the rest are converted to boot-<name>.art.
|
|
|
|
# In addition, each .art file has an associated .oat file.
|
2017-08-16 16:28:05 +08:00
|
|
|
LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).art.rel boot-$(jar).oat)
|
|
|
|
LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.art.rel boot.oat
|
|
|
|
LIBART_TARGET_BOOT_ART_VDEX_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).vdex)
|
|
|
|
LIBART_TARGET_BOOT_ART_VDEX_FILES += boot.vdex
|
2016-03-09 05:21:49 +08:00
|
|
|
|
2017-06-29 09:23:37 +08:00
|
|
|
# If we use a boot image profile.
|
|
|
|
my_use_profile_for_boot_image := $(PRODUCT_USE_PROFILE_FOR_BOOT_IMAGE)
|
|
|
|
ifeq (,$(my_use_profile_for_boot_image))
|
2017-10-25 06:22:57 +08:00
|
|
|
# If not set, set the default to true if we are not a PDK build. PDK builds
|
|
|
|
# can't build the profile since they don't have frameworks/base.
|
|
|
|
ifneq (true,$(TARGET_BUILD_PDK))
|
2017-08-29 09:42:02 +08:00
|
|
|
my_use_profile_for_boot_image := true
|
2017-06-29 09:23:37 +08:00
|
|
|
endif
|
2017-10-25 06:22:57 +08:00
|
|
|
endif
|
2017-06-29 09:23:37 +08:00
|
|
|
|
|
|
|
ifeq (true,$(my_use_profile_for_boot_image))
|
|
|
|
|
|
|
|
# Location of text based profile for the boot image.
|
|
|
|
my_boot_image_profile_location := $(PRODUCT_DEX_PREOPT_BOOT_IMAGE_PROFILE_LOCATION)
|
|
|
|
ifeq (,$(my_boot_image_profile_location))
|
|
|
|
# If not set, use the default.
|
2017-08-29 09:42:02 +08:00
|
|
|
my_boot_image_profile_location := frameworks/base/config/boot-image-profile.txt
|
2017-06-29 09:23:37 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Code to create the boot image profile, not in dex_preopt_libart_boot.mk since the profile is the same for all archs.
|
|
|
|
my_out_boot_image_profile_location := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.prof
|
|
|
|
$(my_out_boot_image_profile_location): PRIVATE_PROFILE_INPUT_LOCATION := $(my_boot_image_profile_location)
|
|
|
|
$(my_out_boot_image_profile_location): $(PROFMAN) $(LIBART_TARGET_BOOT_DEX_FILES) $(my_boot_image_profile_location)
|
|
|
|
@echo "target profman: $@"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
ANDROID_LOG_TAGS="*:e" $(PROFMAN) \
|
|
|
|
--create-profile-from=$(PRIVATE_PROFILE_INPUT_LOCATION) \
|
|
|
|
$(addprefix --apk=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
|
|
|
|
$(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
|
|
|
|
--reference-profile-file=$@
|
|
|
|
|
|
|
|
# We want to install the profile even if we are not using preopt since it is required to generate
|
|
|
|
# the image on the device.
|
|
|
|
my_installed_profile := $(TARGET_OUT)/etc/boot-image.prof
|
|
|
|
$(eval $(call copy-one-file,$(my_out_boot_image_profile_location),$(my_installed_profile)))
|
|
|
|
ALL_DEFAULT_INSTALLED_MODULES += $(my_installed_profile)
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
2017-08-16 16:28:05 +08:00
|
|
|
LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES := $(addprefix $(PRODUCT_OUT)/$(DEXPREOPT_BOOT_JAR_DIR)/,$(LIBART_TARGET_BOOT_ART_VDEX_FILES))
|
|
|
|
|
2014-05-14 04:57:28 +08:00
|
|
|
my_2nd_arch_prefix :=
|
|
|
|
include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
|
|
|
|
|
2016-03-17 10:53:19 +08:00
|
|
|
ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
|
2014-05-14 04:57:28 +08:00
|
|
|
ifdef TARGET_2ND_ARCH
|
|
|
|
my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
|
|
|
|
include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
|
|
|
|
endif
|
2016-03-17 10:53:19 +08:00
|
|
|
endif
|
2013-11-15 15:44:56 +08:00
|
|
|
|
2017-08-16 16:28:05 +08:00
|
|
|
# Copy shared vdex to the directory and create corresponding symlinks in primary and secondary arch.
|
|
|
|
$(LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) : PRIMARY_ARCH_DIR := $(dir $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE))
|
|
|
|
$(LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) : SECOND_ARCH_DIR := $(dir $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE))
|
|
|
|
$(LIBART_TARGET_BOOT_ART_VDEX_INSTALLED_SHARED_FILES) : $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
|
|
|
|
@echo "Install: $@"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@rm -f $@
|
|
|
|
$(hide) cp "$(dir $<)$(notdir $@)" "$@"
|
|
|
|
# Make symlink for both the archs. In the case its single arch the symlink will just get overridden.
|
|
|
|
@mkdir -p $(PRIMARY_ARCH_DIR)
|
|
|
|
$(hide) ln -sf /$(DEXPREOPT_BOOT_JAR_DIR)/$(notdir $@) $(PRIMARY_ARCH_DIR)$(notdir $@)
|
|
|
|
@mkdir -p $(SECOND_ARCH_DIR)
|
|
|
|
$(hide) ln -sf /$(DEXPREOPT_BOOT_JAR_DIR)/$(notdir $@) $(SECOND_ARCH_DIR)$(notdir $@)
|
|
|
|
|
|
|
|
my_2nd_arch_prefix :=
|
2013-11-15 15:44:56 +08:00
|
|
|
|
|
|
|
########################################################################
|
|
|
|
# For a single jar or APK
|
|
|
|
|
2014-05-14 04:57:28 +08:00
|
|
|
# $(1): the input .jar or .apk file
|
|
|
|
# $(2): the output .odex file
|
2018-03-24 12:57:02 +08:00
|
|
|
# In the case where LOCAL_ENFORCE_USES_LIBRARIES is true, PRIVATE_DEX2OAT_CLASS_LOADER_CONTEXT
|
|
|
|
# contains the normalized path list of the libraries. This makes it easier to conditionally prepend
|
|
|
|
# org.apache.http.legacy.boot based on the SDK level if required.
|
2013-11-15 15:44:56 +08:00
|
|
|
define dex2oat-one-file
|
2014-05-14 04:57:28 +08:00
|
|
|
$(hide) rm -f $(2)
|
|
|
|
$(hide) mkdir -p $(dir $(2))
|
2018-03-24 12:57:02 +08:00
|
|
|
stored_class_loader_context_libs=$(PRIVATE_DEX2OAT_STORED_CLASS_LOADER_CONTEXT_LIBS) && \
|
|
|
|
class_loader_context_arg=--class-loader-context=$(PRIVATE_DEX2OAT_CLASS_LOADER_CONTEXT) && \
|
|
|
|
class_loader_context=$(PRIVATE_DEX2OAT_CLASS_LOADER_CONTEXT) && \
|
|
|
|
stored_class_loader_context_arg="" && \
|
|
|
|
uses_library_names="$(PRIVATE_USES_LIBRARY_NAMES)" && \
|
|
|
|
optional_uses_library_names="$(PRIVATE_OPTIONAL_USES_LIBRARY_NAMES)" && \
|
2018-05-12 00:33:41 +08:00
|
|
|
$(if $(filter true,$(PRIVATE_ENFORCE_USES_LIBRARIES)), \
|
2018-03-24 12:57:02 +08:00
|
|
|
source build/make/core/verify_uses_libraries.sh "$(1)" && \
|
|
|
|
source build/make/core/construct_context.sh "$(PRIVATE_CONDITIONAL_USES_LIBRARIES_HOST)" "$(PRIVATE_CONDITIONAL_USES_LIBRARIES_TARGET)" && \
|
|
|
|
,) \
|
|
|
|
ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
|
2014-07-10 13:09:50 +08:00
|
|
|
--runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
|
2018-03-24 12:57:02 +08:00
|
|
|
$${class_loader_context_arg} \
|
|
|
|
$${stored_class_loader_context_arg} \
|
2014-05-14 04:57:28 +08:00
|
|
|
--boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
|
|
|
|
--dex-file=$(1) \
|
|
|
|
--dex-location=$(PRIVATE_DEX_LOCATION) \
|
|
|
|
--oat-file=$(2) \
|
2013-11-15 15:44:56 +08:00
|
|
|
--android-root=$(PRODUCT_OUT)/system \
|
2014-05-14 04:57:28 +08:00
|
|
|
--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
|
2014-10-17 16:05:50 +08:00
|
|
|
--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
|
2014-07-25 07:26:13 +08:00
|
|
|
--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
|
2017-03-01 01:05:12 +08:00
|
|
|
--runtime-arg -Xnorelocate --compile-pic \
|
2016-09-20 01:54:21 +08:00
|
|
|
--no-generate-debug-info --generate-build-id \
|
2015-03-06 11:18:18 +08:00
|
|
|
--abort-on-hard-verifier-error \
|
2017-04-28 22:00:28 +08:00
|
|
|
--force-determinism \
|
2015-12-17 09:20:11 +08:00
|
|
|
--no-inline-from=core-oj.jar \
|
2016-03-12 02:32:01 +08:00
|
|
|
$(PRIVATE_DEX_PREOPT_FLAGS) \
|
2017-02-09 10:30:31 +08:00
|
|
|
$(PRIVATE_ART_FILE_PREOPT_FLAGS) \
|
2017-03-01 03:17:32 +08:00
|
|
|
$(PRIVATE_PROFILE_PREOPT_FLAGS) \
|
2016-03-12 02:32:01 +08:00
|
|
|
$(GLOBAL_DEXPREOPT_FLAGS)
|
2013-11-15 15:44:56 +08:00
|
|
|
endef
|