Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 1 | ########################################################### |
| 2 | ## Standard rules for copying files that are prebuilt |
| 3 | ## |
| 4 | ## Additional inputs from base_rules.make: |
| 5 | ## None. |
| 6 | ## |
| 7 | ########################################################### |
| 8 | |
| 9 | ifneq ($(LOCAL_PREBUILT_LIBS),) |
| 10 | $(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH)) |
| 11 | endif |
| 12 | ifneq ($(LOCAL_PREBUILT_EXECUTABLES),) |
| 13 | $(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH)) |
| 14 | endif |
| 15 | ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),) |
| 16 | $(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH)) |
| 17 | endif |
| 18 | |
| 19 | # Not much sense to check build prebuilts |
| 20 | LOCAL_DONT_CHECK_MODULE := true |
| 21 | |
Ying Wang | 34d5f1b | 2014-05-16 10:38:43 -0700 | [diff] [blame] | 22 | my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32) |
| 23 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 24 | ifdef LOCAL_PREBUILT_MODULE_FILE |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 25 | my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 26 | else |
Ying Wang | 6feb6d5 | 2014-04-17 10:03:35 -0700 | [diff] [blame] | 27 | ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
| 28 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) |
Dan Willemsen | 5709bd5 | 2016-02-01 21:40:17 -0800 | [diff] [blame] | 29 | LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 30 | else |
Ying Wang | 34d5f1b | 2014-05-16 10:38:43 -0700 | [diff] [blame] | 31 | ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix) |
| 32 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 33 | LOCAL_SRC_FILES_$(my_32_64_bit_suffix) := |
Ying Wang | 34d5f1b | 2014-05-16 10:38:43 -0700 | [diff] [blame] | 34 | else |
| 35 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES) |
Dan Willemsen | 3bb168f | 2016-01-19 20:07:08 -0800 | [diff] [blame] | 36 | LOCAL_SRC_FILES := |
Ying Wang | 34d5f1b | 2014-05-16 10:38:43 -0700 | [diff] [blame] | 37 | endif |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 38 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 39 | endif |
| 40 | |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 41 | my_strip_module := $(firstword \ |
| 42 | $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \ |
| 43 | $(LOCAL_STRIP_MODULE)) |
| 44 | my_pack_module_relocations := $(firstword \ |
| 45 | $(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \ |
| 46 | $(LOCAL_PACK_MODULE_RELOCATIONS)) |
| 47 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 48 | ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) |
| 49 | # Put the built targets of all shared libraries in a common directory |
| 50 | # to simplify the link line. |
| 51 | OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 52 | ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),) |
Ying Wang | bfb52a2 | 2014-08-20 17:12:32 -0700 | [diff] [blame] | 53 | # Strip but not try to add debuglink |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 54 | my_strip_module := no_debuglink |
Ying Wang | bfb52a2 | 2014-08-20 17:12:32 -0700 | [diff] [blame] | 55 | endif |
Dmitriy Ivanov | 64762c3 | 2015-04-24 15:33:14 -0700 | [diff] [blame] | 56 | |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 57 | ifeq ($(LOCAL_IS_HOST_MODULE)$(my_pack_module_relocations),) |
Dmitriy Ivanov | 64762c3 | 2015-04-24 15:33:14 -0700 | [diff] [blame] | 58 | # Do not pack relocations by default |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 59 | my_pack_module_relocations := false |
Dmitriy Ivanov | 64762c3 | 2015-04-24 15:33:14 -0700 | [diff] [blame] | 60 | endif |
Dan Albert | 52831d1 | 2015-11-12 15:27:49 -0800 | [diff] [blame] | 61 | |
| 62 | ifeq ($(DISABLE_RELOCATION_PACKER),true) |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 63 | my_pack_module_relocations := false |
Dan Albert | 52831d1 | 2015-11-12 15:27:49 -0800 | [diff] [blame] | 64 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 65 | endif |
| 66 | |
| 67 | ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 68 | prebuilt_module_is_a_library := true |
| 69 | else |
| 70 | prebuilt_module_is_a_library := |
| 71 | endif |
| 72 | |
| 73 | # Don't install static libraries by default. |
| 74 | ifndef LOCAL_UNINSTALLABLE_MODULE |
| 75 | ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) |
| 76 | LOCAL_UNINSTALLABLE_MODULE := true |
| 77 | endif |
| 78 | endif |
| 79 | |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 80 | ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE))) |
| 81 | prebuilt_module_is_dex_javalib := true |
| 82 | else |
| 83 | prebuilt_module_is_dex_javalib := |
| 84 | endif |
| 85 | |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 86 | ifeq ($(LOCAL_MODULE_CLASS),APPS) |
| 87 | LOCAL_BUILT_MODULE_STEM := package.apk |
Dan Willemsen | dc1ddfc | 2016-08-05 17:23:33 -0700 | [diff] [blame^] | 88 | ifndef LOCAL_INSTALLED_MODULE_STEM |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 89 | LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk |
| 90 | endif |
Dan Willemsen | dc1ddfc | 2016-08-05 17:23:33 -0700 | [diff] [blame^] | 91 | endif |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 92 | |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 93 | ifneq ($(filter true no_debuglink,$(my_strip_module) $(my_pack_module_relocations)),) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 94 | ifdef LOCAL_IS_HOST_MODULE |
Dmitriy Ivanov | 64762c3 | 2015-04-24 15:33:14 -0700 | [diff] [blame] | 95 | $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 96 | endif |
| 97 | ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),) |
Dmitriy Ivanov | 64762c3 | 2015-04-24 15:33:14 -0700 | [diff] [blame] | 98 | $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 99 | endif |
| 100 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
Dmitriy Ivanov | 64762c3 | 2015-04-24 15:33:14 -0700 | [diff] [blame] | 101 | $(error Cannot strip/pack scripts LOCAL_PATH=$(LOCAL_PATH)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 102 | endif |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 103 | # Set the arch-specific variables to set up the strip/pack rules. |
| 104 | LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module) |
| 105 | LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_pack_module_relocations) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 106 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 107 | built_module := $(linked_module) |
Ying Wang | bfb52a2 | 2014-08-20 17:12:32 -0700 | [diff] [blame] | 108 | |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 109 | else # my_strip_module and my_pack_module_relocations not true |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 110 | include $(BUILD_SYSTEM)/base_rules.mk |
| 111 | built_module := $(LOCAL_BUILT_MODULE) |
| 112 | |
| 113 | ifdef prebuilt_module_is_a_library |
| 114 | export_includes := $(intermediates)/export_includes |
| 115 | $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
Colin Cross | a4447e8 | 2015-09-28 16:26:00 -0700 | [diff] [blame] | 116 | $(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 117 | @echo Export includes file: $< -- $@ |
| 118 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 119 | ifdef LOCAL_EXPORT_C_INCLUDE_DIRS |
| 120 | $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ |
| 121 | echo "-I $$d" >> $@; \ |
| 122 | done |
| 123 | else |
| 124 | $(hide) touch $@ |
| 125 | endif |
| 126 | |
| 127 | $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes |
| 128 | endif # prebuilt_module_is_a_library |
| 129 | |
| 130 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 131 | # of the shared libraries are determined. |
| 132 | ifdef LOCAL_INSTALLED_MODULE |
| 133 | ifdef LOCAL_SHARED_LIBRARIES |
Ying Wang | 7c87739 | 2014-10-07 13:03:29 -0700 | [diff] [blame] | 134 | my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) |
| 135 | # Extra shared libraries introduced by LOCAL_CXX_STL. |
| 136 | include $(BUILD_SYSTEM)/cxx_stl_setup.mk |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 137 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
Ying Wang | 7c87739 | 2014-10-07 13:03:29 -0700 | [diff] [blame] | 138 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 139 | |
| 140 | # We also need the LOCAL_BUILT_MODULE dependency, |
| 141 | # since we use -rpath-link which points to the built module's path. |
Ying Wang | 7c87739 | 2014-10-07 13:03:29 -0700 | [diff] [blame] | 142 | my_built_shared_libraries := \ |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 143 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 144 | $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ |
Ying Wang | 7c87739 | 2014-10-07 13:03:29 -0700 | [diff] [blame] | 145 | $(my_shared_libraries))) |
| 146 | $(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 147 | endif |
| 148 | endif |
| 149 | |
Ying Wang | 7c87739 | 2014-10-07 13:03:29 -0700 | [diff] [blame] | 150 | # We need to enclose the above export_includes and my_built_shared_libraries in |
Ying Wang | b6eb8dd | 2016-03-01 20:14:52 -0800 | [diff] [blame] | 151 | # "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk. |
| 152 | endif # my_strip_module not true |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 153 | |
Ying Wang | f0534c2 | 2014-04-15 11:12:21 -0700 | [diff] [blame] | 154 | ifeq ($(LOCAL_MODULE_CLASS),APPS) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 155 | PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 156 | |
Dan Willemsen | 048f56d | 2016-06-18 20:43:51 -0700 | [diff] [blame] | 157 | my_extract_apk := $(strip $(LOCAL_EXTRACT_APK)) |
| 158 | |
Ying Wang | 43f7a32 | 2014-11-17 16:56:04 -0800 | [diff] [blame] | 159 | # Select dpi-specific source |
| 160 | ifdef LOCAL_DPI_VARIANTS |
Ying Wang | 6068658 | 2014-12-10 12:40:09 -0800 | [diff] [blame] | 161 | my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI))) |
Ying Wang | 43f7a32 | 2014-11-17 16:56:04 -0800 | [diff] [blame] | 162 | ifdef my_dpi |
| 163 | ifdef LOCAL_DPI_FILE_STEM |
| 164 | my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM) |
| 165 | else |
| 166 | my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk |
| 167 | endif |
| 168 | my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem)) |
Dan Willemsen | 048f56d | 2016-06-18 20:43:51 -0700 | [diff] [blame] | 169 | |
| 170 | ifneq ($(strip $(LOCAL_EXTRACT_DPI_APK)),) |
| 171 | my_extract_apk := $(subst %,$(my_dpi),$(LOCAL_EXTRACT_DPI_APK)) |
| 172 | endif # LOCAL_EXTRACT_DPI_APK |
Ying Wang | 43f7a32 | 2014-11-17 16:56:04 -0800 | [diff] [blame] | 173 | endif # my_dpi |
| 174 | endif # LOCAL_DPI_VARIANTS |
| 175 | |
Dan Willemsen | 048f56d | 2016-06-18 20:43:51 -0700 | [diff] [blame] | 176 | ifdef my_extract_apk |
| 177 | my_extracted_apk := $(intermediates)/extracted.apk |
| 178 | |
| 179 | $(my_extracted_apk): PRIVATE_EXTRACT := $(my_extract_apk) |
| 180 | $(my_extracted_apk): $(my_prebuilt_src_file) |
| 181 | @echo Extract APK: $@ |
| 182 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 183 | $(hide) unzip -p $< $(PRIVATE_EXTRACT) >$@ |
| 184 | |
| 185 | my_prebuilt_src_file := $(my_extracted_apk) |
| 186 | my_extracted_apk := |
| 187 | my_extract_apk := |
| 188 | endif |
| 189 | |
Ying Wang | 96bcad4 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 190 | rs_compatibility_jni_libs := |
| 191 | include $(BUILD_SYSTEM)/install_jni_libs.mk |
| 192 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 193 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 194 | # The magic string "EXTERNAL" means this package will be signed with |
| 195 | # the default dev key throughout the build process, but we expect |
| 196 | # the final package to be signed with a different key. |
| 197 | # |
| 198 | # This can be used for packages where we don't have access to the |
| 199 | # keys, but want the package to be predexopt'ed. |
| 200 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 201 | PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1 |
| 202 | |
| 203 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 204 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 205 | endif |
| 206 | ifeq ($(LOCAL_CERTIFICATE),) |
Ying Wang | f0534c2 | 2014-04-15 11:12:21 -0700 | [diff] [blame] | 207 | # It is now a build error to add a prebuilt .apk without |
| 208 | # specifying a key for it. |
| 209 | $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)") |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 210 | else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 211 | # The magic string "PRESIGNED" means this package is already checked |
| 212 | # signed with its release key. |
| 213 | # |
| 214 | # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be |
| 215 | # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") |
| 216 | # but the dexpreopt process will not try to re-sign the app. |
| 217 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED |
| 218 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 219 | else |
| 220 | # If this is not an absolute certificate, assign it to a generic one. |
| 221 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 222 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 223 | endif |
| 224 | |
| 225 | PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 226 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 227 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 228 | |
| 229 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 230 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 231 | endif |
| 232 | |
Andreas Gampe | 5e0dbe0 | 2014-10-01 22:01:16 -0700 | [diff] [blame] | 233 | # Disable dex-preopt of prebuilts to save space, if requested. |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 234 | ifndef LOCAL_DEX_PREOPT |
Andreas Gampe | 5e0dbe0 | 2014-10-01 22:01:16 -0700 | [diff] [blame] | 235 | ifeq ($(DONT_DEXPREOPT_PREBUILTS),true) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 236 | LOCAL_DEX_PREOPT := false |
Andreas Gampe | 5e0dbe0 | 2014-10-01 22:01:16 -0700 | [diff] [blame] | 237 | endif |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 238 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 239 | |
| 240 | ####################################### |
| 241 | # defines built_odex along with rule to install odex |
| 242 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 243 | ####################################### |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 244 | ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),) |
| 245 | # There is a replacement for the prebuilt .apk we can install without any processing. |
| 246 | $(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED) | $(ACP) |
| 247 | $(transform-prebuilt-to-target) |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 248 | |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 249 | else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED |
| 250 | # Sign and align non-presigned .apks. |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 251 | # The embedded prebuilt jni to uncompress. |
Ying Wang | 226eb92 | 2015-06-01 19:19:57 -0700 | [diff] [blame] | 252 | ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 253 | # For PRESIGNED apks we must uncompress every .so file: |
| 254 | # even if the .so file isn't for the current TARGET_ARCH, |
| 255 | # we can't strip the file. |
| 256 | embedded_prebuilt_jni_libs := 'lib/*.so' |
| 257 | endif |
Ying Wang | 1fb0152 | 2015-05-01 14:02:26 -0700 | [diff] [blame] | 258 | ifndef embedded_prebuilt_jni_libs |
| 259 | # No LOCAL_PREBUILT_JNI_LIBS, uncompress all. |
| 260 | embedded_prebuilt_jni_libs := 'lib/*.so' |
| 261 | endif |
| 262 | $(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs) |
| 263 | |
Alex Klyubin | b05b62d | 2016-01-13 10:32:47 -0800 | [diff] [blame] | 264 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) $(AAPT) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 265 | $(transform-prebuilt-to-target) |
Ying Wang | 226eb92 | 2015-06-01 19:19:57 -0700 | [diff] [blame] | 266 | $(uncompress-shared-libs) |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 267 | ifdef LOCAL_DEX_PREOPT |
| 268 | ifneq ($(BUILD_PLATFORM_ZIP),) |
| 269 | @# Keep a copy of apk with classes.dex unstripped |
| 270 | $(hide) cp -f $@ $(dir $@)package.dex.apk |
| 271 | endif # BUILD_PLATFORM_ZIP |
| 272 | endif # LOCAL_DEX_PREOPT |
Kenny Root | dff3755 | 2015-04-15 12:09:32 -0700 | [diff] [blame] | 273 | ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 274 | @# Only strip out files if we can re-sign the package. |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 275 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 276 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 277 | $(call dexpreopt-remove-classes.dex,$@) |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 278 | endif # LOCAL_DEX_PREOPT != nostripping |
| 279 | endif # LOCAL_DEX_PREOPT |
Kenny Root | dff3755 | 2015-04-15 12:09:32 -0700 | [diff] [blame] | 280 | $(sign-package) |
Alex Klyubin | 5b826ac | 2015-12-04 10:07:41 -0800 | [diff] [blame] | 281 | # No need for align-package because sign-package takes care of alignment |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 282 | else # LOCAL_CERTIFICATE == PRESIGNED |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 283 | $(align-package) |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 284 | endif # LOCAL_CERTIFICATE |
| 285 | endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 286 | |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 287 | ############################### |
| 288 | ## Rule to build the odex file |
| 289 | ifdef LOCAL_DEX_PREOPT |
| 290 | $(built_odex) : $(my_prebuilt_src_file) |
| 291 | $(call dexpreopt-one-file,$<,$@) |
| 292 | endif |
| 293 | |
Ying Wang | 00fe587 | 2014-07-23 14:35:40 -0700 | [diff] [blame] | 294 | ############################### |
| 295 | ## Install split apks. |
| 296 | ifdef LOCAL_PACKAGE_SPLITS |
| 297 | # LOCAL_PACKAGE_SPLITS is a list of apks to be installed. |
| 298 | built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) |
| 299 | installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) |
| 300 | |
Alex Klyubin | 5b826ac | 2015-12-04 10:07:41 -0800 | [diff] [blame] | 301 | # Rules to sign the split apks. |
Ying Wang | 00fe587 | 2014-07-23 14:35:40 -0700 | [diff] [blame] | 302 | my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS))) |
| 303 | ifneq (1,$(words $(my_src_dir))) |
| 304 | $(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS)) |
| 305 | endif |
| 306 | my_src_dir := $(LOCAL_PATH)/$(my_src_dir) |
| 307 | |
| 308 | $(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 309 | $(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
Alex Klyubin | b05b62d | 2016-01-13 10:32:47 -0800 | [diff] [blame] | 310 | $(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP) $(AAPT) |
Ying Wang | 00fe587 | 2014-07-23 14:35:40 -0700 | [diff] [blame] | 311 | $(copy-file-to-new-target) |
| 312 | $(sign-package) |
Ying Wang | 00fe587 | 2014-07-23 14:35:40 -0700 | [diff] [blame] | 313 | |
| 314 | # Rules to install the split apks. |
| 315 | $(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP) |
| 316 | @echo "Install: $@" |
| 317 | $(copy-file-to-new-target) |
| 318 | |
| 319 | # Register the additional built and installed files. |
| 320 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) |
| 321 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ |
| 322 | $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s))) |
| 323 | |
| 324 | # Make sure to install the splits when you run "make <module_name>". |
| 325 | $(my_register_name): $(installed_apk_splits) |
| 326 | |
| 327 | endif # LOCAL_PACKAGE_SPLITS |
| 328 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 329 | else # LOCAL_MODULE_CLASS != APPS |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 330 | ifeq ($(prebuilt_module_is_dex_javalib),true) |
| 331 | # This is a target shared library, i.e. a jar with classes.dex. |
| 332 | ####################################### |
| 333 | # defines built_odex along with rule to install odex |
| 334 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 335 | ####################################### |
| 336 | ifdef LOCAL_DEX_PREOPT |
| 337 | ifneq ($(dexpreopt_boot_jar_module),) # boot jar |
| 338 | # boot jar's rules are defined in dex_preopt.mk |
| 339 | dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar |
| 340 | $(built_module) : $(dexpreopted_boot_jar) | $(ACP) |
| 341 | $(call copy-file-to-target) |
| 342 | |
| 343 | # For libart boot jars, we don't have .odex files. |
| 344 | else # ! boot jar |
| 345 | $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 346 | # Use pattern rule - we may have multiple built odex files. |
| 347 | $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file) |
| 348 | @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" |
| 349 | $(call dexpreopt-one-file,$<,$@) |
| 350 | |
| 351 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) |
| 352 | $(call copy-file-to-target) |
| 353 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 354 | $(call dexpreopt-remove-classes.dex,$@) |
| 355 | endif |
| 356 | endif # boot jar |
| 357 | else # ! LOCAL_DEX_PREOPT |
| 358 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) |
| 359 | $(call copy-file-to-target) |
| 360 | endif # LOCAL_DEX_PREOPT |
| 361 | |
| 362 | else # ! prebuilt_module_is_dex_javalib |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 363 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 364 | $(built_module) : $(my_prebuilt_src_file) |
| 365 | $(transform-prebuilt-to-target-strip-comments) |
Dan Willemsen | 23f326a | 2016-03-01 22:04:57 -0800 | [diff] [blame] | 366 | ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) |
| 367 | $(hide) chmod +x $@ |
| 368 | endif |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 369 | else ifneq ($(LOCAL_ACP_UNAVAILABLE),true) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 370 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) |
| 371 | $(transform-prebuilt-to-target) |
Dan Willemsen | 23f326a | 2016-03-01 22:04:57 -0800 | [diff] [blame] | 372 | ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) |
| 373 | $(hide) chmod +x $@ |
| 374 | endif |
Colin Cross | d6f3892 | 2015-11-16 17:43:11 -0800 | [diff] [blame] | 375 | else |
| 376 | $(built_module) : $(my_prebuilt_src_file) |
| 377 | $(copy-file-to-target-with-cp) |
Dan Willemsen | 23f326a | 2016-03-01 22:04:57 -0800 | [diff] [blame] | 378 | ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) |
| 379 | $(hide) chmod +x $@ |
| 380 | endif |
Colin Cross | d6f3892 | 2015-11-16 17:43:11 -0800 | [diff] [blame] | 381 | endif |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 382 | endif # ! prebuilt_module_is_dex_javalib |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 383 | endif # LOCAL_MODULE_CLASS != APPS |
| 384 | |
Ying Wang | 8c89b4b | 2016-02-22 15:54:27 -0800 | [diff] [blame] | 385 | ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 386 | my_src_jar := $(my_prebuilt_src_file) |
| 387 | ifeq ($(LOCAL_IS_HOST_MODULE),) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 388 | # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, |
| 389 | # while the deps should be in the common dir, so we make a copy in the common dir. |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 390 | common_classes_jar := $(intermediates.COMMON)/classes.jar |
| 391 | common_javalib_jar := $(intermediates.COMMON)/javalib.jar |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 392 | |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 393 | $(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE) |
| 394 | |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 395 | ifeq ($(prebuilt_module_is_dex_javalib),true) |
| 396 | # For prebuilt shared Java library we don't have classes.jar. |
| 397 | $(common_javalib_jar) : $(my_src_jar) | $(ACP) |
| 398 | $(transform-prebuilt-to-target) |
| 399 | |
| 400 | else # ! prebuilt_module_is_dex_javalib |
| 401 | |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 402 | my_src_aar := $(filter %.aar, $(my_prebuilt_src_file)) |
| 403 | ifneq ($(my_src_aar),) |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 404 | # This is .aar file, archive of classes.jar and Android resources. |
| 405 | my_src_jar := $(intermediates.COMMON)/aar/classes.jar |
| 406 | |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 407 | $(my_src_jar) : $(my_src_aar) |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 408 | $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) |
| 409 | $(hide) unzip -qo -d $(dir $@) $< |
| 410 | # Make sure the extracted classes.jar has a new timestamp. |
| 411 | $(hide) touch $@ |
| 412 | |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 413 | endif |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 414 | |
Ying Wang | e9dd9f2 | 2014-10-29 15:48:32 -0700 | [diff] [blame] | 415 | $(common_classes_jar) : $(my_src_jar) | $(ACP) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 416 | $(transform-prebuilt-to-target) |
| 417 | |
| 418 | $(common_javalib_jar) : $(common_classes_jar) | $(ACP) |
| 419 | $(transform-prebuilt-to-target) |
| 420 | |
Shinichiro Hamaji | 89b255a | 2015-11-09 16:47:42 +0900 | [diff] [blame] | 421 | $(call define-jar-to-toc-rule, $(common_classes_jar)) |
| 422 | |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 423 | ifdef LOCAL_USE_AAPT2 |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 424 | ifneq ($(my_src_aar),) |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 425 | my_res_package := $(intermediates.COMMON)/package-res.apk |
| 426 | |
| 427 | # We needed only very few PRIVATE variables and aapt2.mk input variables. Reset the unnecessary ones. |
| 428 | $(my_res_package): PRIVATE_AAPT2_CFLAGS := |
| 429 | $(my_res_package): PRIVATE_ANDROID_MANIFEST := $(intermediates.COMMON)/aar/AndroidManifest.xml |
| 430 | $(my_res_package): PRIVATE_AAPT_INCLUDES := |
| 431 | $(my_res_package): PRIVATE_SOURCE_INTERMEDIATES_DIR := |
| 432 | $(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := |
| 433 | $(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK := |
| 434 | $(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK := |
Adam Lesinski | e758f93 | 2016-02-26 11:13:43 -0800 | [diff] [blame] | 435 | $(my_res_package): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 436 | $(my_res_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 437 | $(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS := |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 438 | |
| 439 | full_android_manifest := |
| 440 | my_res_resources := |
| 441 | my_overlay_resources := |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 442 | my_compiled_res_base_dir := |
| 443 | R_file_stamp := |
| 444 | proguard_options_file := |
| 445 | my_generated_res_dirs := $(intermediates.COMMON)/aar/res |
| 446 | my_generated_res_dirs_deps := $(my_src_jar) |
| 447 | include $(BUILD_SYSTEM)/aapt2.mk |
| 448 | |
| 449 | # Make sure my_res_package is created when you run mm/mmm. |
| 450 | $(built_module) : $(my_res_package) |
Ying Wang | dd71c85 | 2015-12-04 13:59:18 -0800 | [diff] [blame] | 451 | endif # $(my_src_aar) |
Ying Wang | e295c3d | 2016-02-24 14:11:55 -0800 | [diff] [blame] | 452 | endif # LOCAL_USE_AAPT2 |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 453 | # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) |
| 454 | $(built_module) : $(common_javalib_jar) |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 455 | |
| 456 | endif # ! prebuilt_module_is_dex_javalib |
Ying Wang | 8c89b4b | 2016-02-22 15:54:27 -0800 | [diff] [blame] | 457 | endif # LOCAL_IS_HOST_MODULE is not set |
Yohann Roussel | d87cc99 | 2016-01-19 16:08:34 +0100 | [diff] [blame] | 458 | |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 459 | ifneq ($(prebuilt_module_is_dex_javalib),true) |
Yohann Roussel | d87cc99 | 2016-01-19 16:08:34 +0100 | [diff] [blame] | 460 | ifneq ($(LOCAL_JILL_FLAGS),) |
| 461 | $(error LOCAL_JILL_FLAGS is not supported any more, please use jack options in LOCAL_JACK_FLAGS instead) |
| 462 | endif |
| 463 | |
Ying Wang | 8c89b4b | 2016-02-22 15:54:27 -0800 | [diff] [blame] | 464 | # We may be building classes.jack from a host jar for host dalvik Java library. |
Yohann Roussel | d87cc99 | 2016-01-19 16:08:34 +0100 | [diff] [blame] | 465 | $(intermediates.COMMON)/classes.jack : PRIVATE_JACK_FLAGS:=$(LOCAL_JACK_FLAGS) |
Yohann Roussel | 740ec8f | 2016-03-09 17:19:58 +0100 | [diff] [blame] | 466 | $(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := 1 |
Colin Cross | 7ee3b85 | 2015-09-28 18:45:23 -0700 | [diff] [blame] | 467 | $(intermediates.COMMON)/classes.jack : $(my_src_jar) $(LOCAL_MODULE_MAKEFILE_DEP) \ |
Yohann Roussel | d87cc99 | 2016-01-19 16:08:34 +0100 | [diff] [blame] | 468 | $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK) | setup-jack-server |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 469 | $(transform-jar-to-jack) |
| 470 | |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 471 | # Update timestamps of .toc files for prebuilts so dependents will be |
| 472 | # always rebuilt. |
| 473 | $(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack |
| 474 | touch $@ |
| 475 | |
Ying Wang | 3a61eeb | 2016-03-11 10:32:01 -0800 | [diff] [blame] | 476 | endif # ! prebuilt_module_is_dex_javalib |
Yohann Roussel | b4c49cb | 2014-09-08 14:45:14 +0200 | [diff] [blame] | 477 | endif # JAVA_LIBRARIES |
| 478 | |
Colin Cross | a4447e8 | 2015-09-28 16:26:00 -0700 | [diff] [blame] | 479 | $(built_module) : $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 480 | |
| 481 | my_prebuilt_src_file := |