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. 30skip_definition:= 31ifdef LOCAL_PACKAGE_OVERRIDES 32 package_overridden := $(call set-inherited-package-variables) 33 ifeq ($(strip $(package_overridden)),) 34 skip_definition := true 35 endif 36endif 37 38ifndef skip_definition 39 40LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME)) 41ifeq ($(LOCAL_PACKAGE_NAME),) 42$(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME) 43endif 44 45ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),) 46$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX) 47endif 48LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) 49 50ifneq ($(strip $(LOCAL_MODULE)),) 51$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE) 52endif 53LOCAL_MODULE := $(LOCAL_PACKAGE_NAME) 54 55ifneq ($(strip $(LOCAL_MODULE_CLASS)),) 56$(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS) 57endif 58LOCAL_MODULE_CLASS := APPS 59 60################################# 61include $(BUILD_SYSTEM)/configure_local_jack.mk 62################################# 63 64# Package LOCAL_MODULE_TAGS default to optional 65LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS)) 66ifeq ($(LOCAL_MODULE_TAGS),) 67LOCAL_MODULE_TAGS := optional 68endif 69 70ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),) 71# Force localization check if it's not tagged as tests. 72LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z 73endif 74 75ifdef LOCAL_PACKAGE_SPLITS 76LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS)) 77endif 78 79need_compile_asset := 80ifeq (,$(LOCAL_ASSET_DIR)) 81LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets 82else 83need_compile_asset := true 84endif 85 86# LOCAL_RESOURCE_DIR may point to resource generated during the build 87need_compile_res := 88ifeq (,$(LOCAL_RESOURCE_DIR)) 89 LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res 90else 91 need_compile_res := true 92endif 93 94package_resource_overlays := $(strip \ 95 $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \ 96 $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \ 97 $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \ 98 $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR))))) 99 100LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR) 101 102all_assets := $(strip \ 103 $(foreach dir, $(LOCAL_ASSET_DIR), \ 104 $(addprefix $(dir)/, \ 105 $(patsubst assets/%,%, \ 106 $(call find-subdir-assets, $(dir)) \ 107 ) \ 108 ) \ 109 )) 110 111ifneq ($(all_assets),) 112need_compile_asset := true 113endif 114 115all_resources := $(strip \ 116 $(foreach dir, $(LOCAL_RESOURCE_DIR), \ 117 $(addprefix $(dir)/, \ 118 $(patsubst res/%,%, \ 119 $(call find-subdir-assets,$(dir)) \ 120 ) \ 121 ) \ 122 )) 123 124ifneq ($(all_resources),) 125 need_compile_res := true 126endif 127 128all_res_assets := $(strip $(all_assets) $(all_resources)) 129 130intermediates.COMMON := $(call local-intermediates-dir,COMMON) 131 132# If no assets or resources were found, clear the directory variables so 133# we don't try to build them. 134ifneq (true,$(need_compile_asset)) 135LOCAL_ASSET_DIR:= 136endif 137ifneq (true,$(need_compile_res)) 138LOCAL_RESOURCE_DIR:= 139R_file_stamp := 140else 141# Make sure that R_file_stamp inherits the proper PRIVATE vars. 142# If R.stamp moves, be sure to update the framework makefile, 143# which has intimate knowledge of its location. 144R_file_stamp := $(intermediates.COMMON)/src/R.stamp 145LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp) 146endif 147 148LOCAL_BUILT_MODULE_STEM := package.apk 149LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk 150 151LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED)) 152ifndef LOCAL_PROGUARD_ENABLED 153ifneq ($(DISABLE_PROGUARD),true) 154 LOCAL_PROGUARD_ENABLED :=full 155endif 156endif 157ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) 158 # the package explicitly request to disable proguard. 159 LOCAL_PROGUARD_ENABLED := 160endif 161proguard_options_file := 162ifneq ($(LOCAL_PROGUARD_ENABLED),custom) 163ifeq ($(need_compile_res),true) 164 proguard_options_file := $(intermediates.COMMON)/proguard_options 165endif # need_compile_res 166endif # !custom 167LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS) 168 169ifdef LOCAL_JACK_ENABLED 170ifndef LOCAL_JACK_PROGUARD_FLAGS 171 LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS) 172endif 173LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS) 174endif # LOCAL_JACK_ENABLED 175 176ifeq (true,$(EMMA_INSTRUMENT)) 177ifndef LOCAL_EMMA_INSTRUMENT 178# No emma for test apks. 179ifeq (,$(filer tests,$(LOCAL_MODULE_TAGS))$(LOCAL_INSTRUMENTATION_FOR)) 180LOCAL_EMMA_INSTRUMENT := true 181endif # No test apk 182endif # LOCAL_EMMA_INSTRUMENT is not set 183else 184LOCAL_EMMA_INSTRUMENT := false 185endif # EMMA_INSTRUMENT is true 186 187ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) 188ifeq (true,$(EMMA_INSTRUMENT_STATIC)) 189LOCAL_STATIC_JAVA_LIBRARIES += emma 190else 191ifdef LOCAL_SDK_VERSION 192ifdef TARGET_BUILD_APPS 193# In unbundled build merge the emma library into the apk. 194LOCAL_STATIC_JAVA_LIBRARIES += emma 195else 196# If build against the SDK in full build, core.jar is not used, 197# we have to use prebiult emma.jar to make Proguard happy; 198# Otherwise emma classes are included in core.jar. 199LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR) 200endif # full build 201endif # LOCAL_SDK_VERSION 202endif # EMMA_INSTRUMENT_STATIC 203endif # LOCAL_EMMA_INSTRUMENT 204 205rs_compatibility_jni_libs := 206 207include $(BUILD_SYSTEM)/android_manifest.mk 208 209################################# 210include $(BUILD_SYSTEM)/java.mk 211################################# 212 213LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION)) 214ifeq ($(LOCAL_SDK_RES_VERSION),) 215 LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION) 216endif 217 218$(LOCAL_INTERMEDIATE_TARGETS): \ 219 PRIVATE_ANDROID_MANIFEST := $(full_android_manifest) 220ifneq (,$(filter-out current system_current, $(LOCAL_SDK_VERSION))) 221$(LOCAL_INTERMEDIATE_TARGETS): \ 222 PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION) 223else 224$(LOCAL_INTERMEDIATE_TARGETS): \ 225 PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK) 226endif 227 228ifeq ($(need_compile_res),true) 229 230# Since we don't know where the real R.java file is going to end up, 231# we need to use another file to stand in its place. We'll just 232# copy the generated file to src/R.stamp, which means it will 233# have the same contents and timestamp as the actual file. 234# 235# At the same time, this will copy the R.java file to a central 236# 'R' directory to make it easier to add the files to an IDE. 237# 238 239$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \ 240 $(intermediates.COMMON)/public_resources.xml 241$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) 242$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP) 243 @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" 244 @rm -f $@ 245 $(create-resource-java-files) 246 $(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ 247 -name Manifest.java 2> /dev/null`; do \ 248 dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \ 249 mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ 250 $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ 251 done; 252 $(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \ 253 -name R.java 2> /dev/null`; do \ 254 dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \ 255 mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \ 256 $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \ 257 || exit 31; \ 258 $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \ 259 done; \ 260 261$(proguard_options_file): $(R_file_stamp) 262 263resource_export_package := 264ifdef LOCAL_EXPORT_PACKAGE_RESOURCES 265# Put this module's resources into a PRODUCT-agnositc package that 266# other packages can use to build their own PRODUCT-agnostic R.java (etc.) 267# files. 268resource_export_package := $(intermediates.COMMON)/package-export.apk 269$(R_file_stamp): $(resource_export_package) 270 271# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target 272# can't know anything about PRODUCT. Clear it out just for this target. 273$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG := 274$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := 275$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) 276 @echo "target Export Resources: $(PRIVATE_MODULE) ($@)" 277 $(create-empty-package) 278 $(add-assets-to-package) 279endif 280 281# Other modules should depend on the BUILT module if 282# they want to use this module's R.java file. 283$(LOCAL_BUILT_MODULE): $(R_file_stamp) 284 285ifdef LOCAL_JACK_ENABLED 286ifneq ($(built_dex_intermediate),) 287$(built_dex_intermediate): $(R_file_stamp) 288endif 289ifneq ($(noshrob_classes_jack),) 290$(noshrob_classes_jack): $(R_file_stamp) 291endif 292ifneq ($(full_classes_jack),) 293$(full_classes_jack): $(R_file_stamp) 294endif 295endif # LOCAL_JACK_ENABLED 296 297ifneq ($(full_classes_jar),) 298# If full_classes_jar is non-empty, we're building sources. 299# If we're building sources, the initial javac step (which 300# produces full_classes_compiled_jar) needs to ensure the 301# R.java and Manifest.java files have been generated first. 302$(full_classes_compiled_jar): $(R_file_stamp) 303endif 304 305endif # need_compile_res 306 307ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 308# We need to explicitly clear this var so that we don't 309# inherit the value from whomever caused us to be built. 310$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := 311else 312# Most packages should link against the resources defined by framework-res. 313# Even if they don't have their own resources, they may use framework 314# resources. 315ifneq ($(filter-out current system_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current,$(LOCAL_SDK_RES_VERSION))),) 316# for released sdk versions, the platform resources were built into android.jar. 317framework_res_package_export := \ 318 $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar 319framework_res_package_export_deps := $(framework_res_package_export) 320else # LOCAL_SDK_RES_VERSION 321framework_res_package_export := \ 322 $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk 323# We can't depend directly on the export.apk file; it won't get its 324# PRIVATE_ vars set up correctly if we do. Instead, depend on the 325# corresponding R.stamp file, which lists the export.apk as a dependency. 326framework_res_package_export_deps := \ 327 $(dir $(framework_res_package_export))src/R.stamp 328endif # LOCAL_SDK_RES_VERSION 329all_library_res_package_exports := \ 330 $(framework_res_package_export) \ 331 $(foreach lib,$(LOCAL_RES_LIBRARIES),\ 332 $(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk) 333 334all_library_res_package_export_deps := \ 335 $(framework_res_package_export_deps) \ 336 $(foreach lib,$(LOCAL_RES_LIBRARIES),\ 337 $(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp) 338 339$(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_res_package_export_deps) 340$(LOCAL_INTERMEDIATE_TARGETS): \ 341 PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports) 342endif # LOCAL_NO_STANDARD_LIBRARIES 343 344ifneq ($(full_classes_jar),) 345$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex) 346# Use the jarjar processed arhive as the initial package file. 347$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar) 348$(LOCAL_BUILT_MODULE): $(built_dex) 349else 350$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := 351$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := 352endif # full_classes_jar 353 354include $(BUILD_SYSTEM)/install_jni_libs.mk 355 356# Pick a key to sign the package with. If this package hasn't specified 357# an explicit certificate, use the default. 358# Secure release builds will have their packages signed after the fact, 359# so it's ok for these private keys to be in the clear. 360ifeq ($(LOCAL_CERTIFICATE),) 361 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) 362endif 363 364ifeq ($(LOCAL_CERTIFICATE),EXTERNAL) 365 # The special value "EXTERNAL" means that we will sign it with the 366 # default devkey, apply predexopt, but then expect the final .apk 367 # (after dexopting) to be signed by an outside tool. 368 LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) 369 PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1 370endif 371 372# If this is not an absolute certificate, assign it to a generic one. 373ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./) 374 LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE) 375endif 376private_key := $(LOCAL_CERTIFICATE).pk8 377certificate := $(LOCAL_CERTIFICATE).x509.pem 378 379$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR) 380$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key) 381$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate) 382 383PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key) 384PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate) 385 386$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\ 387 $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8) 388 389# Define the rule to build the actual package. 390$(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN) 391# PRIVATE_JNI_SHARED_LIBRARIES is a list of <abi>:<path_of_built_lib>. 392$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis) 393# PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names. 394$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis) 395ifneq ($(TARGET_BUILD_APPS),) 396 # Include all resources for unbundled apps. 397 LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true 398endif 399ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true) 400 $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := 401 $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := 402else 403 $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG) 404ifdef LOCAL_PACKAGE_SPLITS 405 $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := 406else 407 $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG) 408endif 409endif 410$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS) 411$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest) 412 @echo "target Package: $(PRIVATE_MODULE) ($@)" 413ifdef LOCAL_JACK_ENABLED 414 $(create-empty-package) 415else 416 $(if $(PRIVATE_SOURCE_ARCHIVE),\ 417 $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\ 418 $(create-empty-package)) 419endif 420 $(add-assets-to-package) 421ifneq ($(jni_shared_libraries),) 422 $(add-jni-shared-libs-to-package) 423endif 424ifeq ($(full_classes_jar),) 425# We don't build jar, need to add the Java resources here. 426 $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@)) 427else 428 $(add-dex-to-package) 429endif 430ifdef LOCAL_JACK_ENABLED 431 $(add-carried-jack-resources) 432endif 433ifdef LOCAL_DEX_PREOPT 434ifneq (nostripping,$(LOCAL_DEX_PREOPT)) 435 $(call dexpreopt-remove-classes.dex,$@) 436endif 437endif 438 $(sign-package) 439 @# Alignment must happen after all other zip operations. 440 $(align-package) 441 442############################### 443## Build dpi-specific apks, if it's apps_only build. 444ifdef TARGET_BUILD_APPS 445ifdef LOCAL_DPI_VARIANTS 446$(foreach d, $(LOCAL_DPI_VARIANTS), \ 447 $(eval my_dpi := $(d)) \ 448 $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk)) 449endif 450endif 451 452############################### 453## Rule to build the odex file 454ifdef LOCAL_DEX_PREOPT 455$(built_odex): PRIVATE_DEX_FILE := $(built_dex) 456# Use pattern rule - we may have multiple built odex files. 457$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex) 458 $(hide) mkdir -p $(dir $@) && rm -f $@ 459 $(add-dex-to-package) 460 $(hide) mv $@ $@.input 461 $(call dexpreopt-one-file,$@.input,$@) 462 $(hide) rm $@.input 463endif 464 465############################### 466## APK splits 467ifdef LOCAL_PACKAGE_SPLITS 468# LOCAL_PACKAGE_SPLITS is a list of resource labels. 469# aapt will convert comma inside resource lable to underscore in the file names. 470my_split_suffixes := $(subst $(comma),_,$(LOCAL_PACKAGE_SPLITS)) 471built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk) 472installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) 473 474# The splits should have been built in the same command building the base apk. 475# This rule just runs signing and zipalign etc. 476# Note that we explicily check the existence of the split apk and remove the 477# built base apk if the split apk isn't there. 478# That way the build system will rerun the aapt after the user changes the splitting parameters. 479$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key) 480$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate) 481$(built_apk_splits) : $(built_module_path)/%.apk : $(LOCAL_BUILT_MODULE) 482 $(hide) if [ ! -f $@ ]; then \ 483 echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \ 484 rm $<; exit 1; \ 485 fi 486 $(sign-package) 487 $(align-package) 488 489# Rules to install the splits 490$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP) 491 @echo "Install: $@" 492 $(copy-file-to-new-target) 493 494# Register the additional built and installed files. 495ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits) 496ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \ 497 $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk) 498 499# Make sure to install the splits when you run "make <module_name>". 500$(my_register_name): $(installed_apk_splits) 501endif # LOCAL_PACKAGE_SPLITS 502 503# Save information about this package 504PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES)) 505PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources) 506ifdef package_resource_overlays 507PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays) 508endif 509 510PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME) 511 512# Dist the files that can be bundled in system.img. 513# They include the jni shared libraries and the apk with jni libraries stripped. 514ifeq ($(LOCAL_DIST_BUNDLED_BINARIES),true) 515ifneq ($(filter $(LOCAL_PACKAGE_NAME),$(TARGET_BUILD_APPS)),) 516ifneq ($(strip $(jni_shared_libraries)),) 517dist_subdir := bundled_$(LOCAL_PACKAGE_NAME) 518$(foreach f, $(jni_shared_libraries), \ 519 $(call dist-for-goals, apps_only, $(f):$(dist_subdir)/$(notdir $(f)))) 520 521apk_jni_stripped := $(intermediates)/jni_stripped/package.apk 522$(apk_jni_stripped): PRIVATE_JNI_SHARED_LIBRARIES := $(notdir $(jni_shared_libraries)) 523$(apk_jni_stripped) : $(LOCAL_BUILT_MODULE) | $(ZIPALIGN) 524 @rm -rf $(dir $@) && mkdir -p $(dir $@) 525 $(hide) cp $< $@ 526 $(hide) zip -d $@ $(foreach f,$(PRIVATE_JNI_SHARED_LIBRARIES),\*/$(f)) 527 $(align-package) 528 529$(call dist-for-goals, apps_only, $(apk_jni_stripped):$(dist_subdir)/$(LOCAL_PACKAGE_NAME).apk) 530 531endif # jni_shared_libraries 532endif # apps_only build 533endif # LOCAL_DIST_BUNDLED_BINARIES 534 535# Lint phony targets 536.PHONY: lint-$(LOCAL_PACKAGE_NAME) 537lint-$(LOCAL_PACKAGE_NAME): PRIVATE_PATH := $(LOCAL_PATH) 538lint-$(LOCAL_PACKAGE_NAME): PRIVATE_LINT_FLAGS := $(LOCAL_LINT_FLAGS) 539lint-$(LOCAL_PACKAGE_NAME) : 540 @echo lint $(PRIVATE_PATH) 541 $(LINT) $(PRIVATE_LINT_FLAGS) $(PRIVATE_PATH) 542 543lintall : lint-$(LOCAL_PACKAGE_NAME) 544 545endif # skip_definition 546 547# Reset internal variables. 548all_res_assets := 549