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# Users can define base-rules-hook in their buildspec.mk to perform 18# arbitrary operations as each module is included. 19ifdef base-rules-hook 20$(if $(base-rules-hook),) 21endif 22 23########################################################### 24## Common instructions for a generic module. 25########################################################### 26 27LOCAL_MODULE := $(strip $(LOCAL_MODULE)) 28ifeq ($(LOCAL_MODULE),) 29 $(error $(LOCAL_PATH): LOCAL_MODULE is not defined) 30endif 31 32LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE)) 33ifdef LOCAL_IS_HOST_MODULE 34 ifneq ($(LOCAL_IS_HOST_MODULE),true) 35 $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)") 36 endif 37 my_prefix := HOST_ 38 my_host := host- 39else 40 my_prefix := TARGET_ 41 my_host := 42endif 43 44my_module_tags := $(LOCAL_MODULE_TAGS) 45 46########################################################### 47## Validate and define fallbacks for input LOCAL_* variables. 48########################################################### 49 50## Dump a .csv file of all modules and their tags 51#ifneq ($(tag-list-first-time),false) 52#$(shell rm -f tag-list.csv) 53#tag-list-first-time := false 54#endif 55#$(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) 56 57LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE)) 58my_module_tags := $(sort $(my_module_tags)) 59ifeq (,$(my_module_tags)) 60 my_module_tags := optional 61endif 62 63# User tags are not allowed anymore. Fail early because it will not be installed 64# like it used to be. 65ifneq ($(filter $(my_module_tags),user),) 66 $(warning *** Module name: $(LOCAL_MODULE)) 67 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE)) 68 $(warning * ) 69 $(warning * Module is attempting to use the 'user' tag. This) 70 $(warning * used to cause the module to be installed automatically.) 71 $(warning * Now, the module must be listed in the PRODUCT_PACKAGES) 72 $(warning * section of a product makefile to have it installed.) 73 $(warning * ) 74 $(error user tag detected on module.) 75endif 76 77# Only the tags mentioned in this test are expected to be set by module 78# makefiles. Anything else is either a typo or a source of unexpected 79# behaviors. 80ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),) 81$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH)) 82endif 83 84# Add implicit tags. 85# 86# If the local directory or one of its parents contains a MODULE_LICENSE_GPL 87# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*" 88# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL 89# 90license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*) 91gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*) 92ifneq ($(gpl_license_file),) 93 my_module_tags += gnu 94 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file)) 95endif 96 97LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS)) 98ifneq ($(words $(LOCAL_MODULE_CLASS)),1) 99 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)") 100endif 101 102my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32) 103 104ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 105my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix))) 106ifdef my_multilib_module_path 107my_module_path := $(my_multilib_module_path) 108else 109my_module_path := $(strip $(LOCAL_MODULE_PATH)) 110endif 111my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH)) 112ifeq ($(my_module_path),) 113 ifdef LOCAL_IS_HOST_MODULE 114 partition_tag := 115 else 116 ifeq (true,$(LOCAL_PROPRIETARY_MODULE)) 117 partition_tag := _VENDOR 118 else ifeq (true,$(LOCAL_OEM_MODULE)) 119 partition_tag := _OEM 120 else ifeq (true,$(LOCAL_ODM_MODULE)) 121 partition_tag := _ODM 122 else 123 # The definition of should-install-to-system will be different depending 124 # on which goal (e.g., sdk or just droid) is being built. 125 partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA) 126 endif 127 endif 128 install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS) 129 ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) 130 install_path_var := $(install_path_var)_PRIVILEGED 131 endif 132 133 my_module_path := $($(install_path_var)) 134 ifeq ($(strip $(my_module_path)),) 135 $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)") 136 endif 137endif 138ifneq ($(my_module_relative_path),) 139 my_module_path := $(my_module_path)/$(my_module_relative_path) 140endif 141endif # not LOCAL_UNINSTALLABLE_MODULE 142 143ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),) 144 $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles) 145endif 146 147my_register_name := $(LOCAL_MODULE) 148ifdef LOCAL_2ND_ARCH_VAR_PREFIX 149ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX 150my_register_name := $(LOCAL_MODULE)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX) 151endif 152endif 153# Make sure that this IS_HOST/CLASS/MODULE combination is unique. 154module_id := MODULE.$(if \ 155 $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name) 156ifdef $(module_id) 157$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id))) 158endif 159$(module_id) := $(LOCAL_PATH) 160 161intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX)) 162intermediates.COMMON := $(call local-intermediates-dir,COMMON) 163generated_sources_dir := $(call local-generated-sources-dir) 164 165########################################################### 166# Pick a name for the intermediate and final targets 167########################################################### 168include $(BUILD_SYSTEM)/configure_module_stem.mk 169 170# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the 171# internal SHARED_LIBRARIES build files. 172OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH)) 173ifdef OVERRIDE_BUILT_MODULE_PATH 174 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) 175 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) 176 endif 177 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH) 178else 179 built_module_path := $(intermediates) 180endif 181LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem) 182 183ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 184 # Apk and its attachments reside in its own subdir. 185 ifeq ($(LOCAL_MODULE_CLASS),APPS) 186 # framework-res.apk doesn't like the additional layer. 187 ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 188 my_module_path := $(my_module_path)/$(LOCAL_MODULE) 189 endif 190 endif 191 LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem) 192endif 193 194# Assemble the list of targets to create PRIVATE_ variables for. 195LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE) 196 197 198########################################################### 199## AIDL: Compile .aidl files to .java 200########################################################### 201 202aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES)) 203 204ifneq ($(strip $(aidl_sources)),) 205 206aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources))) 207aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources)) 208 209aidl_preprocess_import := 210LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION)) 211ifdef LOCAL_SDK_VERSION 212ifneq ($(filter current system_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),) 213 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS 214 aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl 215else 216 aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl 217endif # not current or system_current 218else 219# build against the platform. 220LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS) 221endif # LOCAL_SDK_VERSION 222$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) 223 224$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \ 225 $(TOPDIR)$(LOCAL_PATH)/%.aidl \ 226 $(LOCAL_MODULE_MAKEFILE) \ 227 $(LOCAL_ADDITIONAL_DEPENDENCIES) \ 228 $(AIDL) \ 229 $(aidl_preprocess_import) 230 $(transform-aidl-to-java) 231-include $(aidl_java_sources:%.java=%.P) 232 233else 234aidl_java_sources := 235endif 236 237########################################################### 238## logtags: Add .logtags files to global list, emit java source 239########################################################### 240 241logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) 242 243ifneq ($(strip $(logtags_sources)),) 244 245event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources)) 246 247# Emit a java source file with constants for the tags, if 248# LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES". 249ifneq ($(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES),) 250 251logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources))) 252logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources)) 253 254$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt 255 $(transform-logtags-to-java) 256 257endif 258 259else 260logtags_java_sources := 261event_log_tags := 262endif 263 264########################################################### 265## .proto files: Compile proto files to .java 266########################################################### 267proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) 268# Because names of the .java files compiled from .proto files are unknown until the 269# .proto files are compiled, we use a timestamp file as depedency. 270proto_java_sources_file_stamp := 271ifneq ($(proto_sources),) 272proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources)) 273# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be 274# automatically found by the java compiling function transform-java-to-classes.jar. 275ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),) 276proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto 277else 278# LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules. 279proto_java_intemediate_dir := $(intermediates)/proto 280endif 281proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp 282proto_java_sources_dir := $(proto_java_intemediate_dir)/src 283 284$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP) 285$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath) 286$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir) 287ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) 288$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out 289else 290 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) 291$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out 292 else 293$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out 294 endif 295endif 296$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) 297$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS) 298$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC) 299 $(call transform-proto-to-java) 300 301#TODO: protoc should output the dependencies introduced by imports. 302 303LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp) 304endif # proto_sources 305 306 307########################################################### 308## Java: Compile .java files to .class 309########################################################### 310#TODO: pull this into java.make once host and target are combined 311 312java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \ 313 $(filter %.java,$(LOCAL_GENERATED_SOURCES)) 314all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES))) 315 316## Java resources ######################################### 317 318# Look for resource files in any specified directories. 319# Non-java and non-doc files will be picked up as resources 320# and included in the output jar file. 321java_resource_file_groups := 322 323LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS)) 324ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),) 325 # This makes a list of words like 326 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>: 327 # where each of the files is relative to the directory it's grouped with. 328 # Directories that don't contain any resource files will result in groups 329 # that end with a colon, and they are stripped out in the next step. 330 java_resource_file_groups += \ 331 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \ 332 $(subst $(space),:,$(strip \ 333 $(TOP_DIR)$(LOCAL_PATH)/$(dir): \ 334 $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \ 335 find . \ 336 -type d -a -name ".svn" -prune -o \ 337 -type f \ 338 -a \! -name "*.java" \ 339 -a \! -name "package.html" \ 340 -a \! -name "overview.html" \ 341 -a \! -name ".*.swp" \ 342 -a \! -name ".DS_Store" \ 343 -a \! -name "*~" \ 344 -print \ 345 )) \ 346 )) \ 347 ) 348 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups)) 349endif # LOCAL_JAVA_RESOURCE_DIRS 350 351LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES)) 352ifneq ($(LOCAL_JAVA_RESOURCE_FILES),) 353 java_resource_file_groups += \ 354 $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \ 355 $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \ 356 ) 357endif # LOCAL_JAVA_RESOURCE_FILES 358 359ifdef java_resource_file_groups 360 # The full paths to all resources, used for dependencies. 361 java_resource_sources := \ 362 $(foreach group,$(java_resource_file_groups), \ 363 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \ 364 $(wordlist 2,9999,$(subst :,$(space),$(group))) \ 365 ) \ 366 ) 367 # The arguments to jar that will include these files in a jar file. 368 # Quote the file name to handle special characters (such as #) correctly. 369 extra_jar_args := \ 370 $(foreach group,$(java_resource_file_groups), \ 371 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \ 372 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \ 373 ) \ 374 ) 375 java_resource_file_groups := 376else 377 java_resource_sources := 378 extra_jar_args := 379endif # java_resource_file_groups 380 381## PRIVATE java vars ###################################### 382# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, 383# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. 384# You have to set up the dependency in some other way. 385need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)) 386ifdef need_compile_java 387 388full_static_java_libs := \ 389 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ 390 $(call intermediates-dir-for, \ 391 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar) 392 393$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE)) 394$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes 395$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src 396$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources) 397$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES)) 398ifeq ($(my_prefix),TARGET_) 399ifeq ($(LOCAL_SDK_VERSION),) 400$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-libart) 401else 402ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) 403# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. 404$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current) 405else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current) 406$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_system_stubs_current) 407else 408$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION)) 409endif # current or system_current 410endif # LOCAL_SDK_VERSION 411endif # TARGET_ 412$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) 413$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR) 414$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs) 415 416# full_java_libs: The list of files that should be used as the classpath. 417# Using this list as a dependency list WILL NOT WORK. 418# full_java_lib_deps: Should be specified as a prerequisite of this module 419# to guarantee that the files in full_java_libs will 420# be up-to-date. 421ifdef LOCAL_IS_HOST_MODULE 422ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true) 423$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-libart-hostdex,$(LOCAL_IS_HOST_MODULE)) 424 425full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 426full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) \ 427 $(full_shared_java_libs) 428else 429$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := 430 431full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\ 432 $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES))) 433full_java_lib_deps := $(full_shared_java_libs) 434endif # USE_CORE_LIB_BOOTCLASSPATH 435else # !LOCAL_IS_HOST_MODULE 436full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 437full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 438endif # !LOCAL_IS_HOST_MODULE 439full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH) 440full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH) 441 442# This is set by packages that are linking to other packages that export 443# shared libraries, allowing them to make use of the code in the linked apk. 444apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES)) 445ifneq ($(apk_libraries),) 446 link_apk_libraries := \ 447 $(foreach lib,$(apk_libraries), \ 448 $(call intermediates-dir-for, \ 449 APPS,$(lib),,COMMON)/classes.jar) 450 451 # link against the jar with full original names (before proguard processing). 452 full_shared_java_libs += $(link_apk_libraries) 453 full_java_libs += $(link_apk_libraries) 454 full_java_lib_deps += $(link_apk_libraries) 455endif 456 457# This is set by packages that contain instrumentation, allowing them to 458# link against the package they are instrumenting. Currently only one such 459# package is allowed. 460LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR)) 461ifdef LOCAL_INSTRUMENTATION_FOR 462 ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1) 463 $(error \ 464 $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined) 465 endif 466 467 link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \ 468 APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON) 469 # link against the jar with full original names (before proguard processing). 470 link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar 471 full_java_libs += $(link_instr_classes_jar) 472 full_java_lib_deps += $(link_instr_classes_jar) 473endif 474 475endif # need_compile_java 476 477# We may want to add jar manifest or jar resource files even if there is no java code at all. 478$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) 479jar_manifest_file := 480ifneq ($(strip $(LOCAL_JAR_MANIFEST)),) 481jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST) 482$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file) 483else 484$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := 485endif 486 487########################################################### 488## make clean- targets 489########################################################### 490cleantarget := clean-$(my_register_name) 491$(cleantarget) : PRIVATE_MODULE := $(my_register_name) 492$(cleantarget) : PRIVATE_CLEAN_FILES := \ 493 $(LOCAL_BUILT_MODULE) \ 494 $(LOCAL_INSTALLED_MODULE) \ 495 $(intermediates) 496$(cleantarget):: 497 @echo "Clean: $(PRIVATE_MODULE)" 498 $(hide) rm -rf $(PRIVATE_CLEAN_FILES) 499 500########################################################### 501## Common definitions for module. 502########################################################### 503 504# aapt doesn't accept multiple --extra-packages flags. 505# We have to collapse them into a single --extra-packages flag here. 506LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS)) 507ifdef LOCAL_AAPT_FLAGS 508ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),) 509aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS)) 510aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags))) 511aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages))) 512LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \ 513 --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages)) 514aapt_flags_extra_packages := 515aapt_flags := 516endif 517endif 518 519# Propagate local configuration options to this target. 520$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH) 521$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS) 522$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES) 523$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME) 524$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) 525 526$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs) 527$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE) 528$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host) 529 530$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates) 531 532$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) 533 534# Tell the module and all of its sub-modules who it is. 535$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name) 536 537# Provide a short-hand for building this module. 538# We name both BUILT and INSTALLED in case 539# LOCAL_UNINSTALLABLE_MODULE is set. 540.PHONY: $(my_register_name) 541$(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE) 542 543########################################################### 544## Module installation rule 545########################################################### 546 547# Some hosts do not have ACP; override the LOCAL version if that's the case. 548ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),) 549 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE)) 550endif 551 552ifndef LOCAL_UNINSTALLABLE_MODULE 553 # Define a copy rule to install the module. 554 # acp and libraries that it uses can't use acp for 555 # installation; hence, LOCAL_ACP_UNAVAILABLE. 556$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) 557ifneq ($(LOCAL_ACP_UNAVAILABLE),true) 558$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP) 559 @echo "Install: $@" 560 $(copy-file-to-new-target) 561 $(PRIVATE_POST_INSTALL_CMD) 562else 563$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) 564 @echo "Install: $@" 565 $(copy-file-to-target-with-cp) 566endif 567 568endif # !LOCAL_UNINSTALLABLE_MODULE 569 570 571########################################################### 572## CHECK_BUILD goals 573########################################################### 574my_checked_module := 575# If nobody has defined a more specific module for the 576# checked modules, use LOCAL_BUILT_MODULE. 577ifdef LOCAL_CHECKED_MODULE 578 my_checked_module := $(LOCAL_CHECKED_MODULE) 579else ifdef java_alternative_checked_module 580 my_checked_module := $(java_alternative_checked_module) 581else 582 my_checked_module := $(LOCAL_BUILT_MODULE) 583endif 584 585# If they request that this module not be checked, then don't. 586# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT 587# GOOD REASON WILL HAVE IT REMOVED. 588ifdef LOCAL_DONT_CHECK_MODULE 589 my_checked_module := 590endif 591# Don't check build target module defined for the 2nd arch 592ifndef LOCAL_IS_HOST_MODULE 593ifdef LOCAL_2ND_ARCH_VAR_PREFIX 594 my_checked_module := 595endif 596endif 597 598########################################################### 599## Register with ALL_MODULES 600########################################################### 601 602ALL_MODULES += $(my_register_name) 603 604# Don't use += on subvars, or else they'll end up being 605# recursively expanded. 606ALL_MODULES.$(my_register_name).CLASS := \ 607 $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS) 608ALL_MODULES.$(my_register_name).PATH := \ 609 $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH) 610ALL_MODULES.$(my_register_name).TAGS := \ 611 $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags) 612ALL_MODULES.$(my_register_name).CHECKED := \ 613 $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module) 614ALL_MODULES.$(my_register_name).BUILT := \ 615 $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE) 616ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) 617ALL_MODULES.$(my_register_name).INSTALLED := \ 618 $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) $(LOCAL_INSTALLED_MODULE)) 619ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \ 620 $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE)) 621endif 622ifdef LOCAL_PICKUP_FILES 623# Files or directories ready to pick up by the build system 624# when $(LOCAL_BUILT_MODULE) is done. 625ALL_MODULES.$(my_register_name).PICKUP_FILES := \ 626 $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES) 627endif 628ALL_MODULES.$(my_register_name).REQUIRED := \ 629 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(LOCAL_REQUIRED_MODULES) \ 630 $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) 631ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \ 632 $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags) 633ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \ 634 $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR) 635ALL_MODULES.$(my_register_name).MAKEFILE := \ 636 $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE) 637ifdef LOCAL_MODULE_OWNER 638ALL_MODULES.$(my_register_name).OWNER := \ 639 $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER)) 640endif 641ifdef LOCAL_2ND_ARCH_VAR_PREFIX 642ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true 643endif 644ifdef aidl_sources 645ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources) 646endif 647 648INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name) 649 650########################################################## 651# Track module-level dependencies. 652# Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness. 653ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE)) 654ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \ 655 $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \ 656 $(LOCAL_STATIC_LIBRARIES) \ 657 $(LOCAL_WHOLE_STATIC_LIBRARIES) \ 658 $(LOCAL_SHARED_LIBRARIES) \ 659 $(LOCAL_STATIC_JAVA_LIBRARIES) \ 660 $(LOCAL_JAVA_LIBRARIES)\ 661 $(LOCAL_JNI_SHARED_LIBRARIES)) 662 663ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files)) 664 665########################################################### 666## Take care of my_module_tags 667########################################################### 668 669# Keep track of all the tags we've seen. 670ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags)) 671 672# Add this module name to the tag list of each specified tag. 673$(foreach tag,$(my_module_tags),\ 674 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name))) 675 676########################################################### 677## umbrella targets used to verify builds 678########################################################### 679j_or_n := 680ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))) 681j_or_n := native 682else 683ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS))) 684j_or_n := java 685endif 686endif 687ifdef LOCAL_IS_HOST_MODULE 688h_or_t := host 689else 690h_or_t := target 691endif 692 693ifdef j_or_n 694$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module) 695ifneq (,$(filter $(my_module_tags),tests)) 696$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module) 697endif 698endif 699 700########################################################### 701# JACK 702########################################################### 703ifdef LOCAL_JACK_ENABLED 704ifdef need_compile_java 705 706full_static_jack_libs := \ 707 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ 708 $(call intermediates-dir-for, \ 709 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jack) 710 711ifeq ($(my_prefix),TARGET_) 712ifeq ($(LOCAL_SDK_VERSION),) 713$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(call jack-lib-files,core-libart) 714else 715ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) 716# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. 717$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(call jack-lib-files,android_stubs_current) 718else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current) 719$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(call jack-lib-files,android_system_stubs_current) 720else 721$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(call jack-lib-files,sdk_v$(LOCAL_SDK_VERSION)) 722endif # current or system_current 723endif # LOCAL_SDK_VERSION 724endif # TARGET_ 725 726$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JACK_LIBRARIES := $(full_static_jack_libs) 727$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VM_ARGS := $(LOCAL_JACK_VM_ARGS) 728$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_EXTRA_ARGS := $(LOCAL_JACK_EXTRA_ARGS) 729 730ifdef LOCAL_IS_HOST_MODULE 731ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true) 732$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(call jack-lib-files,core-libart-hostdex,$(LOCAL_IS_HOST_MODULE)) 733full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 734full_jack_lib_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 735else 736$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := 737full_shared_jack_libs := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 738full_jack_lib_deps := $(full_shared_jack_libs) 739endif # USE_CORE_LIB_BOOTCLASSPATH 740else # !LOCAL_IS_HOST_MODULE 741full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 742full_jack_lib_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 743endif # !LOCAL_IS_HOST_MODULE 744full_jack_libs := $(full_shared_jack_libs) $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH) 745full_jack_lib_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH) 746 747# This is set by packages that are linking to other packages that export 748# shared libraries, allowing them to make use of the code in the linked apk. 749ifneq ($(apk_libraries),) 750 link_apk_jack_libraries := \ 751 $(foreach lib,$(apk_libraries), \ 752 $(call intermediates-dir-for, \ 753 APPS,$(lib),,COMMON)/classes.jack) 754 755 # link against the jar with full original names (before proguard processing). 756 full_shared_jack_libs += $(link_apk_jack_libraries) 757 full_jack_libs += $(link_apk_jack_libraries) 758 full_jack_lib_deps += $(link_apk_jack_libraries) 759endif 760 761# This is set by packages that contain instrumentation, allowing them to 762# link against the package they are instrumenting. Currently only one such 763# package is allowed. 764ifdef LOCAL_INSTRUMENTATION_FOR 765 766 # link against the jar with full original names (before proguard processing). 767 link_instr_classes_jack := $(link_instr_intermediates_dir.COMMON)/classes.noshrob.jack 768 full_jack_libs += $(link_instr_classes_jack) 769 full_jack_lib_deps += $(link_instr_classes_jack) 770endif 771 772endif # need_compile_java 773 774# Propagate local configuration options to this target. 775$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JACK_LIBRARIES:= $(full_jack_libs) 776$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) 777 778endif # LOCAL_JACK_ENABLED 779 780########################################################### 781## NOTICE files 782########################################################### 783 784include $(BUILD_NOTICE_FILE) 785 786#:vi noexpandtab 787