prebuilt_internal.mk revision 4972d195ddb886460cd3a8de6c101f7a0ccd1096
1########################################################### 2## Standard rules for copying files that are prebuilt 3## 4## Additional inputs from base_rules.make: 5## None. 6## 7########################################################### 8 9ifneq ($(LOCAL_PREBUILT_LIBS),) 10$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH)) 11endif 12ifneq ($(LOCAL_PREBUILT_EXECUTABLES),) 13$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH)) 14endif 15ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),) 16$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH)) 17endif 18 19# Not much sense to check build prebuilts 20LOCAL_DONT_CHECK_MODULE := true 21 22my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32) 23 24ifdef LOCAL_PREBUILT_MODULE_FILE 25 my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE) 26else 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)) 29 else 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 35 endif 36endif 37 38ifeq (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 ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_STRIP_MODULE),) 43 # Strip but not try to add debuglink 44 LOCAL_STRIP_MODULE := no_debuglink 45 endif 46endif 47 48ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 49 prebuilt_module_is_a_library := true 50else 51 prebuilt_module_is_a_library := 52endif 53 54# Don't install static libraries by default. 55ifndef LOCAL_UNINSTALLABLE_MODULE 56ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) 57 LOCAL_UNINSTALLABLE_MODULE := true 58endif 59endif 60 61ifeq ($(LOCAL_MODULE_CLASS),APPS) 62LOCAL_BUILT_MODULE_STEM := package.apk 63LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk 64endif 65 66ifneq ($(filter true no_debuglink,$(LOCAL_STRIP_MODULE)),) 67 ifdef LOCAL_IS_HOST_MODULE 68 $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH)) 69 endif 70 ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),) 71 $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH)) 72 endif 73 ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) 74 $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH)) 75 endif 76 include $(BUILD_SYSTEM)/dynamic_binary.mk 77 built_module := $(linked_module) 78 79else # LOCAL_STRIP_MODULE not true 80 include $(BUILD_SYSTEM)/base_rules.mk 81 built_module := $(LOCAL_BUILT_MODULE) 82 83ifdef prebuilt_module_is_a_library 84export_includes := $(intermediates)/export_includes 85$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) 86$(export_includes) : $(LOCAL_MODULE_MAKEFILE) 87 @echo Export includes file: $< -- $@ 88 $(hide) mkdir -p $(dir $@) && rm -f $@ 89ifdef LOCAL_EXPORT_C_INCLUDE_DIRS 90 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ 91 echo "-I $$d" >> $@; \ 92 done 93else 94 $(hide) touch $@ 95endif 96 97$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes 98endif # prebuilt_module_is_a_library 99 100# The real dependency will be added after all Android.mks are loaded and the install paths 101# of the shared libraries are determined. 102ifdef LOCAL_INSTALLED_MODULE 103ifdef LOCAL_SHARED_LIBRARIES 104my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) 105# Extra shared libraries introduced by LOCAL_CXX_STL. 106include $(BUILD_SYSTEM)/cxx_stl_setup.mk 107$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 108 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) 109 110# We also need the LOCAL_BUILT_MODULE dependency, 111# since we use -rpath-link which points to the built module's path. 112my_built_shared_libraries := \ 113 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 114 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ 115 $(my_shared_libraries))) 116$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries) 117endif 118endif 119 120# We need to enclose the above export_includes and my_built_shared_libraries in 121# "LOCAL_STRIP_MODULE not true" because otherwise the rules are defined in dynamic_binary.mk. 122endif # LOCAL_STRIP_MODULE not true 123 124ifeq ($(LOCAL_MODULE_CLASS),APPS) 125PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) 126 127# Select dpi-specific source 128ifdef LOCAL_DPI_VARIANTS 129my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI))) 130ifdef my_dpi 131ifdef LOCAL_DPI_FILE_STEM 132my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM) 133else 134my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk 135endif 136my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem)) 137endif # my_dpi 138endif # LOCAL_DPI_VARIANTS 139 140rs_compatibility_jni_libs := 141include $(BUILD_SYSTEM)/install_jni_libs.mk 142 143ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) 144 # The magic string "EXTERNAL" means this package will be signed with 145 # the default dev key throughout the build process, but we expect 146 # the final package to be signed with a different key. 147 # 148 # This can be used for packages where we don't have access to the 149 # keys, but want the package to be predexopt'ed. 150 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) 151 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1 152 153 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 154 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 155endif 156ifeq ($(LOCAL_CERTIFICATE),) 157 # It is now a build error to add a prebuilt .apk without 158 # specifying a key for it. 159 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)") 160else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) 161 # The magic string "PRESIGNED" means this package is already checked 162 # signed with its release key. 163 # 164 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be 165 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") 166 # but the dexpreopt process will not try to re-sign the app. 167 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED 168 PACKAGES := $(PACKAGES) $(LOCAL_MODULE) 169else 170 # If this is not an absolute certificate, assign it to a generic one. 171 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) 172 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) 173 endif 174 175 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 176 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 177 PACKAGES := $(PACKAGES) $(LOCAL_MODULE) 178 179 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 180 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 181endif 182 183# Disable dex-preopt of prebuilts to save space, if requested. 184ifeq ($(DONT_DEXPREOPT_PREBUILTS),true) 185LOCAL_DEX_PREOPT := false 186endif 187 188####################################### 189# defines built_odex along with rule to install odex 190include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk 191####################################### 192# Sign and align non-presigned .apks. 193$(built_module) : PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES := $(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES) 194$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) 195 $(transform-prebuilt-to-target) 196ifdef extracted_jni_libs 197 $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries. 198endif 199ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) 200 $(sign-package) 201endif 202ifdef LOCAL_DEX_PREOPT 203ifneq (nostripping,$(LOCAL_DEX_PREOPT)) 204 $(call dexpreopt-remove-classes.dex,$@) 205endif 206endif 207 $(align-package) 208 209############################### 210## Rule to build the odex file 211ifdef LOCAL_DEX_PREOPT 212$(built_odex) : $(my_prebuilt_src_file) 213 $(call dexpreopt-one-file,$<,$@) 214endif 215 216############################### 217## Install split apks. 218ifdef LOCAL_PACKAGE_SPLITS 219# LOCAL_PACKAGE_SPLITS is a list of apks to be installed. 220built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) 221installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) 222 223# Rules to sign and zipalign the split apks. 224my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS))) 225ifneq (1,$(words $(my_src_dir))) 226$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS)) 227endif 228my_src_dir := $(LOCAL_PATH)/$(my_src_dir) 229 230$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 231$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 232$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP) 233 $(copy-file-to-new-target) 234 $(sign-package) 235 $(align-package) 236 237# Rules to install the split apks. 238$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP) 239 @echo "Install: $@" 240 $(copy-file-to-new-target) 241 242# Register the additional built and installed files. 243ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) 244ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ 245 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s))) 246 247# Make sure to install the splits when you run "make <module_name>". 248$(my_register_name): $(installed_apk_splits) 249 250endif # LOCAL_PACKAGE_SPLITS 251 252else # LOCAL_MODULE_CLASS != APPS 253ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) 254$(built_module) : $(my_prebuilt_src_file) 255 $(transform-prebuilt-to-target-strip-comments) 256else 257$(built_module) : $(my_prebuilt_src_file) | $(ACP) 258 $(transform-prebuilt-to-target) 259endif 260endif # LOCAL_MODULE_CLASS != APPS 261 262ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 263# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, 264# while the deps should be in the common dir, so we make a copy in the common dir. 265# For nonstatic library, $(common_javalib_jar) is the dependency file, 266# while $(common_classes_jar) is used to link. 267common_classes_jar := $(intermediates.COMMON)/classes.jar 268common_javalib_jar := $(intermediates.COMMON)/javalib.jar 269 270$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE) 271 272ifneq ($(filter %.aar, $(my_prebuilt_src_file)),) 273# This is .aar file, archive of classes.jar and Android resources. 274my_src_jar := $(intermediates.COMMON)/aar/classes.jar 275 276$(my_src_jar) : $(my_prebuilt_src_file) 277 $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) 278 $(hide) unzip -qo -d $(dir $@) $< 279 # Make sure the extracted classes.jar has a new timestamp. 280 $(hide) touch $@ 281 282else 283# This is jar file. 284my_src_jar := $(my_prebuilt_src_file) 285endif 286$(common_classes_jar) : $(my_src_jar) | $(ACP) 287 $(transform-prebuilt-to-target) 288 289$(common_javalib_jar) : $(common_classes_jar) | $(ACP) 290 $(transform-prebuilt-to-target) 291 292# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) 293$(built_module) : $(common_javalib_jar) 294endif # TARGET JAVA_LIBRARIES 295 296ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 297$(intermediates.COMMON)/classes.jack : PRIVATE_JILL_FLAGS:=$(LOCAL_JILL_FLAGS) 298$(intermediates.COMMON)/classes.jack : $(my_prebuilt_src_file) $(LOCAL_MODULE_MAKEFILE) \ 299 $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JILL_JAR) $(JACK_JAR) 300 $(transform-jar-to-jack) 301 302endif # JAVA_LIBRARIES 303 304$(built_module) : $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) 305 306my_prebuilt_src_file := 307