blob: 67911259b26dc374d86c5aec1953573f6401e108 [file] [log] [blame]
Ying Wange7874c42010-09-17 16:36:06 -07001####################################
Brian Carlstromced4bff2013-11-14 23:44:56 -08002# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
Ying Wange7874c42010-09-17 16:36:06 -07003#
4####################################
5
Colin Cross6db5b0e2018-11-16 21:26:33 -08006include $(BUILD_SYSTEM)/dex_preopt_config.mk
Alex Light4e358ab2016-06-16 14:47:10 -07007
Nicolas Geoffraycdd43432017-03-24 14:45:59 +00008# Method returning whether the install path $(1) should be for system_other.
Andreas Gampe4ed21d12017-06-16 10:24:54 -07009# Under SANITIZE_LITE, we do not want system_other. Just put things under /data/asan.
10ifeq ($(SANITIZE_LITE),true)
11install-on-system-other =
12else
Nicolas Geoffray4a0ad4a2017-06-12 15:19:16 +010013install-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)))))
Andreas Gampe4ed21d12017-06-16 10:24:54 -070014endif
Nicolas Geoffraycdd43432017-03-24 14:45:59 +000015
Nicolas Geoffray7e8ca9a2019-04-05 17:49:56 +010016# 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
Nicolas Geoffray269bc742019-02-22 15:33:23 +000020# Install boot images. Note that there can be multiple.
David Srbecky6dd11ec2020-02-11 13:46:45 +000021my_boot_image_arch := TARGET_ARCH
22my_boot_image_out := $(PRODUCT_OUT)
23my_boot_image_syms := $(TARGET_OUT_UNSTRIPPED)
Yo Chiang3ca49802020-07-01 20:16:07 +080024DEFAULT_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)))
David Srbecky6dd11ec2020-02-11 13:46:45 +000028ifdef TARGET_2ND_ARCH
29 my_boot_image_arch := TARGET_2ND_ARCH
Yo Chiang3ca49802020-07-01 20:16:07 +080030 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)))
David Srbecky6dd11ec2020-02-11 13:46:45 +000034endif
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
Yo Chiang3ca49802020-07-01 20:16:07 +080039HOST_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))
David Srbecky6dd11ec2020-02-11 13:46:45 +000044ifdef HOST_2ND_ARCH
45 my_boot_image_arch := HOST_2ND_ARCH
Yo Chiang3ca49802020-07-01 20:16:07 +080046 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))
David Srbecky6dd11ec2020-02-11 13:46:45 +000051endif
52my_boot_image_arch :=
53my_boot_image_out :=
54my_boot_image_syms :=
Yo Chiang3ca49802020-07-01 20:16:07 +080055my_boot_image_module :=
Brian Carlstromced4bff2013-11-14 23:44:56 -080056
Calin Juravle6bfdcda2019-04-16 13:05:42 -070057# 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).
60ifeq ($(WITH_DEXPREOPT), true)
Calin Juravlecdff6b12019-05-01 15:34:47 -070061ifeq ($(PRODUCT_USES_DEFAULT_ART_CONFIG), true)
Calin Juravle6bfdcda2019-04-16 13:05:42 -070062
63boot_zip := $(PRODUCT_OUT)/boot.zip
Colin Crossd8badf52019-02-20 12:39:57 -080064bootclasspath_jars := $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES)
Islam Elbannaab52f4b2022-11-04 15:51:07 +000065
66# TODO remove system_server_jars usages from boot.zip and depend directly on system_server.zip file.
Nick Chameyev3bb4b5d2022-12-19 16:05:28 +000067
68# Use "/system" path for JARs with "platform:" prefix.
69# These JARs counterintuitively use "platform" prefix but they will
70# be actually installed to /system partition.
71platform_system_server_jars = $(filter platform:%, $(PRODUCT_SYSTEM_SERVER_JARS))
satayev35a7a432021-05-04 16:14:02 +010072system_server_jars := \
Nick Chameyev3bb4b5d2022-12-19 16:05:28 +000073 $(foreach m,$(platform_system_server_jars),\
satayev35a7a432021-05-04 16:14:02 +010074 $(PRODUCT_OUT)/system/framework/$(call word-colon,2,$(m)).jar)
Calin Juravle8955a992018-05-10 11:33:27 -070075
Nick Chameyev3bb4b5d2022-12-19 16:05:28 +000076# For the remaining system server JARs use the partition signified by the prefix.
77# For example, prefix "system_ext:" will use "/system_ext" path.
78other_system_server_jars = $(filter-out $(platform_system_server_jars), $(PRODUCT_SYSTEM_SERVER_JARS))
79system_server_jars += \
80 $(foreach m,$(other_system_server_jars),\
81 $(PRODUCT_OUT)/$(call word-colon,1,$(m))/framework/$(call word-colon,2,$(m)).jar)
82
Jiakai Zhanga5551c52023-06-09 17:44:50 +010083# Infix can be 'art' (ART image for testing), 'boot' (primary), or 'mainline' (mainline extension).
84# Soong creates a set of variables for Make, one or each boot image. The only reason why the ART
85# image is exposed to Make is testing (art gtests) and benchmarking (art golem benchmarks). Install
86# rules that use those variables are in dex_preopt_libart.mk. Here for dexpreopt purposes the infix
87# is always 'boot' or 'mainline'.
88DEXPREOPT_INFIX := $(if $(filter true,$(DEX_PREOPT_WITH_UPDATABLE_BCP)),mainline,boot)
89
90# The input variables are written by build/soong/java/dexpreopt_bootjars.go. Examples can be found
91# at the bottom of build/soong/java/dexpreopt_config_testing.go.
92dexpreopt_root_dir := $(dir $(patsubst %/,%,$(dir $(firstword $(bootclasspath_jars)))))
Prashant Dubey029a6152023-09-18 17:57:53 +000093bootclasspath_arg := $(subst $(space),:,$(patsubst $(dexpreopt_root_dir)%,%,$(DEXPREOPT_BOOTCLASSPATH_DEX_FILES)))
94bootclasspath_locations_arg := $(subst $(space),:,$(DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS))
Jiakai Zhanga5551c52023-06-09 17:44:50 +010095boot_images := $(subst :,$(space),$(DEXPREOPT_IMAGE_LOCATIONS_ON_DEVICE$(DEXPREOPT_INFIX)))
96boot_image_arg := $(subst $(space),:,$(patsubst /%,%,$(boot_images)))
Jiakai Zhang96b155c2023-06-19 20:16:21 +010097dex2oat_extra_args := $(if $(filter true,$(ENABLE_UFFD_GC)),--runtime-arg -Xgc:CMC)
Jiakai Zhanga5551c52023-06-09 17:44:50 +010098
Jiakai Zhang34914f62023-06-12 11:18:12 +010099boot_zip_metadata_txt := $(dir $(boot_zip))boot_zip/METADATA.txt
Jiakai Zhanga5551c52023-06-09 17:44:50 +0100100$(boot_zip_metadata_txt):
101 rm -f $@
Prashant Dubey029a6152023-09-18 17:57:53 +0000102 echo "bootclasspath = $(bootclasspath_arg)" >> $@
103 echo "bootclasspath-locations = $(bootclasspath_locations_arg)" >> $@
Jiakai Zhanga5551c52023-06-09 17:44:50 +0100104 echo "boot-image = $(boot_image_arg)" >> $@
Jiakai Zhang96b155c2023-06-19 20:16:21 +0100105 echo "extra-args = $(dex2oat_extra_args)" >> $@
Jiakai Zhanga5551c52023-06-09 17:44:50 +0100106
107$(call dist-for-goals, droidcore, $(boot_zip_metadata_txt))
108
Calin Juravle6bfdcda2019-04-16 13:05:42 -0700109$(boot_zip): PRIVATE_BOOTCLASSPATH_JARS := $(bootclasspath_jars)
110$(boot_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars)
Jiakai Zhanga5551c52023-06-09 17:44:50 +0100111$(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)
Calin Juravle6bfdcda2019-04-16 13:05:42 -0700112 @echo "Create boot package: $@"
Calin Juravle8955a992018-05-10 11:33:27 -0700113 rm -f $@
Calin Juravle6bfdcda2019-04-16 13:05:42 -0700114 $(SOONG_ZIP) -o $@.tmp \
Colin Crossd8badf52019-02-20 12:39:57 -0800115 -C $(dir $(firstword $(PRIVATE_BOOTCLASSPATH_JARS)))/.. $(addprefix -f ,$(PRIVATE_BOOTCLASSPATH_JARS)) \
Jiakai Zhanga5551c52023-06-09 17:44:50 +0100116 -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) \
Jiakai Zhang34914f62023-06-12 11:18:12 +0100117 -j -f $(boot_zip_metadata_txt)
Jiakai Zhanga5551c52023-06-09 17:44:50 +0100118 $(MERGE_ZIPS) $@ $@.tmp $(DEXPREOPT_IMAGE_ZIP_boot) $(DEXPREOPT_IMAGE_ZIP_art) $(DEXPREOPT_IMAGE_ZIP_mainline)
Calin Juravle6bfdcda2019-04-16 13:05:42 -0700119 rm -f $@.tmp
Calin Juravle8955a992018-05-10 11:33:27 -0700120
Calin Juravle6bfdcda2019-04-16 13:05:42 -0700121$(call dist-for-goals, droidcore, $(boot_zip))
122
Pranav Gupta1da72192023-03-18 07:02:44 +0000123ifneq (,$(filter true,$(ART_MODULE_BUILD_FROM_SOURCE) $(MODULE_BUILD_FROM_SOURCE)))
Islam Elbannaab52f4b2022-11-04 15:51:07 +0000124# Build the system_server.zip which contains the Apex system server jars and standalone system server jars
125system_server_zip := $(PRODUCT_OUT)/system_server.zip
126apex_system_server_jars := \
127 $(foreach m,$(PRODUCT_APEX_SYSTEM_SERVER_JARS),\
128 $(PRODUCT_OUT)/apex/$(call word-colon,1,$(m))/javalib/$(call word-colon,2,$(m)).jar)
129
130apex_standalone_system_server_jars := \
131 $(foreach m,$(PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS),\
132 $(PRODUCT_OUT)/apex/$(call word-colon,1,$(m))/javalib/$(call word-colon,2,$(m)).jar)
133
134standalone_system_server_jars := \
135 $(foreach m,$(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS),\
136 $(PRODUCT_OUT)/apex/$(call word-colon,1,$(m))/javalib/$(call word-colon,2,$(m)).jar)
137
138$(system_server_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars)
139$(system_server_zip): PRIVATE_APEX_SYSTEM_SERVER_JARS := $(apex_system_server_jars)
140$(system_server_zip): PRIVATE_APEX_STANDALONE_SYSTEM_SERVER_JARS := $(apex_standalone_system_server_jars)
141$(system_server_zip): PRIVATE_STANDALONE_SYSTEM_SERVER_JARS := $(standalone_system_server_jars)
142$(system_server_zip): $(system_server_jars) $(apex_system_server_jars) $(apex_standalone_system_server_jars) $(standalone_system_server_jars) $(SOONG_ZIP)
143 @echo "Create system server package: $@"
144 rm -f $@
145 $(SOONG_ZIP) -o $@ \
146 -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) \
147 -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_APEX_SYSTEM_SERVER_JARS)) \
148 -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_APEX_STANDALONE_SYSTEM_SERVER_JARS)) \
149 -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_STANDALONE_SYSTEM_SERVER_JARS))
150
151$(call dist-for-goals, droidcore, $(system_server_zip))
152
Pranav Gupta1da72192023-03-18 07:02:44 +0000153endif #ART_MODULE_BUILD_FROM_SOURCE || MODULE_BUILD_FROM_SOURCE
Calin Juravlecdff6b12019-05-01 15:34:47 -0700154endif #PRODUCT_USES_DEFAULT_ART_CONFIG
Calin Juravle6bfdcda2019-04-16 13:05:42 -0700155endif #WITH_DEXPREOPT