prebuilt_internal.mk revision 954b5bdcf4c3621c10666a09bbfc3fe1cf785950
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) 42endif 43 44ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) 45 prebuilt_module_is_a_library := true 46else 47 prebuilt_module_is_a_library := 48endif 49 50# Don't install static libraries by default. 51ifndef LOCAL_UNINSTALLABLE_MODULE 52ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) 53 LOCAL_UNINSTALLABLE_MODULE := true 54endif 55endif 56 57ifeq ($(LOCAL_MODULE_CLASS),APPS) 58LOCAL_BUILT_MODULE_STEM := package.apk 59LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk 60endif 61 62ifeq ($(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) 74else # LOCAL_STRIP_MODULE not true 75 include $(BUILD_SYSTEM)/base_rules.mk 76 built_module := $(LOCAL_BUILT_MODULE) 77 78ifdef prebuilt_module_is_a_library 79export_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 $@ 84ifdef LOCAL_EXPORT_C_INCLUDE_DIRS 85 $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ 86 echo "-I $$d" >> $@; \ 87 done 88else 89 $(hide) touch $@ 90endif 91 92$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes 93endif # 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. 97ifdef LOCAL_INSTALLED_MODULE 98ifdef LOCAL_SHARED_LIBRARIES 99my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) 100# Extra shared libraries introduced by LOCAL_CXX_STL. 101include $(BUILD_SYSTEM)/cxx_stl_setup.mk 102$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ 103 $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) 104 105# We also need the LOCAL_BUILT_MODULE dependency, 106# since we use -rpath-link which points to the built module's path. 107my_built_shared_libraries := \ 108 $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ 109 $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ 110 $(my_shared_libraries))) 111$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries) 112endif 113endif 114 115endif # LOCAL_STRIP_MODULE not true 116 117ifeq ($(LOCAL_MODULE_CLASS),APPS) 118PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) 119 120rs_compatibility_jni_libs := 121include $(BUILD_SYSTEM)/install_jni_libs.mk 122 123ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) 124 # The magic string "EXTERNAL" means this package will be signed with 125 # the default dev key throughout the build process, but we expect 126 # the final package to be signed with a different key. 127 # 128 # This can be used for packages where we don't have access to the 129 # keys, but want the package to be predexopt'ed. 130 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) 131 PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1 132 133 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 134 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 135endif 136ifeq ($(LOCAL_CERTIFICATE),) 137 # It is now a build error to add a prebuilt .apk without 138 # specifying a key for it. 139 $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)") 140else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) 141 # The magic string "PRESIGNED" means this package is already checked 142 # signed with its release key. 143 # 144 # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be 145 # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") 146 # but the dexpreopt process will not try to re-sign the app. 147 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED 148 PACKAGES := $(PACKAGES) $(LOCAL_MODULE) 149else 150 # If this is not an absolute certificate, assign it to a generic one. 151 ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) 152 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) 153 endif 154 155 PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 156 PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 157 PACKAGES := $(PACKAGES) $(LOCAL_MODULE) 158 159 $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 160 $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 161endif 162 163# Disable dex-preopt of prebuilts to save space, if requested. 164ifeq ($(DONT_DEXPREOPT_PREBUILTS),true) 165LOCAL_DEX_PREOPT := false 166endif 167 168####################################### 169# defines built_odex along with rule to install odex 170include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk 171####################################### 172# Sign and align non-presigned .apks. 173$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) 174 $(transform-prebuilt-to-target) 175ifdef extracted_jni_libs 176 $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries. 177endif 178ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) 179 $(sign-package) 180endif 181ifdef LOCAL_DEX_PREOPT 182ifneq (nostripping,$(LOCAL_DEX_PREOPT)) 183 $(call dexpreopt-remove-classes.dex,$@) 184endif 185endif 186 $(align-package) 187 188############################### 189## Rule to build the odex file 190ifdef LOCAL_DEX_PREOPT 191$(built_odex) : $(my_prebuilt_src_file) 192 $(call dexpreopt-one-file,$<,$@) 193endif 194 195############################### 196## Install split apks. 197ifdef LOCAL_PACKAGE_SPLITS 198# LOCAL_PACKAGE_SPLITS is a list of apks to be installed. 199built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) 200installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS))) 201 202# Rules to sign and zipalign the split apks. 203my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS))) 204ifneq (1,$(words $(my_src_dir))) 205$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS)) 206endif 207my_src_dir := $(LOCAL_PATH)/$(my_src_dir) 208 209$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 210$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem 211$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP) 212 $(copy-file-to-new-target) 213 $(sign-package) 214 $(align-package) 215 216# Rules to install the split apks. 217$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP) 218 @echo "Install: $@" 219 $(copy-file-to-new-target) 220 221# Register the additional built and installed files. 222ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) 223ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ 224 $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s))) 225 226# Make sure to install the splits when you run "make <module_name>". 227$(my_register_name): $(installed_apk_splits) 228 229endif # LOCAL_PACKAGE_SPLITS 230 231else # LOCAL_MODULE_CLASS != APPS 232ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) 233$(built_module) : $(my_prebuilt_src_file) 234 $(transform-prebuilt-to-target-strip-comments) 235else 236$(built_module) : $(my_prebuilt_src_file) | $(ACP) 237 $(transform-prebuilt-to-target) 238ifneq ($(prebuilt_module_is_a_library),) 239 ifneq ($(LOCAL_IS_HOST_MODULE),) 240 $(transform-host-ranlib-copy-hack) 241 else 242 $(transform-ranlib-copy-hack) 243 endif 244endif 245endif 246endif # LOCAL_MODULE_CLASS != APPS 247 248ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) 249# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, 250# while the deps should be in the common dir, so we make a copy in the common dir. 251# For nonstatic library, $(common_javalib_jar) is the dependency file, 252# while $(common_classes_jar) is used to link. 253common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar 254common_javalib_jar := $(dir $(common_classes_jar))javalib.jar 255 256$(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP) 257 $(transform-prebuilt-to-target) 258 259$(common_javalib_jar) : $(common_classes_jar) | $(ACP) 260 $(transform-prebuilt-to-target) 261 262# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) 263$(built_module) : $(common_javalib_jar) 264endif # TARGET JAVA_LIBRARIES 265 266$(built_module) : $(LOCAL_MODULE_MAKEFILE) $(LOCAL_ADDITIONAL_DEPENDENCIES) 267 268my_prebuilt_src_file := 269