Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 1 | #################################### |
Nicolas Geoffray | 269bc74 | 2019-02-22 15:33:23 +0000 | [diff] [blame] | 2 | # ART boot image installation |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 3 | # Input variables: |
Nicolas Geoffray | 269bc74 | 2019-02-22 15:33:23 +0000 | [diff] [blame] | 4 | # my_boot_image_name: the boot image to install |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 5 | # my_boot_image_arch: the architecture to install (e.g. TARGET_ARCH, not expanded) |
| 6 | # my_boot_image_out: the install directory (e.g. $(PRODUCT_OUT)) |
| 7 | # my_boot_image_syms: the symbols director (e.g. $(TARGET_OUT_UNSTRIPPED)) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 8 | # |
| 9 | # Output variables: |
| 10 | # my_boot_image_module: the created module name. Empty if no module is created. |
| 11 | # |
| 12 | # Install the boot images compiled by Soong. |
| 13 | # Create a module named dexpreopt_bootjar.$(my_boot_image_name)_$($(my_boot_image_arch)) |
| 14 | # that installs all of boot image files. |
| 15 | # If there is no file to install for $(my_boot_image_name), for example when |
| 16 | # building an unbundled build, then no module is created. |
Brian Carlstrom | ced4bff | 2013-11-14 23:44:56 -0800 | [diff] [blame] | 17 | # |
| 18 | #################################### |
| 19 | |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 20 | # Takes a list of src:dest install pairs and returns a new list with a path |
| 21 | # prefixed to each dest value. |
| 22 | # $(1): list of src:dest install pairs |
| 23 | # $(2): path to prefix to each dest value |
| 24 | define prefix-copy-many-files-dest |
| 25 | $(foreach v,$(1),$(call word-colon,1,$(v)):$(2)$(call word-colon,2,$(v))) |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 26 | endef |
| 27 | |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 28 | # Converts an architecture-specific vdex path into a location that can be shared |
| 29 | # between architectures. |
| 30 | define vdex-shared-install-path |
| 31 | $(dir $(patsubst %/,%,$(dir $(1))))$(notdir $(1)) |
| 32 | endef |
| 33 | |
| 34 | # Takes a list of src:dest install pairs of vdex files and returns a new list |
| 35 | # where each dest has been rewritten to the shared location for vdex files. |
| 36 | define vdex-copy-many-files-shared-dest |
| 37 | $(foreach v,$(1),$(call word-colon,1,$(v)):$(call vdex-shared-install-path,$(call word-colon,2,$(v)))) |
| 38 | endef |
| 39 | |
| 40 | # Creates a rule to symlink an architecture specific vdex file to the shared |
| 41 | # location for that vdex file. |
| 42 | define symlink-vdex-file |
| 43 | $(strip \ |
| 44 | $(call symlink-file,\ |
| 45 | $(call vdex-shared-install-path,$(1)),\ |
| 46 | ../$(notdir $(1)),\ |
| 47 | $(1))\ |
| 48 | $(1)) |
| 49 | endef |
| 50 | |
| 51 | # Takes a list of src:dest install pairs of vdex files and creates rules to |
| 52 | # symlink each dest to the shared location for that vdex file. |
| 53 | define symlink-vdex-files |
| 54 | $(foreach v,$(1),$(call symlink-vdex-file,$(call word-colon,2,$(v)))) |
David Srbecky | 6dd11ec | 2020-02-11 13:46:45 +0000 | [diff] [blame] | 55 | endef |
| 56 | |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 57 | my_boot_image_module := |
| 58 | |
| 59 | my_suffix := $(my_boot_image_name)_$($(my_boot_image_arch)) |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 60 | my_copy_pairs := $(call prefix-copy-many-files-dest,$(DEXPREOPT_IMAGE_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_out)) |
| 61 | my_vdex_copy_pairs := $(call prefix-copy-many-files-dest,$(DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_out)) |
| 62 | my_vdex_copy_shared_pairs := $(call vdex-copy-many-files-shared-dest,$(my_vdex_copy_pairs)) |
| 63 | ifeq (,$(filter %_2ND_ARCH,$(my_boot_image_arch))) |
| 64 | # Only install the vdex to the shared location for the primary architecture. |
| 65 | my_copy_pairs += $(my_vdex_copy_shared_pairs) |
| 66 | endif |
| 67 | |
| 68 | my_unstripped_copy_pairs := $(call prefix-copy-many-files-dest,$(DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_syms)) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 69 | |
| 70 | # Generate the boot image module only if there is any file to install. |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 71 | ifneq (,$(strip $(my_copy_pairs))) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 72 | my_first_pair := $(firstword $(my_copy_pairs)) |
| 73 | my_rest_pairs := $(wordlist 2,$(words $(my_copy_pairs)),$(my_copy_pairs)) |
| 74 | |
| 75 | my_first_src := $(call word-colon,1,$(my_first_pair)) |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 76 | my_first_dest := $(call word-colon,2,$(my_first_pair)) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 77 | |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 78 | my_installed := $(call copy-many-files,$(my_copy_pairs)) |
| 79 | my_unstripped_installed := $(call copy-many-files,$(my_unstripped_copy_pairs)) |
| 80 | |
| 81 | my_symlinks := $(call symlink-vdex-files,$(my_vdex_copy_pairs)) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 82 | |
| 83 | # We don't have a LOCAL_PATH for the auto-generated modules, so let it be the $(BUILD_SYSTEM). |
| 84 | LOCAL_PATH := $(BUILD_SYSTEM) |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 85 | # Hack to let these pseudo-modules wrapped around Soong modules use LOCAL_SOONG_INSTALLED_MODULE. |
| 86 | LOCAL_MODULE_MAKEFILE := $(SOONG_ANDROID_MK) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 87 | |
| 88 | include $(CLEAR_VARS) |
| 89 | LOCAL_MODULE := dexpreopt_bootjar.$(my_suffix) |
| 90 | LOCAL_PREBUILT_MODULE_FILE := $(my_first_src) |
| 91 | LOCAL_MODULE_PATH := $(dir $(my_first_dest)) |
| 92 | LOCAL_MODULE_STEM := $(notdir $(my_first_dest)) |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 93 | LOCAL_SOONG_INSTALL_PAIRS := $(my_copy_pairs) |
| 94 | LOCAL_SOONG_INSTALL_SYMLINKS := $(my_symlinks) |
| 95 | LOCAL_SOONG_INSTALLED_MODULE := $(my_first_dest) |
| 96 | LOCAL_SOONG_LICENSE_METADATA := $(DEXPREOPT_IMAGE_LICENSE_METADATA_$(my_suffix)) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 97 | ifneq (,$(strip $(filter HOST_%,$(my_boot_image_arch)))) |
| 98 | LOCAL_IS_HOST_MODULE := true |
| 99 | endif |
| 100 | LOCAL_MODULE_CLASS := ETC |
| 101 | include $(BUILD_PREBUILT) |
Colin Cross | db98001 | 2021-04-27 19:43:33 -0700 | [diff] [blame] | 102 | $(LOCAL_BUILT_MODULE): | $(my_unstripped_installed) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 103 | # Installing boot.art causes all boot image bits to be installed. |
| 104 | # Keep this old behavior in case anyone still needs it. |
Colin Cross | c6f0d96 | 2022-03-15 17:46:37 -0700 | [diff] [blame] | 105 | $(LOCAL_INSTALLED_MODULE): $(wordlist 2,$(words $(my_installed)),$(my_installed)) $(my_symlinks) |
| 106 | $(my_all_targets): $(my_installed) $(my_symlinks) |
Yo Chiang | 3ca4980 | 2020-07-01 20:16:07 +0800 | [diff] [blame] | 107 | |
| 108 | my_boot_image_module := $(LOCAL_MODULE) |
| 109 | endif # my_copy_pairs != empty |