diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index 602ad008af..7340ddc442 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -59,6 +59,25 @@ built_installed_vdex := built_installed_art := ifdef LOCAL_DEX_PREOPT + +ifeq (false,$(WITH_DEX_PREOPT_GENERATE_PROFILE)) +LOCAL_DEX_PREOPT_GENERATE_PROFILE := false +endif + +ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE +# If LOCAL_DEX_PREOPT_GENERATE_PROFILE is not defined, default it based on the existence of the +# profile class listing. TODO: Use product specific directory here. +my_classes_directory := $(PRODUCT_DEX_PREOPT_PROFILE_DIR) +LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING := $(my_classes_directory)/$(LOCAL_MODULE).prof.txt +ifneq (,$(wildcard $(LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING))) +# Profile listing exists, use it to generate the profile. +ifeq ($(LOCAL_DEX_PREOPT_APP_IMAGE),) +LOCAL_DEX_PREOPT_APP_IMAGE := true +endif +LOCAL_DEX_PREOPT_GENERATE_PROFILE := true +endif +endif + dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)) ifdef dexpreopt_boot_jar_module # For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE). @@ -113,13 +132,6 @@ installed_vdex := $(strip $(installed_vdex)) installed_art := $(strip $(installed_art)) ifdef built_odex - -ifndef LOCAL_DEX_PREOPT_GENERATE_PROFILE -ifeq (true,$(WITH_DEX_PREOPT_GENERATE_PROFILE)) - LOCAL_DEX_PREOPT_GENERATE_PROFILE := true -endif -endif - ifeq (true,$(LOCAL_DEX_PREOPT_GENERATE_PROFILE)) ifndef LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING $(call pretty-error,Must have specified class listing (LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING)) diff --git a/core/product.mk b/core/product.mk index c5ddf817a2..070986b06c 100644 --- a/core/product.mk +++ b/core/product.mk @@ -123,6 +123,7 @@ _product_var_list := \ PRODUCT_DEX_PREOPT_MODULE_CONFIGS \ PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \ PRODUCT_DEX_PREOPT_BOOT_FLAGS \ + PRODUCT_DEX_PREOPT_PROFILE_DIR \ PRODUCT_SANITIZER_MODULE_CONFIGS \ PRODUCT_SYSTEM_BASE_FS_PATH \ PRODUCT_VENDOR_BASE_FS_PATH \ diff --git a/core/product_config.mk b/core/product_config.mk index 36f473ff04..ed8b9a72be 100644 --- a/core/product_config.mk +++ b/core/product_config.mk @@ -380,6 +380,9 @@ PRODUCT_DEX_PREOPT_DEFAULT_FLAGS := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)) PRODUCT_DEX_PREOPT_BOOT_FLAGS := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_BOOT_FLAGS)) +PRODUCT_DEX_PREOPT_PROFILE_DIR := \ + $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_PROFILE_DIR)) + # Resolve and setup per-module dex-preopt configs. PRODUCT_DEX_PREOPT_MODULE_CONFIGS := \ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_MODULE_CONFIGS))