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