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