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 | 6c930fc | 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 | 6c930fc | 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 | 6c930fc | 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 | |
| 57 | ifeq ($(LOCAL_STRIP_MODULE),true) |
| 58 | ifdef LOCAL_IS_HOST_MODULE |
| 59 | $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH)) |
| 60 | endif |
| 61 | ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),) |
| 62 | $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH)) |
| 63 | endif |
| 64 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 65 | $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH)) |
| 66 | endif |
| 67 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 68 | built_module := $(linked_module) |
| 69 | else # LOCAL_STRIP_MODULE not true |
| 70 | include $(BUILD_SYSTEM)/base_rules.mk |
| 71 | built_module := $(LOCAL_BUILT_MODULE) |
| 72 | |
| 73 | ifdef prebuilt_module_is_a_library |
| 74 | export_includes := $(intermediates)/export_includes |
| 75 | $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
| 76 | $(export_includes) : $(LOCAL_MODULE_MAKEFILE) |
| 77 | @echo Export includes file: $< -- $@ |
| 78 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 79 | ifdef LOCAL_EXPORT_C_INCLUDE_DIRS |
| 80 | $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ |
| 81 | echo "-I $$d" >> $@; \ |
| 82 | done |
| 83 | else |
| 84 | $(hide) touch $@ |
| 85 | endif |
| 86 | |
| 87 | $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes |
| 88 | endif # prebuilt_module_is_a_library |
| 89 | |
| 90 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 91 | # of the shared libraries are determined. |
| 92 | ifdef LOCAL_INSTALLED_MODULE |
| 93 | ifdef LOCAL_SHARED_LIBRARIES |
Ying Wang | 75e8fcb | 2014-10-07 13:03:29 -0700 | [diff] [blame^] | 94 | my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) |
| 95 | # Extra shared libraries introduced by LOCAL_CXX_STL. |
| 96 | include $(BUILD_SYSTEM)/cxx_stl_setup.mk |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 97 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
Ying Wang | 75e8fcb | 2014-10-07 13:03:29 -0700 | [diff] [blame^] | 98 | $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 99 | |
| 100 | # We also need the LOCAL_BUILT_MODULE dependency, |
| 101 | # since we use -rpath-link which points to the built module's path. |
Ying Wang | 75e8fcb | 2014-10-07 13:03:29 -0700 | [diff] [blame^] | 102 | my_built_shared_libraries := \ |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 103 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 104 | $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ |
Ying Wang | 75e8fcb | 2014-10-07 13:03:29 -0700 | [diff] [blame^] | 105 | $(my_shared_libraries))) |
| 106 | $(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 107 | endif |
| 108 | endif |
| 109 | |
| 110 | endif # LOCAL_STRIP_MODULE not true |
| 111 | |
| 112 | PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 113 | |
Ying Wang | 695e826 | 2014-04-17 13:38:04 -0700 | [diff] [blame] | 114 | rs_compatibility_jni_libs := |
| 115 | include $(BUILD_SYSTEM)/install_jni_libs.mk |
| 116 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 117 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 118 | # The magic string "EXTERNAL" means this package will be signed with |
| 119 | # the default dev key throughout the build process, but we expect |
| 120 | # the final package to be signed with a different key. |
| 121 | # |
| 122 | # This can be used for packages where we don't have access to the |
| 123 | # keys, but want the package to be predexopt'ed. |
| 124 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 125 | PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1 |
| 126 | |
| 127 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 128 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 129 | endif |
| 130 | ifeq ($(LOCAL_CERTIFICATE),) |
| 131 | ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),) |
| 132 | # It is now a build error to add a prebuilt .apk without |
| 133 | # specifying a key for it. |
| 134 | $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)") |
| 135 | endif |
| 136 | else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 137 | # The magic string "PRESIGNED" means this package is already checked |
| 138 | # signed with its release key. |
| 139 | # |
| 140 | # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be |
| 141 | # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") |
| 142 | # but the dexpreopt process will not try to re-sign the app. |
| 143 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED |
| 144 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 145 | else |
| 146 | # If this is not an absolute certificate, assign it to a generic one. |
| 147 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 148 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 149 | endif |
| 150 | |
| 151 | PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 152 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 153 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 154 | |
| 155 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 156 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 157 | endif |
| 158 | |
| 159 | ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),) |
| 160 | |
| 161 | # Disable dex-preopt of prebuilts to save space |
| 162 | LOCAL_DEX_PREOPT := false |
| 163 | |
| 164 | ####################################### |
| 165 | # defines built_odex along with rule to install odex |
| 166 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 167 | ####################################### |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 168 | # Sign and align non-presigned .apks. |
| 169 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) |
| 170 | $(transform-prebuilt-to-target) |
Ying Wang | 8e20ef6 | 2014-06-24 20:01:52 -0700 | [diff] [blame] | 171 | ifdef extracted_jni_libs |
Ying Wang | 7cf9f28 | 2014-04-18 20:13:41 -0700 | [diff] [blame] | 172 | $(hide) zip -d $@ 'lib/*.so' # strip embedded JNI libraries. |
| 173 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 174 | ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 175 | $(sign-package) |
| 176 | endif |
| 177 | ifdef LOCAL_DEX_PREOPT |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 178 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 179 | $(call dexpreopt-remove-classes.dex,$@) |
| 180 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 181 | endif |
| 182 | $(align-package) |
| 183 | |
Ying Wang | 36142f6 | 2014-05-21 16:13:33 -0700 | [diff] [blame] | 184 | ############################### |
| 185 | ## Rule to build the odex file |
| 186 | ifdef LOCAL_DEX_PREOPT |
| 187 | $(built_odex) : $(my_prebuilt_src_file) |
| 188 | $(call dexpreopt-one-file,$<,$@) |
| 189 | endif |
| 190 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 191 | else # LOCAL_MODULE_CLASS != APPS |
| 192 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 193 | $(built_module) : $(my_prebuilt_src_file) |
| 194 | $(transform-prebuilt-to-target-strip-comments) |
| 195 | else |
| 196 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) |
| 197 | $(transform-prebuilt-to-target) |
| 198 | ifneq ($(prebuilt_module_is_a_library),) |
| 199 | ifneq ($(LOCAL_IS_HOST_MODULE),) |
| 200 | $(transform-host-ranlib-copy-hack) |
| 201 | else |
| 202 | $(transform-ranlib-copy-hack) |
| 203 | endif |
| 204 | endif |
| 205 | endif |
| 206 | endif # LOCAL_MODULE_CLASS != APPS |
| 207 | |
| 208 | ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 209 | # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, |
| 210 | # while the deps should be in the common dir, so we make a copy in the common dir. |
| 211 | # For nonstatic library, $(common_javalib_jar) is the dependency file, |
| 212 | # while $(common_classes_jar) is used to link. |
| 213 | common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar |
| 214 | common_javalib_jar := $(dir $(common_classes_jar))javalib.jar |
| 215 | |
| 216 | $(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP) |
| 217 | $(transform-prebuilt-to-target) |
| 218 | |
| 219 | $(common_javalib_jar) : $(common_classes_jar) | $(ACP) |
| 220 | $(transform-prebuilt-to-target) |
| 221 | |
| 222 | # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) |
| 223 | $(built_module) : $(common_javalib_jar) |
| 224 | endif # TARGET JAVA_LIBRARIES |
| 225 | |
| 226 | $(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 227 | |
| 228 | my_prebuilt_src_file := |