Colin Cross | 8e40412 | 2014-02-06 14:45:37 -0800 | [diff] [blame^] | 1 | # |
| 2 | # Copyright (C) 2008 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | |
| 17 | ########################################################### |
| 18 | ## Standard rules for building an application package. |
| 19 | ## |
| 20 | ## Additional inputs from base_rules.make: |
| 21 | ## LOCAL_PACKAGE_NAME: The name of the package; the directory |
| 22 | ## will be called this. |
| 23 | ## |
| 24 | ## MODULE, MODULE_PATH, and MODULE_SUFFIX will |
| 25 | ## be set for you. |
| 26 | ########################################################### |
| 27 | |
| 28 | # If this makefile is being read from within an inheritance, |
| 29 | # use the new values. |
| 30 | skip_definition:= |
| 31 | ifdef LOCAL_PACKAGE_OVERRIDES |
| 32 | package_overridden := $(call set-inherited-package-variables) |
| 33 | ifeq ($(strip $(package_overridden)),) |
| 34 | skip_definition := true |
| 35 | endif |
| 36 | endif |
| 37 | |
| 38 | ifndef skip_definition |
| 39 | |
| 40 | LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME)) |
| 41 | ifeq ($(LOCAL_PACKAGE_NAME),) |
| 42 | $(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME) |
| 43 | endif |
| 44 | |
| 45 | ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),) |
| 46 | $(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX) |
| 47 | endif |
| 48 | LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) |
| 49 | |
| 50 | ifneq ($(strip $(LOCAL_MODULE)),) |
| 51 | $(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE) |
| 52 | endif |
| 53 | LOCAL_MODULE := $(LOCAL_PACKAGE_NAME) |
| 54 | |
| 55 | ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) |
| 56 | LOCAL_MANIFEST_FILE := AndroidManifest.xml |
| 57 | endif |
| 58 | |
| 59 | # If you need to put the MANIFEST_FILE outside of LOCAL_PATH |
| 60 | # you can use FULL_MANIFEST_FILE |
| 61 | ifeq ($(strip $(LOCAL_FULL_MANIFEST_FILE)),) |
| 62 | LOCAL_FULL_MANIFEST_FILE := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) |
| 63 | endif |
| 64 | |
| 65 | ifneq ($(strip $(LOCAL_MODULE_CLASS)),) |
| 66 | $(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS) |
| 67 | endif |
| 68 | LOCAL_MODULE_CLASS := APPS |
| 69 | |
| 70 | # Package LOCAL_MODULE_TAGS default to optional |
| 71 | LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS)) |
| 72 | ifeq ($(LOCAL_MODULE_TAGS),) |
| 73 | LOCAL_MODULE_TAGS := optional |
| 74 | endif |
| 75 | |
| 76 | ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) |
| 77 | # Force localization check if it's not tagged as tests. |
| 78 | LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z |
| 79 | endif |
| 80 | |
| 81 | ifeq (,$(LOCAL_ASSET_DIR)) |
| 82 | LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets |
| 83 | endif |
| 84 | |
| 85 | ifeq (,$(LOCAL_RESOURCE_DIR)) |
| 86 | LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res |
| 87 | endif |
| 88 | |
| 89 | package_resource_overlays := $(strip \ |
| 90 | $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \ |
| 91 | $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \ |
| 92 | $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \ |
| 93 | $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR))))) |
| 94 | |
| 95 | LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR) |
| 96 | |
| 97 | all_assets := $(call find-subdir-assets,$(LOCAL_ASSET_DIR)) |
| 98 | all_assets := $(addprefix $(LOCAL_ASSET_DIR)/,$(patsubst assets/%,%,$(all_assets))) |
| 99 | |
| 100 | all_resources := $(strip \ |
| 101 | $(foreach dir, $(LOCAL_RESOURCE_DIR), \ |
| 102 | $(addprefix $(dir)/, \ |
| 103 | $(patsubst res/%,%, \ |
| 104 | $(call find-subdir-assets,$(dir)) \ |
| 105 | ) \ |
| 106 | ) \ |
| 107 | )) |
| 108 | |
| 109 | all_res_assets := $(strip $(all_assets) $(all_resources)) |
| 110 | |
| 111 | package_expected_intermediates_COMMON := $(call local-intermediates-dir,COMMON) |
| 112 | # If no assets or resources were found, clear the directory variables so |
| 113 | # we don't try to build them. |
| 114 | ifeq (,$(all_assets)) |
| 115 | LOCAL_ASSET_DIR:= |
| 116 | endif |
| 117 | ifeq (,$(all_resources)) |
| 118 | LOCAL_RESOURCE_DIR:= |
| 119 | R_file_stamp := |
| 120 | else |
| 121 | # Make sure that R_file_stamp inherits the proper PRIVATE vars. |
| 122 | # If R.stamp moves, be sure to update the framework makefile, |
| 123 | # which has intimate knowledge of its location. |
| 124 | R_file_stamp := $(package_expected_intermediates_COMMON)/src/R.stamp |
| 125 | LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) |
| 126 | endif |
| 127 | |
| 128 | LOCAL_BUILT_MODULE_STEM := package.apk |
| 129 | |
| 130 | LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED)) |
| 131 | ifndef LOCAL_PROGUARD_ENABLED |
| 132 | ifneq ($(DISABLE_PROGUARD),true) |
| 133 | LOCAL_PROGUARD_ENABLED :=full |
| 134 | endif |
| 135 | endif |
| 136 | ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) |
| 137 | # the package explicitly request to disable proguard. |
| 138 | LOCAL_PROGUARD_ENABLED := |
| 139 | endif |
| 140 | proguard_options_file := |
| 141 | ifneq ($(LOCAL_PROGUARD_ENABLED),custom) |
| 142 | ifneq ($(all_resources),) |
| 143 | proguard_options_file := $(package_expected_intermediates_COMMON)/proguard_options |
| 144 | endif # all_resources |
| 145 | endif # !custom |
| 146 | LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) |
| 147 | |
| 148 | ifeq (true,$(EMMA_INSTRUMENT)) |
| 149 | ifndef LOCAL_EMMA_INSTRUMENT |
| 150 | # No emma for test apks. |
| 151 | ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR)) |
| 152 | LOCAL_EMMA_INSTRUMENT := true |
| 153 | endif # No test apk |
| 154 | endif # LOCAL_EMMA_INSTRUMENT is not set |
| 155 | else |
| 156 | LOCAL_EMMA_INSTRUMENT := false |
| 157 | endif # EMMA_INSTRUMENT is true |
| 158 | |
| 159 | ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) |
| 160 | ifeq (true,$(EMMA_INSTRUMENT_STATIC)) |
| 161 | LOCAL_STATIC_JAVA_LIBRARIES += emma |
| 162 | else |
| 163 | ifdef LOCAL_SDK_VERSION |
| 164 | ifdef TARGET_BUILD_APPS |
| 165 | # In unbundled build merge the emma library into the apk. |
| 166 | LOCAL_STATIC_JAVA_LIBRARIES += emma |
| 167 | else |
| 168 | # If build against the SDK in full build, core.jar is not used, |
| 169 | # we have to use prebiult emma.jar to make Proguard happy; |
| 170 | # Otherwise emma classes are included in core.jar. |
| 171 | LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR) |
| 172 | endif # full build |
| 173 | endif # LOCAL_SDK_VERSION |
| 174 | endif # EMMA_INSTRUMENT_STATIC |
| 175 | endif # LOCAL_EMMA_INSTRUMENT |
| 176 | |
| 177 | rs_compatibility_jni_libs := |
| 178 | |
| 179 | ################################# |
| 180 | include $(BUILD_SYSTEM)/java.mk |
| 181 | ################################# |
| 182 | |
| 183 | LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) |
| 184 | ifeq ($(LOCAL_SDK_RES_VERSION),) |
| 185 | LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) |
| 186 | endif |
| 187 | |
| 188 | full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) |
| 189 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 190 | PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) |
| 191 | ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) |
| 192 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 193 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) |
| 194 | else |
| 195 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 196 | PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) |
| 197 | endif |
| 198 | |
| 199 | ifneq ($(all_resources),) |
| 200 | |
| 201 | # Since we don't know where the real R.java file is going to end up, |
| 202 | # we need to use another file to stand in its place. We'll just |
| 203 | # copy the generated file to src/R.stamp, which means it will |
| 204 | # have the same contents and timestamp as the actual file. |
| 205 | # |
| 206 | # At the same time, this will copy the R.java file to a central |
| 207 | # 'R' directory to make it easier to add the files to an IDE. |
| 208 | # |
| 209 | #TODO: use PRIVATE_SOURCE_INTERMEDIATES_DIR instead of |
| 210 | # $(intermediates.COMMON)/src |
| 211 | ifneq ($(package_expected_intermediates_COMMON),$(intermediates.COMMON)) |
| 212 | $(error $(LOCAL_MODULE): internal error: expected intermediates.COMMON "$(package_expected_intermediates_COMMON)" != intermediates.COMMON "$(intermediates.COMMON)") |
| 213 | endif |
| 214 | |
| 215 | $(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ |
| 216 | $(intermediates.COMMON)/public_resources.xml |
| 217 | $(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) |
| 218 | $(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP) |
| 219 | @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" |
| 220 | @rm -f $@ |
| 221 | $(create-resource-java-files) |
| 222 | $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 223 | -name Manifest.java 2> /dev/null`; do \ |
| 224 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ |
| 225 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 226 | $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 227 | done; |
| 228 | $(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ |
| 229 | -name R.java 2> /dev/null`; do \ |
| 230 | dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ |
| 231 | mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ |
| 232 | $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ |
| 233 | || exit 31; \ |
| 234 | $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \ |
| 235 | done; \ |
| 236 | |
| 237 | $(proguard_options_file): $(R_file_stamp) |
| 238 | |
| 239 | ifdef LOCAL_EXPORT_PACKAGE_RESOURCES |
| 240 | # Put this module's resources into a PRODUCT-agnositc package that |
| 241 | # other packages can use to build their own PRODUCT-agnostic R.java (etc.) |
| 242 | # files. |
| 243 | resource_export_package := $(intermediates.COMMON)/package-export.apk |
| 244 | $(R_file_stamp): $(resource_export_package) |
| 245 | |
| 246 | # add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target |
| 247 | # can't know anything about PRODUCT. Clear it out just for this target. |
| 248 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 249 | $(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 250 | $(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) |
| 251 | @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" |
| 252 | $(create-empty-package) |
| 253 | $(add-assets-to-package) |
| 254 | endif |
| 255 | |
| 256 | # Other modules should depend on the BUILT module if |
| 257 | # they want to use this module's R.java file. |
| 258 | $(LOCAL_BUILT_MODULE): $(R_file_stamp) |
| 259 | |
| 260 | ifneq ($(full_classes_jar),) |
| 261 | # If full_classes_jar is non-empty, we're building sources. |
| 262 | # If we're building sources, the initial javac step (which |
| 263 | # produces full_classes_compiled_jar) needs to ensure the |
| 264 | # R.java and Manifest.java files have been generated first. |
| 265 | $(full_classes_compiled_jar): $(R_file_stamp) |
| 266 | endif |
| 267 | |
| 268 | endif # all_resources |
| 269 | |
| 270 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 271 | # We need to explicitly clear this var so that we don't |
| 272 | # inherit the value from whomever caused us to be built. |
| 273 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := |
| 274 | else |
| 275 | # Most packages should link against the resources defined by framework-res. |
| 276 | # Even if they don't have their own resources, they may use framework |
| 277 | # resources. |
| 278 | ifneq ($(filter-out current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_RES_VERSION))),) |
| 279 | # for released sdk versions, the platform resources were built into android.jar. |
| 280 | framework_res_package_export := \ |
| 281 | $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar |
| 282 | framework_res_package_export_deps := $(framework_res_package_export) |
| 283 | else # LOCAL_SDK_RES_VERSION |
| 284 | framework_res_package_export := \ |
| 285 | $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk |
| 286 | # We can't depend directly on the export.apk file; it won't get its |
| 287 | # PRIVATE_ vars set up correctly if we do. Instead, depend on the |
| 288 | # corresponding R.stamp file, which lists the export.apk as a dependency. |
| 289 | framework_res_package_export_deps := \ |
| 290 | $(dir $(framework_res_package_export))src/R.stamp |
| 291 | endif # LOCAL_SDK_RES_VERSION |
| 292 | $(R_file_stamp): $(framework_res_package_export_deps) |
| 293 | $(LOCAL_INTERMEDIATE_TARGETS): \ |
| 294 | PRIVATE_AAPT_INCLUDES := $(framework_res_package_export) |
| 295 | endif # LOCAL_NO_STANDARD_LIBRARIES |
| 296 | |
| 297 | ifneq ($(full_classes_jar),) |
| 298 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) |
| 299 | $(LOCAL_BUILT_MODULE): $(built_dex) |
| 300 | endif # full_classes_jar |
| 301 | |
| 302 | |
| 303 | # Get the list of jni libraries to be included in the apk file. |
| 304 | |
| 305 | so_suffix := $($(my_prefix)SHLIB_SUFFIX) |
| 306 | |
| 307 | jni_shared_libraries := \ |
| 308 | $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ |
| 309 | $(addsuffix $(so_suffix), \ |
| 310 | $(LOCAL_JNI_SHARED_LIBRARIES))) |
| 311 | |
| 312 | # Include RS dynamically-generated libraries as well |
| 313 | # Keep this ifneq, as the += otherwise adds spaces that need to be stripped. |
| 314 | ifneq ($(rs_compatibility_jni_libs),) |
| 315 | jni_shared_libraries += $(rs_compatibility_jni_libs) |
| 316 | endif |
| 317 | |
| 318 | # App explicitly requires the prebuilt NDK libstlport_shared.so. |
| 319 | # libstlport_shared.so should never go to the system image. |
| 320 | # Instead it should be packaged into the apk. |
| 321 | ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT)) |
| 322 | ifndef LOCAL_SDK_VERSION |
| 323 | $(error LOCAL_SDK_VERSION has to be defined together with LOCAL_NDK_STL_VARIANT, \ |
| 324 | LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME)) |
| 325 | endif |
| 326 | jni_shared_libraries += \ |
| 327 | $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)/libstlport_shared.so |
| 328 | endif |
| 329 | |
| 330 | # Set the abi directory used by the local JNI shared libraries. |
| 331 | # (Doesn't change how the local shared libraries are compiled, just |
| 332 | # sets where they are stored in the apk.) |
| 333 | |
| 334 | ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),) |
| 335 | jni_shared_libraries_abi := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI) |
| 336 | else |
| 337 | jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI) |
| 338 | endif |
| 339 | |
| 340 | # Pick a key to sign the package with. If this package hasn't specified |
| 341 | # an explicit certificate, use the default. |
| 342 | # Secure release builds will have their packages signed after the fact, |
| 343 | # so it's ok for these private keys to be in the clear. |
| 344 | ifeq ($(LOCAL_CERTIFICATE),) |
| 345 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 346 | endif |
| 347 | |
| 348 | ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) |
| 349 | # The special value "EXTERNAL" means that we will sign it with the |
| 350 | # default devkey, apply predexopt, but then expect the final .apk |
| 351 | # (after dexopting) to be signed by an outside tool. |
| 352 | LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) |
| 353 | PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1 |
| 354 | endif |
| 355 | |
| 356 | # If this is not an absolute certificate, assign it to a generic one. |
| 357 | ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) |
| 358 | LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) |
| 359 | endif |
| 360 | private_key := $(LOCAL_CERTIFICATE).pk8 |
| 361 | certificate := $(LOCAL_CERTIFICATE).x509.pem |
| 362 | |
| 363 | $(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR) |
| 364 | $(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key) |
| 365 | $(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate) |
| 366 | |
| 367 | PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key) |
| 368 | PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate) |
| 369 | |
| 370 | $(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\ |
| 371 | $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8) |
| 372 | |
| 373 | # Define the rule to build the actual package. |
| 374 | $(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN) |
| 375 | ifdef LOCAL_DEX_PREOPT |
| 376 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE)) |
| 377 | $(LOCAL_BUILT_MODULE): PRIVATE_BUILT_ODEX := $(built_odex) |
| 378 | $(LOCAL_BUILT_MODULE): PRIVATE_DEX_PREOPT_IMAGE := $(LOCAL_DEX_PREOPT_IMAGE) |
| 379 | # Make sure the boot jars get dexpreopt-ed first |
| 380 | $(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) |
| 381 | $(LOCAL_BUILT_MODULE) : $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) |
| 382 | $(LOCAL_BUILT_MODULE) : $(LOCAL_DEX_PREOPT_IMAGE) |
| 383 | |
| 384 | # built_odex is byproduct of LOCAL_BUILT_MODULE without its own build recipe. |
| 385 | $(built_odex) : $(LOCAL_BUILT_MODULE) |
| 386 | endif |
| 387 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries) |
| 388 | $(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abi) |
| 389 | ifneq ($(TARGET_BUILD_APPS),) |
| 390 | # Include all resources for unbundled apps. |
| 391 | LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true |
| 392 | endif |
| 393 | ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true) |
| 394 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := |
| 395 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := |
| 396 | else |
| 397 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG) |
| 398 | $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) |
| 399 | endif |
| 400 | $(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) |
| 401 | @echo "target Package: $(PRIVATE_MODULE) ($@)" |
| 402 | $(create-empty-package) |
| 403 | $(add-assets-to-package) |
| 404 | ifneq ($(jni_shared_libraries),) |
| 405 | $(add-jni-shared-libs-to-package) |
| 406 | endif |
| 407 | ifneq ($(full_classes_jar),) |
| 408 | $(add-dex-to-package) |
| 409 | endif |
| 410 | $(add-carried-java-resources) |
| 411 | ifneq ($(extra_jar_args),) |
| 412 | $(add-java-resources-to-package) |
| 413 | endif |
| 414 | $(sign-package) |
| 415 | ifdef LOCAL_DEX_PREOPT |
| 416 | $(call dexpreopt-one-file,$(PRIVATE_DEX_PREOPT_IMAGE),$@,$(PRIVATE_DEX_LOCATION),$(PRIVATE_BUILT_ODEX)) |
| 417 | ifneq (nostripping,$(LOCAL_DEX_PREOPT)) |
| 418 | $(call dexpreopt-remove-classes.dex,$@) |
| 419 | endif |
| 420 | endif |
| 421 | @# Alignment must happen after all other zip operations. |
| 422 | $(align-package) |
| 423 | |
| 424 | # Save information about this package |
| 425 | PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) |
| 426 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources) |
| 427 | ifdef package_resource_overlays |
| 428 | PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays) |
| 429 | endif |
| 430 | |
| 431 | PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME) |
| 432 | |
| 433 | # Dist the files that can be bundled in system.img. |
| 434 | # They include the jni shared libraries and the apk with jni libraries stripped. |
| 435 | ifeq ($(LOCAL_DIST_BUNDLED_BINARIES),true) |
| 436 | ifneq ($(filter $(LOCAL_PACKAGE_NAME),$(TARGET_BUILD_APPS)),) |
| 437 | ifneq ($(strip $(jni_shared_libraries)),) |
| 438 | dist_subdir := bundled_$(LOCAL_PACKAGE_NAME) |
| 439 | $(foreach f, $(jni_shared_libraries), \ |
| 440 | $(call dist-for-goals, apps_only, $(f):$(dist_subdir)/$(notdir $(f)))) |
| 441 | |
| 442 | apk_jni_stripped := $(intermediates)/jni_stripped/package.apk |
| 443 | $(apk_jni_stripped): PRIVATE_JNI_SHARED_LIBRARIES := $(notdir $(jni_shared_libraries)) |
| 444 | $(apk_jni_stripped) : $(LOCAL_BUILT_MODULE) | $(ZIPALIGN) |
| 445 | @rm -rf $(dir $@) && mkdir -p $(dir $@) |
| 446 | $(hide) cp $< $@ |
| 447 | $(hide) zip -d $@ $(foreach f,$(PRIVATE_JNI_SHARED_LIBRARIES),\*/$(f)) |
| 448 | $(call align-package) |
| 449 | |
| 450 | $(call dist-for-goals, apps_only, $(apk_jni_stripped):$(dist_subdir)/$(LOCAL_PACKAGE_NAME).apk) |
| 451 | |
| 452 | endif # jni_shared_libraries |
| 453 | endif # apps_only build |
| 454 | endif # LOCAL_DIST_BUNDLED_BINARIES |
| 455 | |
| 456 | # Lint phony targets |
| 457 | .PHONY: lint-$(LOCAL_PACKAGE_NAME) |
| 458 | lint-$(LOCAL_PACKAGE_NAME): PRIVATE_PATH := $(LOCAL_PATH) |
| 459 | lint-$(LOCAL_PACKAGE_NAME): PRIVATE_LINT_FLAGS := $(LOCAL_LINT_FLAGS) |
| 460 | lint-$(LOCAL_PACKAGE_NAME) : |
| 461 | @echo lint $(PRIVATE_PATH) |
| 462 | $(LINT) $(PRIVATE_LINT_FLAGS) $(PRIVATE_PATH) |
| 463 | |
| 464 | lintall : lint-$(LOCAL_PACKAGE_NAME) |
| 465 | |
| 466 | endif # skip_definition |
| 467 | |
| 468 | # Reset internal variables. |
| 469 | all_res_assets := |