1#################################### 2# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time 3# 4#################################### 5 6include $(BUILD_SYSTEM)/dex_preopt_config.mk 7 8# Method returning whether the install path $(1) should be for system_other. 9# Under SANITIZE_LITE, we do not want system_other. Just put things under /data/asan. 10ifeq ($(SANITIZE_LITE),true) 11install-on-system-other = 12else 13install-on-system-other = $(filter-out $(PRODUCT_DEXPREOPT_SPEED_APPS) $(PRODUCT_SYSTEM_SERVER_APPS),$(basename $(notdir $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(1))))) 14endif 15 16# We want to install the profile even if we are not using preopt since it is required to generate 17# the image on the device. 18ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED),$(PRODUCT_OUT)) 19 20# Install boot images. Note that there can be multiple. 21my_boot_image_arch := TARGET_ARCH 22my_boot_image_out := $(PRODUCT_OUT) 23my_boot_image_syms := $(TARGET_OUT_UNSTRIPPED) 24DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE := \ 25 $(foreach my_boot_image_name,$(DEXPREOPT_IMAGE_NAMES),$(strip \ 26 $(eval include $(BUILD_SYSTEM)/dex_preopt_libart.mk) \ 27 $(my_boot_image_module))) 28ifdef TARGET_2ND_ARCH 29 my_boot_image_arch := TARGET_2ND_ARCH 30 2ND_DEFAULT_DEX_PREOPT_INSTALLED_IMAGE_MODULE := \ 31 $(foreach my_boot_image_name,$(DEXPREOPT_IMAGE_NAMES),$(strip \ 32 $(eval include $(BUILD_SYSTEM)/dex_preopt_libart.mk) \ 33 $(my_boot_image_module))) 34endif 35# Install boot images for testing on host. We exclude framework image as it is not part of art manifest. 36my_boot_image_arch := HOST_ARCH 37my_boot_image_out := $(HOST_OUT) 38my_boot_image_syms := $(HOST_OUT)/symbols 39HOST_BOOT_IMAGE_MODULE := \ 40 $(foreach my_boot_image_name,art_host,$(strip \ 41 $(eval include $(BUILD_SYSTEM)/dex_preopt_libart.mk) \ 42 $(my_boot_image_module))) 43HOST_BOOT_IMAGE := $(call module-installed-files,$(HOST_BOOT_IMAGE_MODULE)) 44ifdef HOST_2ND_ARCH 45 my_boot_image_arch := HOST_2ND_ARCH 46 2ND_HOST_BOOT_IMAGE_MODULE := \ 47 $(foreach my_boot_image_name,art_host,$(strip \ 48 $(eval include $(BUILD_SYSTEM)/dex_preopt_libart.mk) \ 49 $(my_boot_image_module))) 50 2ND_HOST_BOOT_IMAGE := $(call module-installed-files,$(2ND_HOST_BOOT_IMAGE_MODULE)) 51endif 52my_boot_image_arch := 53my_boot_image_out := 54my_boot_image_syms := 55my_boot_image_module := 56 57# Build the boot.zip which contains the boot jars and their compilation output 58# We can do this only if preopt is enabled and if the product uses libart config (which sets the 59# default properties for preopting). 60# At the time of writing, this is only for ART Cloud. 61ifeq ($(WITH_DEXPREOPT), true) 62ifneq ($(WITH_DEXPREOPT_ART_BOOT_IMG_ONLY), true) 63ifeq ($(PRODUCT_USES_DEFAULT_ART_CONFIG), true) 64 65boot_zip := $(PRODUCT_OUT)/boot.zip 66bootclasspath_jars := $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES) 67 68# TODO remove system_server_jars usages from boot.zip and depend directly on system_server.zip file. 69 70# Use "/system" path for JARs with "platform:" prefix. 71# These JARs counterintuitively use "platform" prefix but they will 72# be actually installed to /system partition. 73platform_system_server_jars = $(filter platform:%, $(PRODUCT_SYSTEM_SERVER_JARS)) 74system_server_jars := \ 75 $(foreach m,$(platform_system_server_jars),\ 76 $(PRODUCT_OUT)/system/framework/$(call word-colon,2,$(m)).jar) 77 78# For the remaining system server JARs use the partition signified by the prefix. 79# For example, prefix "system_ext:" will use "/system_ext" path. 80other_system_server_jars = $(filter-out $(platform_system_server_jars), $(PRODUCT_SYSTEM_SERVER_JARS)) 81system_server_jars += \ 82 $(foreach m,$(other_system_server_jars),\ 83 $(PRODUCT_OUT)/$(call word-colon,1,$(m))/framework/$(call word-colon,2,$(m)).jar) 84 85# Infix can be 'art' (ART image for testing), 'boot' (primary), or 'mainline' (mainline extension). 86# Soong creates a set of variables for Make, one or each boot image. The only reason why the ART 87# image is exposed to Make is testing (art gtests) and benchmarking (art golem benchmarks). Install 88# rules that use those variables are in dex_preopt_libart.mk. Here for dexpreopt purposes the infix 89# is always 'boot' or 'mainline'. 90DEXPREOPT_INFIX := $(if $(filter true,$(DEX_PREOPT_WITH_UPDATABLE_BCP)),mainline,boot) 91 92# The input variables are written by build/soong/java/dexpreopt_bootjars.go. Examples can be found 93# at the bottom of build/soong/java/dexpreopt_config_testing.go. 94dexpreopt_root_dir := $(dir $(patsubst %/,%,$(dir $(firstword $(bootclasspath_jars))))) 95bootclasspath_arg := $(subst $(space),:,$(patsubst $(dexpreopt_root_dir)%,%,$(DEXPREOPT_BOOTCLASSPATH_DEX_FILES))) 96bootclasspath_locations_arg := $(subst $(space),:,$(DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS)) 97boot_images := $(subst :,$(space),$(DEXPREOPT_IMAGE_LOCATIONS_ON_DEVICE$(DEXPREOPT_INFIX))) 98boot_image_arg := $(subst $(space),:,$(patsubst /%,%,$(boot_images))) 99uffd_gc_flag_txt := $(OUT_DIR)/soong/dexpreopt/uffd_gc_flag.txt 100 101boot_zip_metadata_txt := $(dir $(boot_zip))boot_zip/METADATA.txt 102$(boot_zip_metadata_txt): $(uffd_gc_flag_txt) 103$(boot_zip_metadata_txt): 104 rm -f $@ 105 echo "bootclasspath = $(bootclasspath_arg)" >> $@ 106 echo "bootclasspath-locations = $(bootclasspath_locations_arg)" >> $@ 107 echo "boot-image = $(boot_image_arg)" >> $@ 108 echo "extra-args = `cat $(uffd_gc_flag_txt)`" >> $@ 109 110$(call dist-for-goals, droidcore, $(boot_zip_metadata_txt)) 111 112$(boot_zip): PRIVATE_BOOTCLASSPATH_JARS := $(bootclasspath_jars) 113$(boot_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars) 114$(boot_zip): $(bootclasspath_jars) $(system_server_jars) $(SOONG_ZIP) $(MERGE_ZIPS) $(DEXPREOPT_IMAGE_ZIP_boot) $(DEXPREOPT_IMAGE_ZIP_art) $(DEXPREOPT_IMAGE_ZIP_mainline) $(boot_zip_metadata_txt) 115 @echo "Create boot package: $@" 116 rm -f $@ 117 $(SOONG_ZIP) -o $@.tmp \ 118 -C $(dir $(firstword $(PRIVATE_BOOTCLASSPATH_JARS)))/.. $(addprefix -f ,$(PRIVATE_BOOTCLASSPATH_JARS)) \ 119 -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) \ 120 -j -f $(boot_zip_metadata_txt) 121 $(MERGE_ZIPS) $@ $@.tmp $(DEXPREOPT_IMAGE_ZIP_boot) $(DEXPREOPT_IMAGE_ZIP_art) $(DEXPREOPT_IMAGE_ZIP_mainline) 122 rm -f $@.tmp 123 124$(call dist-for-goals, droidcore, $(boot_zip)) 125 126# Build the system_server.zip which contains the Apex system server jars and standalone system server jars 127system_server_dex2oat_dir := $(SOONG_OUT_DIR)/system_server_dexjars 128system_server_zip := $(PRODUCT_OUT)/system_server.zip 129# non_updatable_system_server_jars contains jars in /system and /system_ext that are not part of an apex. 130non_updatable_system_server_jars := \ 131 $(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),\ 132 $(system_server_dex2oat_dir)/$(call word-colon,2,$(m)).jar) 133 134apex_system_server_jars := \ 135 $(foreach m,$(PRODUCT_APEX_SYSTEM_SERVER_JARS),\ 136 $(system_server_dex2oat_dir)/$(call word-colon,2,$(m)).jar) 137 138apex_standalone_system_server_jars := \ 139 $(foreach m,$(PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS),\ 140 $(system_server_dex2oat_dir)/$(call word-colon,2,$(m)).jar) 141 142standalone_system_server_jars := \ 143 $(foreach m,$(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS),\ 144 $(system_server_dex2oat_dir)/$(call word-colon,2,$(m)).jar) 145 146$(system_server_zip): PRIVATE_SYSTEM_SERVER_DEX2OAT_DIR := $(system_server_dex2oat_dir) 147$(system_server_zip): PRIVATE_SYSTEM_SERVER_JARS := $(non_updatable_system_server_jars) 148$(system_server_zip): PRIVATE_APEX_SYSTEM_SERVER_JARS := $(apex_system_server_jars) 149$(system_server_zip): PRIVATE_APEX_STANDALONE_SYSTEM_SERVER_JARS := $(apex_standalone_system_server_jars) 150$(system_server_zip): PRIVATE_STANDALONE_SYSTEM_SERVER_JARS := $(standalone_system_server_jars) 151$(system_server_zip): $(system_server_jars) $(apex_system_server_jars) $(apex_standalone_system_server_jars) $(standalone_system_server_jars) $(SOONG_ZIP) 152 @echo "Create system server package: $@" 153 rm -f $@ 154 $(SOONG_ZIP) -o $@ \ 155 -C $(PRIVATE_SYSTEM_SERVER_DEX2OAT_DIR) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) \ 156 -C $(PRIVATE_SYSTEM_SERVER_DEX2OAT_DIR) $(addprefix -f ,$(PRIVATE_APEX_SYSTEM_SERVER_JARS)) \ 157 -C $(PRIVATE_SYSTEM_SERVER_DEX2OAT_DIR) $(addprefix -f ,$(PRIVATE_APEX_STANDALONE_SYSTEM_SERVER_JARS)) \ 158 -C $(PRIVATE_SYSTEM_SERVER_DEX2OAT_DIR) $(addprefix -f ,$(PRIVATE_STANDALONE_SYSTEM_SERVER_JARS)) 159 160$(call dist-for-goals, droidcore, $(system_server_zip)) 161 162endif #PRODUCT_USES_DEFAULT_ART_CONFIG 163endif #WITH_DEXPREOPT_ART_BOOT_IMG_ONLY 164endif #WITH_DEXPREOPT 165