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)) |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 29 | else |
Ying Wang | 34d5f1b | 2014-05-16 10:38:43 -0700 | [diff] [blame] | 30 | ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix) |
| 31 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) |
| 32 | else |
| 33 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES) |
| 34 | endif |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 35 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 36 | endif |
| 37 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 38 | ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) |
| 39 | # Put the built targets of all shared libraries in a common directory |
| 40 | # to simplify the link line. |
| 41 | OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) |
| 42 | endif |
| 43 | |
| 44 | ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 45 | prebuilt_module_is_a_library := true |
| 46 | else |
| 47 | prebuilt_module_is_a_library := |
| 48 | endif |
| 49 | |
| 50 | # Don't install static libraries by default. |
| 51 | ifndef LOCAL_UNINSTALLABLE_MODULE |
| 52 | ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) |
| 53 | LOCAL_UNINSTALLABLE_MODULE := true |
| 54 | endif |
| 55 | endif |
| 56 | |
Ying Wang | af9757e | 2014-07-17 21:24:42 -0700 | [diff] [blame] | 57 | ifeq ($(LOCAL_MODULE_CLASS),APPS) |
| 58 | LOCAL_BUILT_MODULE_STEM := package.apk |
| 59 | LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk |
| 60 | endif |
| 61 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 62 | ifeq ($(LOCAL_STRIP_MODULE),true) |
| 63 | ifdef LOCAL_IS_HOST_MODULE |
| 64 | $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH)) |
| 65 | endif |
| 66 | ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),) |
| 67 | $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH)) |
| 68 | endif |
| 69 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 70 | $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH)) |
| 71 | endif |
| 72 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 73 | built_module := $(linked_module) |
| 74 | else # LOCAL_STRIP_MODULE not true |
| 75 | include $(BUILD_SYSTEM)/base_rules.mk |
| 76 | built_module := $(LOCAL_BUILT_MODULE) |
| 77 | |
| 78 | ifdef prebuilt_module_is_a_library |
| 79 | export_includes := $(intermediates)/export_includes |
| 80 | $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
| 81 | $(export_includes) : $(LOCAL_MODULE_MAKEFILE) |
| 82 | @echo Export includes file: $< -- $@ |
| 83 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 84 | ifdef LOCAL_EXPORT_C_INCLUDE_DIRS |
| 85 | $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ |
| 86 | echo "-I $$d" >> $@; \ |
| 87 | done |
| 88 | else |
| 89 | $(hide) touch $@ |
| 90 | endif |
| 91 | |
| 92 | $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes |
| 93 | endif # prebuilt_module_is_a_library |
| 94 | |
| 95 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 96 | # of the shared libraries are determined. |
| 97 | ifdef LOCAL_INSTALLED_MODULE |
| 98 | ifdef LOCAL_SHARED_LIBRARIES |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 99 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
Ying Wang | e1b867d | 2014-06-10 14:21:20 -0700 | [diff] [blame] | 100 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 101 | |
| 102 | # We also need the LOCAL_BUILT_MODULE dependency, |
| 103 | # since we use -rpath-link which points to the built module's path. |
| 104 | built_shared_libraries := \ |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 105 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 106 | $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ |
| 107 | $(LOCAL_SHARED_LIBRARIES))) |
| 108 | $(LOCAL_BUILT_MODULE) : $(built_shared_libraries) |
| 109 | endif |
| 110 | endif |
| 111 | |
| 112 | endif # LOCAL_STRIP_MODULE not true |
| 113 | |
Ying Wang | f0534c2 | 2014-04-15 11:12:21 -0700 | [diff] [blame] | 114 | ifeq ($(LOCAL_MODULE_CLASS),APPS) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 115 | PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 116 | |
Ying Wang | 96bcad4 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 117 | rs_compatibility_jni_libs := |
| 118 | include $(BUILD_SYSTEM)/install_jni_libs.mk |
| 119 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 120 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 121 | # The magic string "EXTERNAL" means this package will be signed with |
| 122 | # the default dev key throughout the build process, but we expect |
| 123 | # the final package to be signed with a different key. |
| 124 | # |
| 125 | # This can be used for packages where we don't have access to the |
| 126 | # keys, but want the package to be predexopt'ed. |
| 127 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 128 | PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1 |
| 129 | |
| 130 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 131 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 132 | endif |
| 133 | ifeq ($(LOCAL_CERTIFICATE),) |
Ying Wang | f0534c2 | 2014-04-15 11:12:21 -0700 | [diff] [blame] | 134 | # It is now a build error to add a prebuilt .apk without |
| 135 | # specifying a key for it. |
| 136 | $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)") |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 137 | else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 138 | # The magic string "PRESIGNED" means this package is already checked |
| 139 | # signed with its release key. |
| 140 | # |
| 141 | # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be |
| 142 | # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") |
| 143 | # but the dexpreopt process will not try to re-sign the app. |
| 144 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED |
| 145 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 146 | else |
| 147 | # If this is not an absolute certificate, assign it to a generic one. |
| 148 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 149 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 150 | endif |
| 151 | |
| 152 | PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 153 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 154 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 155 | |
| 156 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 157 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 158 | endif |
| 159 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 160 | # Disable dex-preopt of prebuilts to save space |
| 161 | LOCAL_DEX_PREOPT := false |
| 162 | |
| 163 | ####################################### |
| 164 | # defines built_odex along with rule to install odex |
| 165 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 166 | ####################################### |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 167 | # Sign and align non-presigned .apks. |
| 168 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) |
| 169 | $(transform-prebuilt-to-target) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 170 | ifdef extracted_jni_libs |
Ying Wang | 74eb660 | 2014-04-18 20:13:41 -0700 | [diff] [blame] | 171 | $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries. |
| 172 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 173 | ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 174 | $(sign-package) |
| 175 | endif |
| 176 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 177 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 178 | $(call dexpreopt-remove-classes.dex,$@) |
| 179 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 180 | endif |
| 181 | $(align-package) |
| 182 | |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 183 | ############################### |
| 184 | ## Rule to build the odex file |
| 185 | ifdef LOCAL_DEX_PREOPT |
| 186 | $(built_odex) : $(my_prebuilt_src_file) |
| 187 | $(call dexpreopt-one-file,$<,$@) |
| 188 | endif |
| 189 | |
Ying Wang | 00fe587 | 2014-07-23 14:35:40 -0700 | [diff] [blame^] | 190 | ############################### |
| 191 | ## Install split apks. |
| 192 | ifdef LOCAL_PACKAGE_SPLITS |
| 193 | # LOCAL_PACKAGE_SPLITS is a list of apks to be installed. |
| 194 | built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) |
| 195 | installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) |
| 196 | |
| 197 | # Rules to sign and zipalign the split apks. |
| 198 | my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS))) |
| 199 | ifneq (1,$(words $(my_src_dir))) |
| 200 | $(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS)) |
| 201 | endif |
| 202 | my_src_dir := $(LOCAL_PATH)/$(my_src_dir) |
| 203 | |
| 204 | $(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 205 | $(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 206 | $(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP) |
| 207 | $(copy-file-to-new-target) |
| 208 | $(sign-package) |
| 209 | $(align-package) |
| 210 | |
| 211 | # Rules to install the split apks. |
| 212 | $(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP) |
| 213 | @echo "Install: $@" |
| 214 | $(copy-file-to-new-target) |
| 215 | |
| 216 | # Register the additional built and installed files. |
| 217 | ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) |
| 218 | ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ |
| 219 | $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s))) |
| 220 | |
| 221 | # Make sure to install the splits when you run "make <module_name>". |
| 222 | $(my_register_name): $(installed_apk_splits) |
| 223 | |
| 224 | endif # LOCAL_PACKAGE_SPLITS |
| 225 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 226 | else # LOCAL_MODULE_CLASS != APPS |
| 227 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 228 | $(built_module) : $(my_prebuilt_src_file) |
| 229 | $(transform-prebuilt-to-target-strip-comments) |
| 230 | else |
| 231 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) |
| 232 | $(transform-prebuilt-to-target) |
| 233 | ifneq ($(prebuilt_module_is_a_library),) |
| 234 | ifneq ($(LOCAL_IS_HOST_MODULE),) |
| 235 | $(transform-host-ranlib-copy-hack) |
| 236 | else |
| 237 | $(transform-ranlib-copy-hack) |
| 238 | endif |
| 239 | endif |
| 240 | endif |
| 241 | endif # LOCAL_MODULE_CLASS != APPS |
| 242 | |
| 243 | ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 244 | # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, |
| 245 | # while the deps should be in the common dir, so we make a copy in the common dir. |
| 246 | # For nonstatic library, $(common_javalib_jar) is the dependency file, |
| 247 | # while $(common_classes_jar) is used to link. |
| 248 | common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar |
| 249 | common_javalib_jar := $(dir $(common_classes_jar))javalib.jar |
| 250 | |
| 251 | $(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP) |
| 252 | $(transform-prebuilt-to-target) |
| 253 | |
| 254 | $(common_javalib_jar) : $(common_classes_jar) | $(ACP) |
| 255 | $(transform-prebuilt-to-target) |
| 256 | |
| 257 | # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) |
| 258 | $(built_module) : $(common_javalib_jar) |
| 259 | endif # TARGET JAVA_LIBRARIES |
| 260 | |
| 261 | $(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 262 | |
| 263 | my_prebuilt_src_file := |