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 | |
| 22 | ifdef LOCAL_PREBUILT_MODULE_FILE |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 23 | my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 24 | else |
Ying Wang | c0adfb7 | 2014-02-27 14:10:53 -0800 | [diff] [blame] | 25 | ifdef LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) |
| 26 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) |
| 27 | else |
| 28 | my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES) |
| 29 | endif |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 30 | endif |
| 31 | |
| 32 | ifdef LOCAL_IS_HOST_MODULE |
| 33 | my_prefix := HOST_ |
| 34 | else |
| 35 | my_prefix := TARGET_ |
| 36 | endif |
| 37 | ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) |
| 38 | # Put the built targets of all shared libraries in a common directory |
| 39 | # to simplify the link line. |
| 40 | OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) |
| 41 | endif |
| 42 | |
| 43 | ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),) |
| 44 | prebuilt_module_is_a_library := true |
| 45 | else |
| 46 | prebuilt_module_is_a_library := |
| 47 | endif |
| 48 | |
| 49 | # Don't install static libraries by default. |
| 50 | ifndef LOCAL_UNINSTALLABLE_MODULE |
| 51 | ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)) |
| 52 | LOCAL_UNINSTALLABLE_MODULE := true |
| 53 | endif |
| 54 | endif |
| 55 | |
| 56 | ifeq ($(LOCAL_STRIP_MODULE),true) |
| 57 | ifdef LOCAL_IS_HOST_MODULE |
| 58 | $(error Cannot strip host module LOCAL_PATH=$(LOCAL_PATH)) |
| 59 | endif |
| 60 | ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),) |
| 61 | $(error Can strip only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH)) |
| 62 | endif |
| 63 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 64 | $(error Cannot strip scripts LOCAL_PATH=$(LOCAL_PATH)) |
| 65 | endif |
| 66 | include $(BUILD_SYSTEM)/dynamic_binary.mk |
| 67 | built_module := $(linked_module) |
| 68 | else # LOCAL_STRIP_MODULE not true |
| 69 | include $(BUILD_SYSTEM)/base_rules.mk |
| 70 | built_module := $(LOCAL_BUILT_MODULE) |
| 71 | |
| 72 | ifdef prebuilt_module_is_a_library |
| 73 | export_includes := $(intermediates)/export_includes |
| 74 | $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS) |
| 75 | $(export_includes) : $(LOCAL_MODULE_MAKEFILE) |
| 76 | @echo Export includes file: $< -- $@ |
| 77 | $(hide) mkdir -p $(dir $@) && rm -f $@ |
| 78 | ifdef LOCAL_EXPORT_C_INCLUDE_DIRS |
| 79 | $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ |
| 80 | echo "-I $$d" >> $@; \ |
| 81 | done |
| 82 | else |
| 83 | $(hide) touch $@ |
| 84 | endif |
| 85 | |
| 86 | $(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes |
| 87 | endif # prebuilt_module_is_a_library |
| 88 | |
| 89 | # The real dependency will be added after all Android.mks are loaded and the install paths |
| 90 | # of the shared libraries are determined. |
| 91 | ifdef LOCAL_INSTALLED_MODULE |
| 92 | ifdef LOCAL_SHARED_LIBRARIES |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 93 | $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ |
| 94 | $(LOCAL_MODULE):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(LOCAL_SHARED_LIBRARIES)) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 95 | |
| 96 | # We also need the LOCAL_BUILT_MODULE dependency, |
| 97 | # since we use -rpath-link which points to the built module's path. |
| 98 | built_shared_libraries := \ |
Ying Wang | 58f462f | 2014-02-25 18:26:29 -0800 | [diff] [blame] | 99 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 100 | $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \ |
| 101 | $(LOCAL_SHARED_LIBRARIES))) |
| 102 | $(LOCAL_BUILT_MODULE) : $(built_shared_libraries) |
| 103 | endif |
| 104 | endif |
| 105 | |
| 106 | endif # LOCAL_STRIP_MODULE not true |
| 107 | |
Ying Wang | f0534c2 | 2014-04-15 11:12:21 -0700 | [diff] [blame^] | 108 | ifeq ($(LOCAL_MODULE_CLASS),APPS) |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 109 | PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 110 | |
| 111 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 112 | # The magic string "EXTERNAL" means this package will be signed with |
| 113 | # the default dev key throughout the build process, but we expect |
| 114 | # the final package to be signed with a different key. |
| 115 | # |
| 116 | # This can be used for packages where we don't have access to the |
| 117 | # keys, but want the package to be predexopt'ed. |
| 118 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 119 | PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1 |
| 120 | |
| 121 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 122 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 123 | endif |
| 124 | ifeq ($(LOCAL_CERTIFICATE),) |
Ying Wang | f0534c2 | 2014-04-15 11:12:21 -0700 | [diff] [blame^] | 125 | # It is now a build error to add a prebuilt .apk without |
| 126 | # specifying a key for it. |
| 127 | $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)") |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 128 | else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 129 | # The magic string "PRESIGNED" means this package is already checked |
| 130 | # signed with its release key. |
| 131 | # |
| 132 | # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be |
| 133 | # mentioned in apkcerts.txt (with certificate set to "PRESIGNED") |
| 134 | # but the dexpreopt process will not try to re-sign the app. |
| 135 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED |
| 136 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 137 | else |
| 138 | # If this is not an absolute certificate, assign it to a generic one. |
| 139 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 140 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 141 | endif |
| 142 | |
| 143 | PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 144 | PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 145 | PACKAGES := $(PACKAGES) $(LOCAL_MODULE) |
| 146 | |
| 147 | $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8 |
| 148 | $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem |
| 149 | endif |
| 150 | |
Colin Cross | e18cb93 | 2014-02-13 15:04:18 -0800 | [diff] [blame] | 151 | # Disable dex-preopt of prebuilts to save space |
| 152 | LOCAL_DEX_PREOPT := false |
| 153 | |
| 154 | ####################################### |
| 155 | # defines built_odex along with rule to install odex |
| 156 | include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk |
| 157 | ####################################### |
| 158 | ifdef LOCAL_DEX_PREOPT |
| 159 | $(built_module): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE) |
| 160 | $(built_module): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 161 | $(built_module): PRIVATE_BUILT_ODEX := $(built_odex) |
| 162 | # Make sure the boot jars get dexpreopt-ed first |
| 163 | $(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) |
| 164 | $(built_module) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) |
| 165 | (built_module) : $(LOCAL_DEX_PREOPT_IMAGE) |
| 166 | # built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe. |
| 167 | $(built_odex) : $(LOCAL_BUILT_MODULE) |
| 168 | endif # LOCAL_DEX_PREOPT |
| 169 | # Sign and align non-presigned .apks. |
| 170 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) |
| 171 | $(transform-prebuilt-to-target) |
| 172 | ifneq ($(LOCAL_CERTIFICATE),PRESIGNED) |
| 173 | $(sign-package) |
| 174 | endif |
| 175 | ifdef LOCAL_DEX_PREOPT |
| 176 | $(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX)) |
| 177 | endif |
| 178 | $(align-package) |
| 179 | |
| 180 | else # LOCAL_MODULE_CLASS != APPS |
| 181 | ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) |
| 182 | $(built_module) : $(my_prebuilt_src_file) |
| 183 | $(transform-prebuilt-to-target-strip-comments) |
| 184 | else |
| 185 | $(built_module) : $(my_prebuilt_src_file) | $(ACP) |
| 186 | $(transform-prebuilt-to-target) |
| 187 | ifneq ($(prebuilt_module_is_a_library),) |
| 188 | ifneq ($(LOCAL_IS_HOST_MODULE),) |
| 189 | $(transform-host-ranlib-copy-hack) |
| 190 | else |
| 191 | $(transform-ranlib-copy-hack) |
| 192 | endif |
| 193 | endif |
| 194 | endif |
| 195 | endif # LOCAL_MODULE_CLASS != APPS |
| 196 | |
| 197 | ifeq ($(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS),JAVA_LIBRARIES) |
| 198 | # for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir, |
| 199 | # while the deps should be in the common dir, so we make a copy in the common dir. |
| 200 | # For nonstatic library, $(common_javalib_jar) is the dependency file, |
| 201 | # while $(common_classes_jar) is used to link. |
| 202 | common_classes_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),,COMMON)/classes.jar |
| 203 | common_javalib_jar := $(dir $(common_classes_jar))javalib.jar |
| 204 | |
| 205 | $(common_classes_jar) : $(my_prebuilt_src_file) | $(ACP) |
| 206 | $(transform-prebuilt-to-target) |
| 207 | |
| 208 | $(common_javalib_jar) : $(common_classes_jar) | $(ACP) |
| 209 | $(transform-prebuilt-to-target) |
| 210 | |
| 211 | # make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE) |
| 212 | $(built_module) : $(common_javalib_jar) |
| 213 | endif # TARGET JAVA_LIBRARIES |
| 214 | |
| 215 | $(built_module) : $(LOCAL_ADDITIONAL_DEPENDENCIES) |
| 216 | |
| 217 | my_prebuilt_src_file := |