blob: a2c9942a41a0d5916f8297afeb9e44692a24a7c6 [file] [log] [blame]
Brian Carlstromced4bff2013-11-14 23:44:56 -08001####################################
Nicolas Geoffray269bc742019-02-22 15:33:23 +00002# ART boot image installation
David Srbecky6dd11ec2020-02-11 13:46:45 +00003# Input variables:
Nicolas Geoffray269bc742019-02-22 15:33:23 +00004# my_boot_image_name: the boot image to install
David Srbecky6dd11ec2020-02-11 13:46:45 +00005# 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 Chiang3ca49802020-07-01 20:16:07 +08008#
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 Carlstromced4bff2013-11-14 23:44:56 -080017#
18####################################
19
Colin Crossc6f0d962022-03-15 17:46:37 -070020# 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
24define prefix-copy-many-files-dest
25$(foreach v,$(1),$(call word-colon,1,$(v)):$(2)$(call word-colon,2,$(v)))
David Srbecky6dd11ec2020-02-11 13:46:45 +000026endef
27
Colin Crossc6f0d962022-03-15 17:46:37 -070028# Converts an architecture-specific vdex path into a location that can be shared
29# between architectures.
30define vdex-shared-install-path
31$(dir $(patsubst %/,%,$(dir $(1))))$(notdir $(1))
32endef
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.
36define 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))))
38endef
39
40# Creates a rule to symlink an architecture specific vdex file to the shared
41# location for that vdex file.
42define symlink-vdex-file
43$(strip \
44 $(call symlink-file,\
45 $(call vdex-shared-install-path,$(1)),\
46 ../$(notdir $(1)),\
47 $(1))\
48 $(1))
49endef
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.
53define symlink-vdex-files
54$(foreach v,$(1),$(call symlink-vdex-file,$(call word-colon,2,$(v))))
David Srbecky6dd11ec2020-02-11 13:46:45 +000055endef
56
Yo Chiang3ca49802020-07-01 20:16:07 +080057my_boot_image_module :=
58
59my_suffix := $(my_boot_image_name)_$($(my_boot_image_arch))
Colin Crossc6f0d962022-03-15 17:46:37 -070060my_copy_pairs := $(call prefix-copy-many-files-dest,$(DEXPREOPT_IMAGE_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_out))
61my_vdex_copy_pairs := $(call prefix-copy-many-files-dest,$(DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_out))
62my_vdex_copy_shared_pairs := $(call vdex-copy-many-files-shared-dest,$(my_vdex_copy_pairs))
63ifeq (,$(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)
66endif
67
68my_unstripped_copy_pairs := $(call prefix-copy-many-files-dest,$(DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_syms))
Yo Chiang3ca49802020-07-01 20:16:07 +080069
70# Generate the boot image module only if there is any file to install.
Colin Crossc6f0d962022-03-15 17:46:37 -070071ifneq (,$(strip $(my_copy_pairs)))
Yo Chiang3ca49802020-07-01 20:16:07 +080072 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 Crossc6f0d962022-03-15 17:46:37 -070076 my_first_dest := $(call word-colon,2,$(my_first_pair))
Yo Chiang3ca49802020-07-01 20:16:07 +080077
Colin Crossc6f0d962022-03-15 17:46:37 -070078 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 Chiang3ca49802020-07-01 20:16:07 +080082
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 Crossc6f0d962022-03-15 17:46:37 -070085 # Hack to let these pseudo-modules wrapped around Soong modules use LOCAL_SOONG_INSTALLED_MODULE.
86 LOCAL_MODULE_MAKEFILE := $(SOONG_ANDROID_MK)
Yo Chiang3ca49802020-07-01 20:16:07 +080087
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 Crossc6f0d962022-03-15 17:46:37 -070093 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 Chiang3ca49802020-07-01 20:16:07 +080097 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 Crossdb980012021-04-27 19:43:33 -0700102 $(LOCAL_BUILT_MODULE): | $(my_unstripped_installed)
Yo Chiang3ca49802020-07-01 20:16:07 +0800103 # Installing boot.art causes all boot image bits to be installed.
104 # Keep this old behavior in case anyone still needs it.
Colin Crossc6f0d962022-03-15 17:46:37 -0700105 $(LOCAL_INSTALLED_MODULE): $(wordlist 2,$(words $(my_installed)),$(my_installed)) $(my_symlinks)
106 $(my_all_targets): $(my_installed) $(my_symlinks)
Yo Chiang3ca49802020-07-01 20:16:07 +0800107
108 my_boot_image_module := $(LOCAL_MODULE)
109endif # my_copy_pairs != empty