blob: 8f0702ba6c748bbde4a7eae8809783a25db7ac8a [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
David Srbecky6dd11ec2020-02-11 13:46:45 +000020# Install $(1) to $(2) so that it is shared between architectures.
Yo Chiang3ca49802020-07-01 20:16:07 +080021# Returns the target path of the shared vdex file and installed symlink.
David Srbecky6dd11ec2020-02-11 13:46:45 +000022define copy-vdex-file
Yo Chiang3ca49802020-07-01 20:16:07 +080023$(strip \
24 $(eval # Remove the arch dir) \
25 $(eval my_vdex_shared := $(dir $(patsubst %/,%,$(dir $(2))))$(notdir $(2))) \
26 $(if $(filter-out %_2ND_ARCH,$(my_boot_image_arch)), \
27 $(eval # Copy $(1) to directory one level up (i.e. with the arch dir removed).) \
28 $(eval $(call copy-one-file,$(1),$(my_vdex_shared))) \
29 ) \
30 $(eval # Create symlink at $(2) which points to the actual physical copy.) \
31 $(call symlink-file,$(my_vdex_shared),../$(notdir $(2)),$(2)) \
32 $(my_vdex_shared) $(2) \
33)
David Srbecky6dd11ec2020-02-11 13:46:45 +000034endef
35
36# Same as 'copy-many-files' but it uses the vdex-specific helper above.
37define copy-vdex-files
Yo Chiang3ca49802020-07-01 20:16:07 +080038$(foreach v,$(1),$(call copy-vdex-file,$(call word-colon,1,$(v)),$(2)$(call word-colon,2,$(v))))
David Srbecky6dd11ec2020-02-11 13:46:45 +000039endef
40
Yo Chiang3ca49802020-07-01 20:16:07 +080041my_boot_image_module :=
42
43my_suffix := $(my_boot_image_name)_$($(my_boot_image_arch))
44my_copy_pairs := $(strip $(DEXPREOPT_IMAGE_BUILT_INSTALLED_$(my_suffix)))
45
46# Generate the boot image module only if there is any file to install.
47ifneq (,$(my_copy_pairs))
48 my_first_pair := $(firstword $(my_copy_pairs))
49 my_rest_pairs := $(wordlist 2,$(words $(my_copy_pairs)),$(my_copy_pairs))
50
51 my_first_src := $(call word-colon,1,$(my_first_pair))
52 my_first_dest := $(my_boot_image_out)$(call word-colon,2,$(my_first_pair))
53
54 my_installed := $(call copy-many-files,$(my_rest_pairs),$(my_boot_image_out))
55 my_installed += $(call copy-vdex-files,$(DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_out))
56 my_unstripped_installed := $(call copy-many-files,$(DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_$(my_suffix)),$(my_boot_image_syms))
57
58 # We don't have a LOCAL_PATH for the auto-generated modules, so let it be the $(BUILD_SYSTEM).
59 LOCAL_PATH := $(BUILD_SYSTEM)
60
61 include $(CLEAR_VARS)
62 LOCAL_MODULE := dexpreopt_bootjar.$(my_suffix)
63 LOCAL_PREBUILT_MODULE_FILE := $(my_first_src)
64 LOCAL_MODULE_PATH := $(dir $(my_first_dest))
65 LOCAL_MODULE_STEM := $(notdir $(my_first_dest))
66 ifneq (,$(strip $(filter HOST_%,$(my_boot_image_arch))))
67 LOCAL_IS_HOST_MODULE := true
68 endif
69 LOCAL_MODULE_CLASS := ETC
70 include $(BUILD_PREBUILT)
71 $(LOCAL_BUILT_MODULE): $(my_unstripped_installed)
72 # Installing boot.art causes all boot image bits to be installed.
73 # Keep this old behavior in case anyone still needs it.
74 $(LOCAL_INSTALLED_MODULE): $(my_installed)
75 ALL_MODULES.$(my_register_name).INSTALLED += $(my_installed)
76 $(my_all_targets): $(my_installed)
77
78 my_boot_image_module := $(LOCAL_MODULE)
79endif # my_copy_pairs != empty