Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 1 | #################################### |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 2 | # dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time |
Ying Wang | e7874c4 | 2010-09-17 16:36:06 -0700 | [diff] [blame] | 3 | # |
| 4 | #################################### |
| 5 | |
Colin Cross | 6db5b0e | 2018-11-16 21:26:33 -0800 | [diff] [blame] | 6 | include $(BUILD_SYSTEM)/dex_preopt_config.mk |
Alex Light | 4e358ab | 2016-06-16 14:47:10 -0700 | [diff] [blame] | 7 | |
Nicolas Geoffray | cdd4343 | 2017-03-24 14:45:59 +0000 | [diff] [blame] | 8 | # Method returning whether the install path $(1) should be for system_other. |
Andreas Gampe | 4ed21d1 | 2017-06-16 10:24:54 -0700 | [diff] [blame] | 9 | # Under SANITIZE_LITE, we do not want system_other. Just put things under /data/asan. |
| 10 | ifeq ($(SANITIZE_LITE),true) |
| 11 | install-on-system-other = |
| 12 | else |
Nicolas Geoffray | 4a0ad4a | 2017-06-12 15:19:16 +0100 | [diff] [blame] | 13 | install-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 Gampe | 4ed21d1 | 2017-06-16 10:24:54 -0700 | [diff] [blame] | 14 | endif |
Nicolas Geoffray | cdd4343 | 2017-03-24 14:45:59 +0000 | [diff] [blame] | 15 | |
Nicolas Geoffray | 7e8ca9a | 2019-04-05 17:49:56 +0100 | [diff] [blame] | 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. |
| 18 | ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(DEXPREOPT_IMAGE_PROFILE_BUILT_INSTALLED),$(PRODUCT_OUT)) |
| 19 | |
Nicolas Geoffray | 269bc74 | 2019-02-22 15:33:23 +0000 | [diff] [blame] | 20 | # Install boot images. Note that there can be multiple. |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 21 | my_boot_image_arch := TARGET_ARCH |
| 22 | my_boot_image_out := $(PRODUCT_OUT) |
| 23 | my_boot_image_syms := $(TARGET_OUT_UNSTRIPPED) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 24 | DEFAULT_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 Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 28 | ifdef TARGET_2ND_ARCH |
| 29 | my_boot_image_arch := TARGET_2ND_ARCH |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 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))) |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 34 | endif |
| 35 | # Install boot images for testing on host. We exclude framework image as it is not part of art manifest. |
| 36 | my_boot_image_arch := HOST_ARCH |
| 37 | my_boot_image_out := $(HOST_OUT) |
| 38 | my_boot_image_syms := $(HOST_OUT)/symbols |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 39 | HOST_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))) |
| 43 | HOST_BOOT_IMAGE := $(call module-installed-files,$(HOST_BOOT_IMAGE_MODULE)) |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 44 | ifdef HOST_2ND_ARCH |
| 45 | my_boot_image_arch := HOST_2ND_ARCH |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 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)) |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 51 | endif |
| 52 | my_boot_image_arch := |
| 53 | my_boot_image_out := |
| 54 | my_boot_image_syms := |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 55 | my_boot_image_module := |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 56 | |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 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). |
Jiakai Zhang | 53dd895 | 2024-01-18 17:22:13 +0000 | [diff] [blame] | 60 | # At the time of writing, this is only for ART Cloud. |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 61 | ifeq ($(WITH_DEXPREOPT), true) |
Jiakai Zhang | 5b5ab17 | 2023-11-17 22:22:52 +0000 | [diff] [blame] | 62 | ifneq ($(WITH_DEXPREOPT_ART_BOOT_IMG_ONLY), true) |
Calin Juravle | cdff6b1 | 2019-05-01 15:34:47 -0700 | [diff] [blame] | 63 | ifeq ($(PRODUCT_USES_DEFAULT_ART_CONFIG), true) |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 64 | |
| 65 | boot_zip := $(PRODUCT_OUT)/boot.zip |
Colin Cross | d8badf5 | 2019-02-20 12:39:57 -0800 | [diff] [blame] | 66 | bootclasspath_jars := $(DEXPREOPT_BOOTCLASSPATH_DEX_FILES) |
Islam Elbanna | ab52f4b | 2022-11-04 15:51:07 +0000 | [diff] [blame] | 67 | |
| 68 | # TODO remove system_server_jars usages from boot.zip and depend directly on system_server.zip file. |
Nick Chameyev | 3bb4b5d | 2022-12-19 16:05:28 +0000 | [diff] [blame] | 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. |
| 73 | platform_system_server_jars = $(filter platform:%, $(PRODUCT_SYSTEM_SERVER_JARS)) |
satayev | 35a7a43 | 2021-05-04 16:14:02 +0100 | [diff] [blame] | 74 | system_server_jars := \ |
Nick Chameyev | 3bb4b5d | 2022-12-19 16:05:28 +0000 | [diff] [blame] | 75 | $(foreach m,$(platform_system_server_jars),\ |
satayev | 35a7a43 | 2021-05-04 16:14:02 +0100 | [diff] [blame] | 76 | $(PRODUCT_OUT)/system/framework/$(call word-colon,2,$(m)).jar) |
Calin Juravle | 8955a99 | 2018-05-10 11:33:27 -0700 | [diff] [blame] | 77 | |
Nick Chameyev | 3bb4b5d | 2022-12-19 16:05:28 +0000 | [diff] [blame] | 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. |
| 80 | other_system_server_jars = $(filter-out $(platform_system_server_jars), $(PRODUCT_SYSTEM_SERVER_JARS)) |
| 81 | system_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 | |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 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'. |
| 90 | DEXPREOPT_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. |
| 94 | dexpreopt_root_dir := $(dir $(patsubst %/,%,$(dir $(firstword $(bootclasspath_jars))))) |
Prashant Dubey | 029a615 | 2023-09-18 17:57:53 +0000 | [diff] [blame] | 95 | bootclasspath_arg := $(subst $(space),:,$(patsubst $(dexpreopt_root_dir)%,%,$(DEXPREOPT_BOOTCLASSPATH_DEX_FILES))) |
| 96 | bootclasspath_locations_arg := $(subst $(space),:,$(DEXPREOPT_BOOTCLASSPATH_DEX_LOCATIONS)) |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 97 | boot_images := $(subst :,$(space),$(DEXPREOPT_IMAGE_LOCATIONS_ON_DEVICE$(DEXPREOPT_INFIX))) |
| 98 | boot_image_arg := $(subst $(space),:,$(patsubst /%,%,$(boot_images))) |
Jiakai Zhang | 53dd895 | 2024-01-18 17:22:13 +0000 | [diff] [blame] | 99 | uffd_gc_flag_txt := $(OUT_DIR)/soong/dexpreopt/uffd_gc_flag.txt |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 100 | |
Jiakai Zhang | 34914f6 | 2023-06-12 11:18:12 +0100 | [diff] [blame] | 101 | boot_zip_metadata_txt := $(dir $(boot_zip))boot_zip/METADATA.txt |
Jiakai Zhang | 53dd895 | 2024-01-18 17:22:13 +0000 | [diff] [blame] | 102 | $(boot_zip_metadata_txt): $(uffd_gc_flag_txt) |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 103 | $(boot_zip_metadata_txt): |
| 104 | rm -f $@ |
Prashant Dubey | 029a615 | 2023-09-18 17:57:53 +0000 | [diff] [blame] | 105 | echo "bootclasspath = $(bootclasspath_arg)" >> $@ |
| 106 | echo "bootclasspath-locations = $(bootclasspath_locations_arg)" >> $@ |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 107 | echo "boot-image = $(boot_image_arg)" >> $@ |
Jiakai Zhang | 53dd895 | 2024-01-18 17:22:13 +0000 | [diff] [blame] | 108 | echo "extra-args = `cat $(uffd_gc_flag_txt)`" >> $@ |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 109 | |
| 110 | $(call dist-for-goals, droidcore, $(boot_zip_metadata_txt)) |
| 111 | |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 112 | $(boot_zip): PRIVATE_BOOTCLASSPATH_JARS := $(bootclasspath_jars) |
| 113 | $(boot_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars) |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 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) |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 115 | @echo "Create boot package: $@" |
Calin Juravle | 8955a99 | 2018-05-10 11:33:27 -0700 | [diff] [blame] | 116 | rm -f $@ |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 117 | $(SOONG_ZIP) -o $@.tmp \ |
Colin Cross | d8badf5 | 2019-02-20 12:39:57 -0800 | [diff] [blame] | 118 | -C $(dir $(firstword $(PRIVATE_BOOTCLASSPATH_JARS)))/.. $(addprefix -f ,$(PRIVATE_BOOTCLASSPATH_JARS)) \ |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 119 | -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) \ |
Jiakai Zhang | 34914f6 | 2023-06-12 11:18:12 +0100 | [diff] [blame] | 120 | -j -f $(boot_zip_metadata_txt) |
Jiakai Zhang | a5551c5 | 2023-06-09 17:44:50 +0100 | [diff] [blame] | 121 | $(MERGE_ZIPS) $@ $@.tmp $(DEXPREOPT_IMAGE_ZIP_boot) $(DEXPREOPT_IMAGE_ZIP_art) $(DEXPREOPT_IMAGE_ZIP_mainline) |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 122 | rm -f $@.tmp |
Calin Juravle | 8955a99 | 2018-05-10 11:33:27 -0700 | [diff] [blame] | 123 | |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 124 | $(call dist-for-goals, droidcore, $(boot_zip)) |
| 125 | |
Pranav Gupta | 1da7219 | 2023-03-18 07:02:44 +0000 | [diff] [blame] | 126 | ifneq (,$(filter true,$(ART_MODULE_BUILD_FROM_SOURCE) $(MODULE_BUILD_FROM_SOURCE))) |
Islam Elbanna | ab52f4b | 2022-11-04 15:51:07 +0000 | [diff] [blame] | 127 | # Build the system_server.zip which contains the Apex system server jars and standalone system server jars |
| 128 | system_server_zip := $(PRODUCT_OUT)/system_server.zip |
| 129 | apex_system_server_jars := \ |
| 130 | $(foreach m,$(PRODUCT_APEX_SYSTEM_SERVER_JARS),\ |
| 131 | $(PRODUCT_OUT)/apex/$(call word-colon,1,$(m))/javalib/$(call word-colon,2,$(m)).jar) |
| 132 | |
| 133 | apex_standalone_system_server_jars := \ |
| 134 | $(foreach m,$(PRODUCT_APEX_STANDALONE_SYSTEM_SERVER_JARS),\ |
| 135 | $(PRODUCT_OUT)/apex/$(call word-colon,1,$(m))/javalib/$(call word-colon,2,$(m)).jar) |
| 136 | |
| 137 | standalone_system_server_jars := \ |
| 138 | $(foreach m,$(PRODUCT_STANDALONE_SYSTEM_SERVER_JARS),\ |
| 139 | $(PRODUCT_OUT)/apex/$(call word-colon,1,$(m))/javalib/$(call word-colon,2,$(m)).jar) |
| 140 | |
| 141 | $(system_server_zip): PRIVATE_SYSTEM_SERVER_JARS := $(system_server_jars) |
| 142 | $(system_server_zip): PRIVATE_APEX_SYSTEM_SERVER_JARS := $(apex_system_server_jars) |
| 143 | $(system_server_zip): PRIVATE_APEX_STANDALONE_SYSTEM_SERVER_JARS := $(apex_standalone_system_server_jars) |
| 144 | $(system_server_zip): PRIVATE_STANDALONE_SYSTEM_SERVER_JARS := $(standalone_system_server_jars) |
| 145 | $(system_server_zip): $(system_server_jars) $(apex_system_server_jars) $(apex_standalone_system_server_jars) $(standalone_system_server_jars) $(SOONG_ZIP) |
| 146 | @echo "Create system server package: $@" |
| 147 | rm -f $@ |
| 148 | $(SOONG_ZIP) -o $@ \ |
| 149 | -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_SYSTEM_SERVER_JARS)) \ |
| 150 | -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_APEX_SYSTEM_SERVER_JARS)) \ |
| 151 | -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_APEX_STANDALONE_SYSTEM_SERVER_JARS)) \ |
| 152 | -C $(PRODUCT_OUT) $(addprefix -f ,$(PRIVATE_STANDALONE_SYSTEM_SERVER_JARS)) |
| 153 | |
| 154 | $(call dist-for-goals, droidcore, $(system_server_zip)) |
| 155 | |
Pranav Gupta | 1da7219 | 2023-03-18 07:02:44 +0000 | [diff] [blame] | 156 | endif #ART_MODULE_BUILD_FROM_SOURCE || MODULE_BUILD_FROM_SOURCE |
Calin Juravle | cdff6b1 | 2019-05-01 15:34:47 -0700 | [diff] [blame] | 157 | endif #PRODUCT_USES_DEFAULT_ART_CONFIG |
Jiakai Zhang | 5b5ab17 | 2023-11-17 22:22:52 +0000 | [diff] [blame] | 158 | endif #WITH_DEXPREOPT_ART_BOOT_IMG_ONLY |
Calin Juravle | 6bfdcda | 2019-04-16 13:05:42 -0700 | [diff] [blame] | 159 | endif #WITH_DEXPREOPT |