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# Catch users that directly include base_rules.mk 18$(call record-module-type,base_rules) 19 20# Users can define base-rules-hook in their buildspec.mk to perform 21# arbitrary operations as each module is included. 22ifdef base-rules-hook 23$(if $(base-rules-hook),) 24endif 25 26########################################################### 27## Common instructions for a generic module. 28########################################################### 29 30LOCAL_MODULE := $(strip $(LOCAL_MODULE)) 31ifeq ($(LOCAL_MODULE),) 32 $(error $(LOCAL_PATH): LOCAL_MODULE is not defined) 33endif 34$(call verify-module-name) 35 36LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE)) 37LOCAL_IS_AUX_MODULE := $(strip $(LOCAL_IS_AUX_MODULE)) 38ifdef LOCAL_IS_HOST_MODULE 39 ifneq ($(LOCAL_IS_HOST_MODULE),true) 40 $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)") 41 endif 42 ifeq ($(LOCAL_HOST_PREFIX),) 43 my_prefix := HOST_ 44 else 45 my_prefix := $(LOCAL_HOST_PREFIX) 46 endif 47 my_host := host- 48 my_kind := HOST 49else 50 ifdef LOCAL_IS_AUX_MODULE 51 ifneq ($(LOCAL_IS_AUX_MODULE),true) 52 $(error $(LOCAL_PATH): LOCAL_IS_AUX_MODULE must be "true" or empty, not "$(LOCAL_IS_AUX_MODULE)") 53 endif 54 my_prefix := AUX_ 55 my_kind := AUX 56 else 57 my_prefix := TARGET_ 58 my_kind := 59 endif 60 my_host := 61endif 62 63ifeq ($(my_prefix),HOST_CROSS_) 64 my_host_cross := true 65else 66 my_host_cross := 67endif 68 69ifeq (true, $(LOCAL_PRODUCT_MODULE)) 70ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION))) 71 LOCAL_PRODUCT_MODULE := 72endif 73endif 74 75_path := $(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64) 76ifneq ($(filter $(TARGET_OUT_VENDOR)%,$(_path)),) 77LOCAL_VENDOR_MODULE := true 78else ifneq ($(filter $(TARGET_OUT_OEM)/%,$(_path)),) 79LOCAL_OEM_MODULE := true 80else ifneq ($(filter $(TARGET_OUT_ODM)/%,$(_path)),) 81LOCAL_ODM_MODULE := true 82else ifneq ($(filter $(TARGET_OUT_PRODUCT)/%,$(_path)),) 83LOCAL_PRODUCT_MODULE := true 84else ifneq ($(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(_path)),) 85LOCAL_SYSTEM_EXT_MODULE := true 86endif 87_path := 88 89# TODO(b/135957588) Remove following workaround 90# LOCAL_PRODUCT_SERVICES_MODULE to LOCAL_PRODUCT_MODULE for all Android.mk 91ifndef LOCAL_PRODUCT_MODULE 92LOCAL_PRODUCT_MODULE := $(LOCAL_PRODUCT_SERVICES_MODULE) 93endif 94 95ifndef LOCAL_PROPRIETARY_MODULE 96 LOCAL_PROPRIETARY_MODULE := $(LOCAL_VENDOR_MODULE) 97endif 98ifndef LOCAL_VENDOR_MODULE 99 LOCAL_VENDOR_MODULE := $(LOCAL_PROPRIETARY_MODULE) 100endif 101ifneq ($(filter-out $(LOCAL_PROPRIETARY_MODULE),$(LOCAL_VENDOR_MODULE))$(filter-out $(LOCAL_VENDOR_MODULE),$(LOCAL_PROPRIETARY_MODULE)),) 102$(call pretty-error,Only one of LOCAL_PROPRIETARY_MODULE[$(LOCAL_PROPRIETARY_MODULE)] and LOCAL_VENDOR_MODULE[$(LOCAL_VENDOR_MODULE)] may be set, or they must be equal) 103endif 104 105non_system_module := $(filter true, \ 106 $(LOCAL_PRODUCT_MODULE) \ 107 $(LOCAL_SYSTEM_EXT_MODULE) \ 108 $(LOCAL_VENDOR_MODULE) \ 109 $(LOCAL_PROPRIETARY_MODULE)) 110 111include $(BUILD_SYSTEM)/local_vndk.mk 112include $(BUILD_SYSTEM)/local_systemsdk.mk 113 114my_module_tags := $(LOCAL_MODULE_TAGS) 115ifeq ($(my_host_cross),true) 116 my_module_tags := 117endif 118 119# Ninja has an implicit dependency on the command being run, and kati will 120# regenerate the ninja manifest if any read makefile changes, so there is no 121# need to have dependencies on makefiles. 122# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains 123# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include 124# base_rules.mk, but it will fix the most common ones. 125LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES)) 126 127my_bad_deps := $(strip $(foreach dep,$(filter-out | ||,$(LOCAL_ADDITIONAL_DEPENDENCIES)),\ 128 $(if $(findstring /,$(dep)),,$(dep)))) 129ifneq ($(my_bad_deps),) 130$(call pretty-warning,"Bad LOCAL_ADDITIONAL_DEPENDENCIES: $(my_bad_deps)") 131$(call pretty-error,"LOCAL_ADDITIONAL_DEPENDENCIES must only contain paths (not module names)") 132endif 133 134########################################################### 135## Validate and define fallbacks for input LOCAL_* variables. 136########################################################### 137 138## Dump a .csv file of all modules and their tags 139#ifneq ($(tag-list-first-time),false) 140#$(shell rm -f tag-list.csv) 141#tag-list-first-time := false 142#endif 143#$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(my_module_tags))) >> tag-list.csv) 144 145LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE)) 146my_module_tags := $(sort $(my_module_tags)) 147ifeq (,$(my_module_tags)) 148 my_module_tags := optional 149endif 150 151# User tags are not allowed anymore. Fail early because it will not be installed 152# like it used to be. 153ifneq ($(filter $(my_module_tags),user),) 154 $(warning *** Module name: $(LOCAL_MODULE)) 155 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE)) 156 $(warning * ) 157 $(warning * Module is attempting to use the 'user' tag. This) 158 $(warning * used to cause the module to be installed automatically.) 159 $(warning * Now, the module must be listed in the PRODUCT_PACKAGES) 160 $(warning * section of a product makefile to have it installed.) 161 $(warning * ) 162 $(error user tag detected on module.) 163endif 164 165my_bad_module_tags := $(filter eng debug,$(my_module_tags)) 166ifdef my_bad_module_tags 167 ifeq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 168 $(call pretty-warning,LOCAL_MODULE_TAGS := $(my_bad_module_tags) does not do anything for uninstallable modules) 169 endif 170 $(call pretty-error,LOCAL_MODULE_TAGS := $(my_bad_module_tags) is obsolete. See $(CHANGES_URL)#LOCAL_MODULE_TAGS) 171endif 172 173# Only the tags mentioned in this test are expected to be set by module 174# makefiles. Anything else is either a typo or a source of unexpected 175# behaviors. 176ifneq ($(filter-out tests optional samples,$(my_module_tags)),) 177$(call pretty-error,unusual tags: $(filter-out tests optional samples,$(my_module_tags))) 178endif 179 180# Add implicit tags. 181# 182# If the local directory or one of its parents contains a MODULE_LICENSE_GPL 183# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*" 184# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL 185# 186gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*) 187ifneq ($(gpl_license_file),) 188 my_module_tags += gnu 189 ALL_GPL_MODULE_LICENSE_FILES += $(gpl_license_file) 190endif 191 192LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS)) 193ifneq ($(words $(LOCAL_MODULE_CLASS)),1) 194 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)") 195endif 196 197my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32) 198 199ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 200my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix))) 201ifdef my_multilib_module_path 202my_module_path := $(my_multilib_module_path) 203else 204my_module_path := $(strip $(LOCAL_MODULE_PATH)) 205endif 206my_module_path := $(patsubst %/,%,$(my_module_path)) 207my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH)) 208ifdef LOCAL_IS_HOST_MODULE 209 partition_tag := 210 actual_partition_tag := 211else 212ifeq (true,$(strip $(LOCAL_VENDOR_MODULE))) 213 partition_tag := _VENDOR 214 # A vendor module could be on the vendor partition at "vendor" or the system 215 # partition at "system/vendor". 216 actual_partition_tag := $(if $(filter true,$(BOARD_USES_VENDORIMAGE)),vendor,system) 217else ifeq (true,$(strip $(LOCAL_OEM_MODULE))) 218 partition_tag := _OEM 219 actual_partition_tag := oem 220else ifeq (true,$(strip $(LOCAL_ODM_MODULE))) 221 partition_tag := _ODM 222 # An ODM module could be on the odm partition at "odm", the vendor partition 223 # at "vendor/odm", or the system partition at "system/vendor/odm". 224 actual_partition_tag := $(if $(filter true,$(BOARD_USES_ODMIMAGE)),odm,$(if $(filter true,$(BOARD_USES_VENDORIMAGE)),vendor,system)) 225else ifeq (true,$(strip $(LOCAL_PRODUCT_MODULE))) 226 partition_tag := _PRODUCT 227 # A product module could be on the product partition at "product" or the 228 # system partition at "system/product". 229 actual_partition_tag := $(if $(filter true,$(BOARD_USES_PRODUCTIMAGE)),product,system) 230else ifeq (true,$(strip $(LOCAL_SYSTEM_EXT_MODULE))) 231 partition_tag := _SYSTEM_EXT 232 # A system_ext-specific module could be on the system_ext partition at 233 # "system_ext" or the system partition at "system/system_ext". 234 actual_partition_tag := $(if $(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)),system_ext,system) 235else ifeq (NATIVE_TESTS,$(LOCAL_MODULE_CLASS)) 236 partition_tag := _DATA 237 actual_partition_tag := data 238else 239 # The definition of should-install-to-system will be different depending 240 # on which goal (e.g., sdk or just droid) is being built. 241 partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA) 242 actual_partition_tag := $(if $(partition_tag),data,system) 243endif 244endif 245# For test modules that lack a suite tag, set null-suite as the default. 246# We only support adding a default suite to native tests, native benchmarks, and instrumentation tests. 247# This is because they are the only tests we currently auto-generate test configs for. 248ifndef LOCAL_COMPATIBILITY_SUITE 249 ifneq ($(filter NATIVE_TESTS NATIVE_BENCHMARK, $(LOCAL_MODULE_CLASS)),) 250 LOCAL_COMPATIBILITY_SUITE := null-suite 251 endif 252 ifneq ($(filter APPS, $(LOCAL_MODULE_CLASS)),) 253 ifneq ($(filter $(my_module_tags),tests),) 254 LOCAL_COMPATIBILITY_SUITE := null-suite 255 endif 256 endif 257endif 258 259use_testcase_folder := 260ifeq ($(my_module_path),) 261 ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(DEFAULT_DATA_OUT_MODULES))) 262 ifdef LOCAL_COMPATIBILITY_SUITE 263 ifneq (true, $(LOCAL_IS_HOST_MODULE)) 264 use_testcase_folder := true 265 endif 266 endif 267 endif 268endif 269 270ifeq ($(my_module_path),) 271 install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS) 272 ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) 273 install_path_var := $(install_path_var)_PRIVILEGED 274 endif 275 276 my_module_path := $($(install_path_var)) 277 278 # If use_testcase_folder be set, and LOCAL_MODULE_PATH not set, 279 # overwrite the default path under testcase. 280 ifeq ($(use_testcase_folder),true) 281 arch_dir := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 282 testcase_folder := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)/$(arch_dir) 283 my_module_path := $(testcase_folder) 284 arch_dir := 285 endif 286 287 ifeq ($(strip $(my_module_path)),) 288 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)") 289 endif 290endif 291ifneq ($(my_module_relative_path),) 292 my_module_path := $(my_module_path)/$(my_module_relative_path) 293endif 294endif # not LOCAL_UNINSTALLABLE_MODULE 295 296ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),) 297 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles) 298endif 299 300my_register_name := $(LOCAL_MODULE) 301ifeq ($(my_host_cross),true) 302 my_register_name := host_cross_$(LOCAL_MODULE) 303endif 304ifdef LOCAL_2ND_ARCH_VAR_PREFIX 305ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX 306my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX) 307endif 308endif 309 310ifeq ($(my_host_cross),true) 311 my_all_targets := host_cross_$(my_register_name)_all_targets 312else ifneq ($(LOCAL_IS_HOST_MODULE),) 313 my_all_targets := host_$(my_register_name)_all_targets 314else 315 my_all_targets := device_$(my_register_name)_all_targets 316endif 317 318# variant is enough to make nano class unique; it serves as a key to lookup (OS,ARCH) tuple 319aux_class := $($(my_prefix)OS_VARIANT) 320# Make sure that this IS_HOST/CLASS/MODULE combination is unique. 321module_id := MODULE.$(if \ 322 $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),$(if \ 323 $(LOCAL_IS_AUX_MODULE),$(aux_class),TARGET)).$(LOCAL_MODULE_CLASS).$(my_register_name) 324ifdef $(module_id) 325$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id))) 326endif 327$(module_id) := $(LOCAL_PATH) 328 329# These are the same as local-intermediates-dir / local-generated-sources dir, but faster 330intermediates.COMMON := $($(my_prefix)OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates 331ifneq (,$(filter $(my_prefix)$(LOCAL_MODULE_CLASS),$(COMMON_MODULE_CLASSES))) 332 intermediates := $($(my_prefix)OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates 333 generated_sources_dir := $($(my_prefix)OUT_COMMON_GEN)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates 334else 335 ifneq (,$(filter $(LOCAL_MODULE_CLASS),$(PER_ARCH_MODULE_CLASSES))) 336 intermediates := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates 337 else 338 intermediates := $($(my_prefix)OUT_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates 339 endif 340 generated_sources_dir := $($(my_prefix)OUT_GEN)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates 341endif 342 343ifneq ($(LOCAL_OVERRIDES_MODULES),) 344 ifndef LOCAL_IS_HOST_MODULE 345 ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) 346 EXECUTABLES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES)) 347 else ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) 348 SHARED_LIBRARIES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES)) 349 else ifeq ($(LOCAL_MODULE_CLASS),ETC) 350 ETC.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES)) 351 else 352 $(call pretty-error,LOCAL_MODULE_CLASS := $(LOCAL_MODULE_CLASS) cannot use LOCAL_OVERRIDES_MODULES) 353 endif 354 else 355 $(call pretty-error,host modules cannot use LOCAL_OVERRIDES_MODULES) 356 endif 357endif 358 359########################################################### 360# Pick a name for the intermediate and final targets 361########################################################### 362include $(BUILD_SYSTEM)/configure_module_stem.mk 363 364LOCAL_BUILT_MODULE := $(intermediates)/$(my_built_module_stem) 365 366ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 367 # Apk and its attachments reside in its own subdir. 368 ifeq ($(LOCAL_MODULE_CLASS),APPS) 369 # framework-res.apk doesn't like the additional layer. 370 ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 371 # Neither do Runtime Resource Overlay apks, which contain just the overlaid resources. 372 else ifeq ($(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY),true) 373 else 374 ifneq ($(use_testcase_folder),true) 375 my_module_path := $(my_module_path)/$(LOCAL_MODULE) 376 endif 377 endif 378 endif 379 LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem) 380endif 381 382# Assemble the list of targets to create PRIVATE_ variables for. 383LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE) 384 385########################################################### 386## Create .toc files from shared objects to reduce unnecessary rebuild 387# .toc files have the list of external dynamic symbols without their addresses. 388# As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used, 389# dependent binaries of a .toc file will be rebuilt only when the content of 390# the .toc file is changed. 391# 392# Don't create .toc files for Soong shared libraries, that is handled in 393# Soong and soong_cc_prebuilt.mk 394########################################################### 395ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 396ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) 397LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc 398$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE) 399 $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp) 400 $(call commit-change-for-toc,$@) 401 402# Kati adds restat=1 to ninja. GNU make does nothing for this. 403.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc 404# Build .toc file when using mm, mma, or make $(my_register_name) 405$(my_all_targets): $(LOCAL_BUILT_MODULE).toc 406endif 407endif 408 409########################################################### 410## logtags: Add .logtags files to global list 411########################################################### 412 413logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES) 414 415ifneq ($(strip $(logtags_sources)),) 416event_log_tags := $(foreach f,$(addprefix $(LOCAL_PATH)/,$(logtags_sources)),$(call clean-path,$(f))) 417else 418event_log_tags := 419endif 420 421########################################################### 422## make clean- targets 423########################################################### 424cleantarget := clean-$(my_register_name) 425.PHONY: $(cleantarget) 426$(cleantarget) : PRIVATE_MODULE := $(my_register_name) 427$(cleantarget) : PRIVATE_CLEAN_FILES := \ 428 $(LOCAL_BUILT_MODULE) \ 429 $(LOCAL_INSTALLED_MODULE) \ 430 $(intermediates) 431$(cleantarget):: 432 @echo "Clean: $(PRIVATE_MODULE)" 433 $(hide) rm -rf $(PRIVATE_CLEAN_FILES) 434 435########################################################### 436## Common definitions for module. 437########################################################### 438$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH) 439$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE) 440$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_AUX_MODULE := $(LOCAL_IS_AUX_MODULE) 441$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host) 442$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix) 443 444$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates) 445$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) 446 447# Tell the module and all of its sub-modules who it is. 448$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name) 449 450# Provide a short-hand for building this module. 451# We name both BUILT and INSTALLED in case 452# LOCAL_UNINSTALLABLE_MODULE is set. 453.PHONY: $(my_all_targets) 454$(my_all_targets): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE) $(LOCAL_ADDITIONAL_CHECKED_MODULE) 455 456.PHONY: $(my_register_name) 457$(my_register_name): $(my_all_targets) 458 459ifneq ($(my_register_name),$(LOCAL_MODULE)) 460# $(LOCAL_MODULE) covers all the multilib targets. 461.PHONY: $(LOCAL_MODULE) 462$(LOCAL_MODULE) : $(my_all_targets) 463endif 464 465# Set up phony targets that covers all modules under the given paths. 466# This allows us to build everything in given paths by running mmma/mma. 467my_path_components := $(subst /,$(space),$(LOCAL_PATH)) 468my_path_prefix := MODULES-IN 469$(foreach c, $(my_path_components),\ 470 $(eval my_path_prefix := $(my_path_prefix)-$(c))\ 471 $(eval .PHONY : $(my_path_prefix))\ 472 $(eval $(my_path_prefix) : $(my_all_targets))) 473 474########################################################### 475## Module installation rule 476########################################################### 477 478my_init_rc_installed := 479my_init_rc_pairs := 480my_installed_symlinks := 481my_default_test_module := 482ifeq ($(use_testcase_folder),true) 483arch_dir := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 484my_default_test_module := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)/$(arch_dir)/$(my_installed_module_stem) 485arch_dir := 486endif 487 488ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 489ifneq ($(LOCAL_INSTALLED_MODULE),$(my_default_test_module)) 490$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) 491$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) 492 @echo "Install: $@" 493 $(copy-file-to-new-target) 494 $(PRIVATE_POST_INSTALL_CMD) 495endif 496 497ifndef LOCAL_IS_HOST_MODULE 498# Rule to install the module's companion init.rc. 499my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC) 500ifneq ($(strip $(my_init_rc)),) 501my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(LOCAL_PATH)/$(rc):$(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(rc))) 502my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc))) 503 504# Make sure we only set up the copy rules once, even if another arch variant 505# shares a common LOCAL_INIT_RC. 506my_init_rc_new_pairs := $(filter-out $(ALL_INIT_RC_INSTALLED_PAIRS),$(my_init_rc_pairs)) 507my_init_rc_new_installed := $(call copy-many-init-script-files-checked,$(my_init_rc_new_pairs)) 508ALL_INIT_RC_INSTALLED_PAIRS += $(my_init_rc_new_pairs) 509 510$(my_all_targets) : $(my_init_rc_installed) 511endif # my_init_rc 512endif # !LOCAL_IS_HOST_MODULE 513 514# Rule to install the module's companion symlinks 515my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix))) 516$(foreach symlink,$(my_installed_symlinks),\ 517 $(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink))) 518 519$(my_all_targets) : | $(my_installed_symlinks) 520 521endif # !LOCAL_UNINSTALLABLE_MODULE 522 523########################################################### 524## VINTF manifest fragment goals 525########################################################### 526 527my_vintf_installed:= 528my_vintf_pairs:= 529ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 530ifndef LOCAL_IS_HOST_MODULE 531ifneq ($(strip $(LOCAL_VINTF_FRAGMENTS)),) 532 533my_vintf_pairs := $(foreach xml,$(LOCAL_VINTF_FRAGMENTS),$(LOCAL_PATH)/$(xml):$(TARGET_OUT$(partition_tag)_ETC)/vintf/manifest/$(notdir $(xml))) 534my_vintf_installed := $(foreach xml,$(my_vintf_pairs),$(call word-colon,2,$(xml))) 535 536# Only set up copy rules once, even if another arch variant shares it 537my_vintf_new_pairs := $(filter-out $(ALL_VINTF_MANIFEST_FRAGMENTS_LIST),$(my_vintf_pairs)) 538my_vintf_new_installed := $(call copy-many-vintf-manifest-files-checked,$(my_vintf_new_pairs)) 539 540ALL_VINTF_MANIFEST_FRAGMENTS_LIST += $(my_vintf_new_pairs) 541 542$(my_all_targets) : $(my_vintf_new_installed) 543endif # LOCAL_VINTF_FRAGMENTS 544endif # !LOCAL_IS_HOST_MODULE 545endif # !LOCAL_UNINSTALLABLE_MODULE 546 547########################################################### 548## CHECK_BUILD goals 549########################################################### 550my_checked_module := 551# If nobody has defined a more specific module for the 552# checked modules, use LOCAL_BUILT_MODULE. 553ifdef LOCAL_CHECKED_MODULE 554 my_checked_module := $(LOCAL_CHECKED_MODULE) 555else 556 my_checked_module := $(LOCAL_BUILT_MODULE) 557endif 558 559my_checked_module += $(LOCAL_ADDITIONAL_CHECKED_MODULE) 560 561# If they request that this module not be checked, then don't. 562# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT 563# GOOD REASON WILL HAVE IT REMOVED. 564ifdef LOCAL_DONT_CHECK_MODULE 565 my_checked_module := 566endif 567# Don't check build target module defined for the 2nd arch 568ifndef LOCAL_IS_HOST_MODULE 569ifdef LOCAL_2ND_ARCH_VAR_PREFIX 570 my_checked_module := 571endif 572endif 573 574########################################################### 575## Test Data 576########################################################### 577my_test_data_pairs := 578my_installed_test_data := 579# Source to relative dst file paths for reuse in LOCAL_COMPATIBILITY_SUITE. 580my_test_data_file_pairs := 581 582ifneq ($(strip $(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)) $(LOCAL_IS_FUZZ_TARGET)),) 583ifneq ($(strip $(LOCAL_TEST_DATA)),) 584ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 585 586ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 587 define copy_test_data_pairs 588 _src_base := $$(call word-colon,1,$$(td)) 589 _file := $$(call word-colon,2,$$(td)) 590 my_test_data_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(call append-path,$$(my_module_path),$$(_file)) 591 my_test_data_file_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(_file) 592 endef 593else 594 define copy_test_data_pairs 595 _src_base := $$(call word-colon,1,$$(td)) 596 _file := $$(call word-colon,2,$$(td)) 597 ifndef _file 598 _file := $$(_src_base) 599 _src_base := $$(LOCAL_PATH) 600 endif 601 ifneq (,$$(findstring ..,$$(_file))) 602 $$(call pretty-error,LOCAL_TEST_DATA may not include '..': $$(_file)) 603 endif 604 ifneq (,$$(filter/%,$$(_src_base) $$(_file))) 605 $$(call pretty-error,LOCAL_TEST_DATA may not include absolute paths: $$(_src_base) $$(_file)) 606 endif 607 my_test_data_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(call append-path,$$(my_module_path),$$(_file)) 608 my_test_data_file_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(_file) 609 endef 610endif 611 612$(foreach td,$(LOCAL_TEST_DATA),$(eval $(copy_test_data_pairs))) 613 614copy_test_data_pairs := 615 616my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs)) 617$(LOCAL_INSTALLED_MODULE): $(my_installed_test_data) 618 619endif 620endif 621endif 622 623########################################################### 624## Compatibility suite files. 625########################################################### 626ifdef LOCAL_COMPATIBILITY_SUITE 627ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 628 629# If we are building a native test or benchmark and its stem variants are not defined, 630# separate the multiple architectures into subdirectories of the testcase folder. 631arch_dir := 632is_native := 633multi_arch := 634ifeq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) 635 is_native := true 636 multi_arch := true 637endif 638ifdef LOCAL_MULTILIB 639 multi_arch := true 640endif 641 642ifdef multi_arch 643arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 644else 645ifeq ($(use_testcase_folder),true) 646 arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) 647endif 648endif 649 650multi_arch := 651 652my_default_test_module := 653my_default_test_module := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)$(arch_dir)/$(my_installed_module_stem) 654ifneq ($(LOCAL_INSTALLED_MODULE),$(my_default_test_module)) 655# Install into the testcase folder 656$(LOCAL_INSTALLED_MODULE) : $(my_default_test_module) 657endif 658 659# The module itself. 660$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 661 $(eval my_compat_dist_$(suite) := $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \ 662 $(LOCAL_BUILT_MODULE):$(dir)/$(my_installed_module_stem))) \ 663 $(eval my_compat_dist_config_$(suite) := )) 664 665 666# Auto-generate build config. 667ifneq (,$(LOCAL_FULL_TEST_CONFIG)) 668 test_config := $(LOCAL_FULL_TEST_CONFIG) 669else ifneq (,$(LOCAL_TEST_CONFIG)) 670 test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG) 671else 672 test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml) 673endif 674ifeq (,$(test_config)) 675 ifneq (true,$(is_native)) 676 is_instrumentation_test := true 677 ifeq (true, $(LOCAL_IS_HOST_MODULE)) 678 is_instrumentation_test := false 679 endif 680 # If LOCAL_MODULE_CLASS is not APPS, it's certainly not an instrumentation 681 # test. However, some packages for test data also have LOCAL_MODULE_CLASS 682 # set to APPS. These will require flag LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG 683 # to disable auto-generating test config file. 684 ifneq (APPS, $(LOCAL_MODULE_CLASS)) 685 is_instrumentation_test := false 686 endif 687 endif 688 # CTS modules can be used for test data, so test config files must be 689 # explicitly created using AndroidTest.xml 690 ifeq (,$(filter cts, $(LOCAL_COMPATIBILITY_SUITE))) 691 ifneq (true, $(LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG)) 692 ifeq (true, $(filter true,$(is_native) $(is_instrumentation_test))) 693 include $(BUILD_SYSTEM)/autogen_test_config.mk 694 test_config := $(autogen_test_config_file) 695 autogen_test_config_file := 696 endif 697 endif 698 endif 699endif 700is_instrumentation_test := 701 702# Make sure we only add the files once for multilib modules. 703ifdef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files 704 # Sync the auto_test_config value for multilib modules. 705 ifdef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_autogen 706 ALL_MODULES.$(my_register_name).auto_test_config := true 707 endif 708else 709 $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true 710 # LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of <src>[:<dest>]. 711 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 712 $(eval my_compat_dist_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \ 713 $(eval p := $(subst :,$(space),$(f))) \ 714 $(eval s := $(word 1,$(p))) \ 715 $(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \ 716 $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ 717 $(s):$(dir)/$(n))))) 718 719 ifneq (,$(test_config)) 720 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 721 $(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ 722 $(test_config):$(dir)/$(LOCAL_MODULE).config))) 723 endif 724 725 ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml)) 726 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 727 $(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ 728 $(LOCAL_PATH)/DynamicConfig.xml:$(dir)/$(LOCAL_MODULE).dynamic))) 729 endif 730 731 ifneq (,$(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE)_*.config)) 732 $(foreach extra_config, $(wildcard $(LOCAL_PATH)/$(LOCAL_MODULE)_*.config), \ 733 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 734 $(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \ 735 $(extra_config):$(dir)/$(notdir $(extra_config)))))) 736 endif 737endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files 738 739# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by setting the flag in 740# module-info.json 741# TODO: (b/113029686) Add explicit flag from Soong to determine if a test was 742# autogenerated. 743ifneq (,$(filter $(SOONG_OUT_DIR)%,$(LOCAL_FULL_TEST_CONFIG))) 744 ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 745 ALL_MODULES.$(my_register_name).auto_test_config := true 746 endif 747endif 748 749 750ifeq ($(use_testcase_folder),true) 751ifneq ($(my_test_data_file_pairs),) 752$(foreach pair, $(my_test_data_file_pairs), \ 753 $(eval parts := $(subst :,$(space),$(pair))) \ 754 $(eval src_path := $(word 1,$(parts))) \ 755 $(eval file := $(word 2,$(parts))) \ 756 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 757 $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \ 758 $(call filter-copy-pair,$(src_path),$(call append-path,$(dir),$(file)),$(my_installed_test_data)))))) 759endif 760else 761ifneq ($(my_test_data_file_pairs),) 762$(foreach pair, $(my_test_data_file_pairs), \ 763 $(eval parts := $(subst :,$(space),$(pair))) \ 764 $(eval src_path := $(word 1,$(parts))) \ 765 $(eval file := $(word 2,$(parts))) \ 766 $(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 767 $(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \ 768 $(src_path):$(call append-path,$(dir),$(file)))))) 769endif 770endif 771 772 773 774arch_dir := 775is_native := 776 777$(call create-suite-dependencies) 778$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \ 779 $(eval my_compat_dist_config_$(suite) := )) 780 781endif # LOCAL_UNINSTALLABLE_MODULE 782endif # LOCAL_COMPATIBILITY_SUITE 783 784########################################################### 785## Add test module to ALL_DISABLED_PRESUBMIT_TESTS if LOCAL_PRESUBMIT_DISABLED is set to true. 786########################################################### 787ifeq ($(LOCAL_PRESUBMIT_DISABLED),true) 788 ALL_DISABLED_PRESUBMIT_TESTS += $(LOCAL_MODULE) 789endif # LOCAL_PRESUBMIT_DISABLED 790 791########################################################### 792## Register with ALL_MODULES 793########################################################### 794 795ifndef ALL_MODULES.$(my_register_name).PATH 796 # These keys are no longer used, they've been replaced by keys that specify 797 # target/host/host_cross (REQUIRED_FROM_TARGET / REQUIRED_FROM_HOST) and similar. 798 # 799 # Marking them obsolete to ensure that anyone using these internal variables looks for 800 # alternates. 801 $(KATI_obsolete_var ALL_MODULES.$(my_register_name).REQUIRED) 802 $(KATI_obsolete_var ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED) 803 $(KATI_obsolete_var ALL_MODULES.$(my_register_name).HOST_REQUIRED) 804 $(KATI_obsolete_var ALL_MODULES.$(my_register_name).TARGET_REQUIRED) 805endif 806 807ALL_MODULES += $(my_register_name) 808 809# Don't use += on subvars, or else they'll end up being 810# recursively expanded. 811ALL_MODULES.$(my_register_name).CLASS := \ 812 $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS) 813ALL_MODULES.$(my_register_name).PATH := \ 814 $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH) 815ALL_MODULES.$(my_register_name).TAGS := \ 816 $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags) 817ALL_MODULES.$(my_register_name).CHECKED := \ 818 $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module) 819ALL_MODULES.$(my_register_name).BUILT := \ 820 $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE) 821ifndef LOCAL_IS_HOST_MODULE 822ALL_MODULES.$(my_register_name).TARGET_BUILT := \ 823 $(ALL_MODULES.$(my_register_name).TARGET_BUILT) $(LOCAL_BUILT_MODULE) 824endif 825ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 826ALL_MODULES.$(my_register_name).INSTALLED := \ 827 $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \ 828 $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed) $(my_installed_symlinks) \ 829 $(my_installed_test_data) $(my_vintf_installed)) 830ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \ 831 $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \ 832 $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \ 833 $(my_init_rc_pairs) $(my_test_data_pairs) $(my_vintf_pairs)) 834endif 835ifdef LOCAL_PICKUP_FILES 836# Files or directories ready to pick up by the build system 837# when $(LOCAL_BUILT_MODULE) is done. 838ALL_MODULES.$(my_register_name).PICKUP_FILES := \ 839 $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES) 840endif 841# Record the platform availability of this module. Note that the availability is not 842# meaningful for non-installable modules (e.g., static libs) or host modules. 843# We only care about modules that are installable to the device. 844ifeq (true,$(LOCAL_NOT_AVAILABLE_FOR_PLATFORM)) 845 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 846 ifndef LOCAL_IS_HOST_MODULE 847 ALL_MODULES.$(my_register_name).NOT_AVAILABLE_FOR_PLATFORM := true 848 endif 849 endif 850endif 851 852my_required_modules := $(LOCAL_REQUIRED_MODULES) \ 853 $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) 854ifdef LOCAL_IS_HOST_MODULE 855my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS)) 856endif 857 858########################################################################## 859## When compiling against the VNDK, add the .vendor or .product suffix to 860## required modules. 861########################################################################## 862ifneq ($(LOCAL_USE_VNDK),) 863 ##################################################### 864 ## Soong modules may be built three times, once for 865 ## /system, once for /vendor and once for /product. 866 ## If we're using the VNDK, switch all soong 867 ## libraries over to the /vendor or /product variant. 868 ##################################################### 869 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 870 # We don't do this renaming for soong-defined modules since they already 871 # have correct names (with .vendor or .product suffix when necessary) in 872 # their LOCAL_*_LIBRARIES. 873 ifeq ($(LOCAL_USE_VNDK_PRODUCT),true) 874 my_required_modules := $(foreach l,$(my_required_modules),\ 875 $(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l))) 876 else 877 my_required_modules := $(foreach l,$(my_required_modules),\ 878 $(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l))) 879 endif 880 endif 881endif 882 883ifdef LOCAL_IS_HOST_MODULE 884 ifneq ($(my_host_cross),true) 885 ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST := \ 886 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST) $(my_required_modules)) 887 ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST := \ 888 $(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST)\ 889 $(my_required_modules)) 890 ALL_MODULES.$(my_register_name).TARGET_REQUIRED_FROM_HOST := \ 891 $(strip $(ALL_MODULES.$(my_register_name).TARGET_REQUIRED_FROM_HOST)\ 892 $(LOCAL_TARGET_REQUIRED_MODULES)) 893 else 894 ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST_CROSS := \ 895 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST_CROSS) $(my_required_modules)) 896 ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST_CROSS := \ 897 $(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST_CROSS)\ 898 $(my_required_modules)) 899 ifdef LOCAL_TARGET_REQUIRED_MODULES 900 $(call pretty-error,LOCAL_TARGET_REQUIRED_MODULES may not be used from host_cross modules) 901 endif 902 endif 903 ifdef LOCAL_HOST_REQUIRED_MODULES 904 $(call pretty-error,LOCAL_HOST_REQUIRED_MODULES may not be used from host modules. Use LOCAL_REQUIRED_MODULES instead) 905 endif 906else 907 ALL_MODULES.$(my_register_name).REQUIRED_FROM_TARGET := \ 908 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED_FROM_TARGET) $(my_required_modules)) 909 ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_TARGET := \ 910 $(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_TARGET)\ 911 $(my_required_modules)) 912 ALL_MODULES.$(my_register_name).HOST_REQUIRED_FROM_TARGET := \ 913 $(strip $(ALL_MODULES.$(my_register_name).HOST_REQUIRED_FROM_TARGET)\ 914 $(LOCAL_HOST_REQUIRED_MODULES)) 915 ifdef LOCAL_TARGET_REQUIRED_MODULES 916 $(call pretty-error,LOCAL_TARGET_REQUIRED_MODULES may not be used from target modules. Use LOCAL_REQUIRED_MODULES instead) 917 endif 918endif 919ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \ 920 $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags) 921ALL_MODULES.$(my_register_name).MAKEFILE := \ 922 $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE) 923ifdef LOCAL_MODULE_OWNER 924ALL_MODULES.$(my_register_name).OWNER := \ 925 $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER)) 926endif 927ifdef LOCAL_2ND_ARCH_VAR_PREFIX 928ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true 929endif 930ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross) 931ALL_MODULES.$(my_register_name).MODULE_NAME := $(LOCAL_MODULE) 932ALL_MODULES.$(my_register_name).COMPATIBILITY_SUITES := $(LOCAL_COMPATIBILITY_SUITE) 933ALL_MODULES.$(my_register_name).TEST_CONFIG := $(test_config) 934test_config := 935 936INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name) 937 938########################################################## 939# Track module-level dependencies. 940# Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness. 941ifneq (,$(filter deps-license,$(MAKECMDGOALS))) 942ALL_DEPS.MODULES += $(LOCAL_MODULE) 943ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \ 944 $(ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS) \ 945 $(LOCAL_STATIC_LIBRARIES) \ 946 $(LOCAL_WHOLE_STATIC_LIBRARIES) \ 947 $(LOCAL_SHARED_LIBRARIES) \ 948 $(LOCAL_DYLIB_LIBRARIES) \ 949 $(LOCAL_RLIB_LIBRARIES) \ 950 $(LOCAL_PROC_MACRO_LIBRARIES) \ 951 $(LOCAL_HEADER_LIBRARIES) \ 952 $(LOCAL_STATIC_JAVA_LIBRARIES) \ 953 $(LOCAL_JAVA_LIBRARIES) \ 954 $(LOCAL_JNI_SHARED_LIBRARIES)) 955 956license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*) 957ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files)) 958endif 959 960########################################################### 961## Take care of my_module_tags 962########################################################### 963 964# Keep track of all the tags we've seen. 965ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags)) 966 967# Add this module name to the tag list of each specified tag. 968$(foreach tag,$(filter-out optional,$(my_module_tags)),\ 969 $(eval ALL_MODULE_NAME_TAGS.$(tag) := $$(ALL_MODULE_NAME_TAGS.$(tag)) $(my_register_name))) 970 971########################################################### 972## umbrella targets used to verify builds 973########################################################### 974j_or_n := 975ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES HEADER_LIBRARIES NATIVE_TESTS RLIB_LIBRARIES DYLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS))) 976j_or_n := native 977else 978ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS))) 979j_or_n := java 980endif 981endif 982ifdef LOCAL_IS_HOST_MODULE 983h_or_t := host 984ifeq ($(my_host_cross),true) 985h_or_hc_or_t := host-cross 986else 987h_or_hc_or_t := host 988endif 989else 990h_or_hc_or_t := target 991h_or_t := target 992endif 993 994 995ifdef j_or_n 996$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_hc_or_t) : $(my_checked_module) 997ifneq (,$(filter $(my_module_tags),tests)) 998$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module) 999endif 1000$(LOCAL_MODULE)-$(h_or_hc_or_t) : $(my_all_targets) 1001.PHONY: $(LOCAL_MODULE)-$(h_or_hc_or_t) 1002ifeq ($(j_or_n),native) 1003$(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets) 1004.PHONY: $(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) 1005endif 1006endif 1007 1008########################################################### 1009# Ensure privileged applications always have LOCAL_PRIVILEGED_MODULE 1010########################################################### 1011ifndef LOCAL_PRIVILEGED_MODULE 1012 ifneq (,$(filter $(TARGET_OUT_APPS_PRIVILEGED)/% $(TARGET_OUT_VENDOR_APPS_PRIVILEGED)/%,$(my_module_path))) 1013 LOCAL_PRIVILEGED_MODULE := true 1014 endif 1015endif 1016 1017########################################################### 1018## NOTICE files 1019########################################################### 1020 1021include $(BUILD_NOTICE_FILE) 1022