2 # Copyright (C) 2008 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Users can define base-rules-hook in their buildspec.mk to perform
18 # arbitrary operations as each module is included.
20 $(if $(base-rules-hook),)
23 ###########################################################
24 ## Common instructions for a generic module.
25 ###########################################################
27 LOCAL_MODULE := $(strip $(LOCAL_MODULE))
28 ifeq ($(LOCAL_MODULE),)
29 $(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
32 LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
33 ifdef 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)")
44 my_module_tags := $(LOCAL_MODULE_TAGS)
46 ###########################################################
47 ## Validate and define fallbacks for input LOCAL_* variables.
48 ###########################################################
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
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)
57 LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
58 my_module_tags := $(sort $(my_module_tags))
59 ifeq (,$(my_module_tags))
60 my_module_tags := optional
63 # User tags are not allowed anymore. Fail early because it will not be installed
65 ifneq ($(filter $(my_module_tags),user),)
66 $(warning *** Module name: $(LOCAL_MODULE))
67 $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE))
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.)
74 $(error user tag detected on module.)
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
80 ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),)
81 $(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH))
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
90 license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*)
91 gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*)
92 ifneq ($(gpl_license_file),)
94 ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file))
97 LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
98 ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
99 $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
102 my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
104 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
105 my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
106 ifdef my_multilib_module_path
107 my_module_path := $(my_multilib_module_path)
109 my_module_path := $(strip $(LOCAL_MODULE_PATH))
111 my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
112 ifeq ($(my_module_path),)
113 ifdef LOCAL_IS_HOST_MODULE
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
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)
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
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)")
138 ifneq ($(my_module_relative_path),)
139 my_module_path := $(my_module_path)/$(my_module_relative_path)
141 endif # not LOCAL_UNINSTALLABLE_MODULE
143 ifneq ($(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)
147 my_register_name := $(LOCAL_MODULE)
148 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
149 ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
150 my_register_name := $(LOCAL_MODULE)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
153 # Make sure that this IS_HOST/CLASS/MODULE combination is unique.
154 module_id := MODULE.$(if \
155 $(LOCAL_IS_HOST_MODULE),HOST,TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name)
157 $(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
159 $(module_id) := $(LOCAL_PATH)
161 intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
162 intermediates.COMMON := $(call local-intermediates-dir,COMMON)
163 generated_sources_dir := $(call local-generated-sources-dir)
165 ###########################################################
166 # Pick a name for the intermediate and final targets
167 ###########################################################
168 include $(BUILD_SYSTEM)/configure_module_stem.mk
170 # OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the
171 # internal SHARED_LIBRARIES build files.
172 OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH))
173 ifdef OVERRIDE_BUILT_MODULE_PATH
174 ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
175 $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
177 built_module_path := $(OVERRIDE_BUILT_MODULE_PATH)
179 built_module_path := $(intermediates)
181 LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem)
183 ifneq (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)
191 LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
194 # Assemble the list of targets to create PRIVATE_ variables for.
195 LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
198 ###########################################################
199 ## AIDL: Compile .aidl files to .java
200 ###########################################################
202 aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
204 ifneq ($(strip $(aidl_sources)),)
206 aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
207 aidl_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(aidl_sources))
209 aidl_preprocess_import :=
210 LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
211 ifdef LOCAL_SDK_VERSION
212 ifneq ($(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
216 aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
217 endif # not current or system_current
219 # build against the platform.
220 LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
221 endif # 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))
224 $(aidl_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.aidl $(LOCAL_ADDITIONAL_DEPENDENCIES) $(AIDL) $(aidl_preprocess_import)
225 $(transform-aidl-to-java)
226 -include $(aidl_java_sources:%.java=%.P)
232 ###########################################################
233 ## logtags: Add .logtags files to global list, emit java source
234 ###########################################################
236 logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES))
238 ifneq ($(strip $(logtags_sources)),)
240 event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources))
242 # Emit a java source file with constants for the tags, if
243 # LOCAL_MODULE_CLASS is "APPS" or "JAVA_LIBRARIES".
244 ifneq ($(filter $(LOCAL_MODULE_CLASS),APPS JAVA_LIBRARIES),)
246 logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
247 logtags_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(logtags_sources))
249 $(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(TOPDIR)$(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
250 $(transform-logtags-to-java)
255 logtags_java_sources :=
259 ###########################################################
260 ## .proto files: Compile proto files to .java
261 ###########################################################
262 proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
263 # Because names of the .java files compiled from .proto files are unknown until the
264 # .proto files are compiled, we use a timestamp file as depedency.
265 proto_java_sources_file_stamp :=
266 ifneq ($(proto_sources),)
267 proto_sources_fullpath := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(proto_sources))
268 # By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
269 # automatically found by the java compiling function transform-java-to-classes.jar.
270 ifneq ($(LOCAL_INTERMEDIATE_SOURCE_DIR),)
271 proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
273 # LOCAL_INTERMEDIATE_SOURCE_DIR may be not defined in non-java modules.
274 proto_java_intemediate_dir := $(intermediates)/proto
276 proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
277 proto_java_sources_dir := $(proto_java_intemediate_dir)/src
279 $(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
280 $(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
281 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
282 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
283 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
285 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
286 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
288 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
291 $(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
292 $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
293 $(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
294 $(call transform-proto-to-java)
296 #TODO: protoc should output the dependencies introduced by imports.
298 LOCAL_INTERMEDIATE_TARGETS += $(proto_java_sources_file_stamp)
299 endif # proto_sources
302 ###########################################################
303 ## Java: Compile .java files to .class
304 ###########################################################
305 #TODO: pull this into java.make once host and target are combined
307 java_sources := $(addprefix $(TOP_DIR)$(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
308 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
309 all_java_sources := $(java_sources) $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
311 ## Java resources #########################################
313 # Look for resource files in any specified directories.
314 # Non-java and non-doc files will be picked up as resources
315 # and included in the output jar file.
316 java_resource_file_groups :=
318 LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
319 ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
320 # This makes a list of words like
321 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
322 # where each of the files is relative to the directory it's grouped with.
323 # Directories that don't contain any resource files will result in groups
324 # that end with a colon, and they are stripped out in the next step.
325 java_resource_file_groups += \
326 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
327 $(subst $(space),:,$(strip \
328 $(TOP_DIR)$(LOCAL_PATH)/$(dir): \
329 $(patsubst ./%,%,$(shell cd $(TOP_DIR)$(LOCAL_PATH)/$(dir) && \
331 -type d -a -name ".svn" -prune -o \
333 -a \! -name "*.java" \
334 -a \! -name "package.html" \
335 -a \! -name "overview.html" \
336 -a \! -name ".*.swp" \
337 -a \! -name ".DS_Store" \
343 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
344 endif # LOCAL_JAVA_RESOURCE_DIRS
346 LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
347 ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
348 java_resource_file_groups += \
349 $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
350 $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
352 endif # LOCAL_JAVA_RESOURCE_FILES
354 ifdef java_resource_file_groups
355 # The full paths to all resources, used for dependencies.
356 java_resource_sources := \
357 $(foreach group,$(java_resource_file_groups), \
358 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
359 $(wordlist 2,9999,$(subst :,$(space),$(group))) \
362 # The arguments to jar that will include these files in a jar file.
363 # Quote the file name to handle special characters (such as #) correctly.
365 $(foreach group,$(java_resource_file_groups), \
366 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
367 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
370 java_resource_file_groups :=
372 java_resource_sources :=
374 endif # java_resource_file_groups
376 ## PRIVATE java vars ######################################
377 # LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
378 # but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
379 # You have to set up the dependency in some other way.
380 need_compile_java := $(strip $(all_java_sources)$(all_res_assets))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
381 ifdef need_compile_java
383 full_static_java_libs := \
384 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
385 $(call intermediates-dir-for, \
386 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
388 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_INSTALL_DIR := $(dir $(LOCAL_INSTALLED_MODULE))
389 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates)/classes
390 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates)/src
391 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
392 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_OBJECTS := $(patsubst %.java,%.class,$(LOCAL_SRC_FILES))
393 ifeq ($(my_prefix),TARGET_)
394 ifeq ($(LOCAL_SDK_VERSION),)
395 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,core-libart)
397 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
398 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
399 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_stubs_current)
400 else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
401 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,android_system_stubs_current)
403 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
404 endif # current or system_current
405 endif # LOCAL_SDK_VERSION
407 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
408 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
409 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
411 # full_java_libs: The list of files that should be used as the classpath.
412 # Using this list as a dependency list WILL NOT WORK.
413 # full_java_lib_deps: Should be specified as a prerequisite of this module
414 # to guarantee that the files in full_java_libs will
416 ifdef LOCAL_IS_HOST_MODULE
417 ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
418 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(call java-lib-deps,core-libart-hostdex,$(LOCAL_IS_HOST_MODULE))
420 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
421 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
423 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
425 full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
426 $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
427 full_java_lib_deps := $(full_shared_java_libs)
428 endif # USE_CORE_LIB_BOOTCLASSPATH
429 else # !LOCAL_IS_HOST_MODULE
430 full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
431 full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
432 endif # !LOCAL_IS_HOST_MODULE
433 full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
434 full_java_lib_deps += $(full_static_java_libs) $(LOCAL_CLASSPATH)
436 # This is set by packages that are linking to other packages that export
437 # shared libraries, allowing them to make use of the code in the linked apk.
438 apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES))
439 ifneq ($(apk_libraries),)
440 link_apk_libraries := \
441 $(foreach lib,$(apk_libraries), \
442 $(call intermediates-dir-for, \
443 APPS,$(lib),,COMMON)/classes.jar)
445 # link against the jar with full original names (before proguard processing).
446 full_shared_java_libs += $(link_apk_libraries)
447 full_java_libs += $(link_apk_libraries)
448 full_java_lib_deps += $(link_apk_libraries)
451 # This is set by packages that contain instrumentation, allowing them to
452 # link against the package they are instrumenting. Currently only one such
453 # package is allowed.
454 LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
455 ifdef LOCAL_INSTRUMENTATION_FOR
456 ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
458 $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
461 link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
462 APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
463 # link against the jar with full original names (before proguard processing).
464 link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
465 full_java_libs += $(link_instr_classes_jar)
466 full_java_lib_deps += $(link_instr_classes_jar)
469 endif # need_compile_java
471 # We may want to add jar manifest or jar resource files even if there is no java code at all.
472 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
474 ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
475 jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
476 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
478 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
481 ###########################################################
482 ## make clean- targets
483 ###########################################################
484 cleantarget := clean-$(my_register_name)
485 $(cleantarget) : PRIVATE_MODULE := $(my_register_name)
486 $(cleantarget) : PRIVATE_CLEAN_FILES := \
487 $(LOCAL_BUILT_MODULE) \
488 $(LOCAL_INSTALLED_MODULE) \
491 @echo "Clean: $(PRIVATE_MODULE)"
492 $(hide) rm -rf $(PRIVATE_CLEAN_FILES)
494 ###########################################################
495 ## Common definitions for module.
496 ###########################################################
498 # aapt doesn't accept multiple --extra-packages flags.
499 # We have to collapse them into a single --extra-packages flag here.
500 LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
501 ifdef LOCAL_AAPT_FLAGS
502 ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
503 aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
504 aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
505 aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
506 LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
507 --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
508 aapt_flags_extra_packages :=
513 # Propagate local configuration options to this target.
514 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
515 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_AAPT_FLAGS:= $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS)
516 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_JAVA_LIBRARIES:= $(LOCAL_JAVA_LIBRARIES)
517 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_PACKAGE_NAME:= $(LOCAL_MANIFEST_PACKAGE_NAME)
518 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MANIFEST_INSTRUMENTATION_FOR:= $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
520 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_JAVA_LIBRARIES:= $(full_java_libs)
521 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
522 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
524 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
526 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
528 # Tell the module and all of its sub-modules who it is.
529 $(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
531 # Provide a short-hand for building this module.
532 # We name both BUILT and INSTALLED in case
533 # LOCAL_UNINSTALLABLE_MODULE is set.
534 .PHONY: $(my_register_name)
535 $(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE)
537 ###########################################################
538 ## Module installation rule
539 ###########################################################
541 # Some hosts do not have ACP; override the LOCAL version if that's the case.
542 ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),)
543 LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE))
546 ifndef LOCAL_UNINSTALLABLE_MODULE
547 # Define a copy rule to install the module.
548 # acp and libraries that it uses can't use acp for
549 # installation; hence, LOCAL_ACP_UNAVAILABLE.
550 $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
551 ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
552 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP)
554 $(copy-file-to-new-target)
555 $(PRIVATE_POST_INSTALL_CMD)
557 $(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
559 $(copy-file-to-target-with-cp)
562 endif # !LOCAL_UNINSTALLABLE_MODULE
565 ###########################################################
567 ###########################################################
569 ifdef java_alternative_checked_module
570 LOCAL_CHECKED_MODULE := $(java_alternative_checked_module)
573 # If nobody has defined a more specific module for the
574 # checked modules, use LOCAL_BUILT_MODULE.
575 ifndef LOCAL_CHECKED_MODULE
576 LOCAL_CHECKED_MODULE := $(LOCAL_BUILT_MODULE)
579 # If they request that this module not be checked, then don't.
580 # PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
581 # GOOD REASON WILL HAVE IT REMOVED.
582 ifdef LOCAL_DONT_CHECK_MODULE
583 LOCAL_CHECKED_MODULE :=
585 # Don't check build target module defined for the 2nd arch
586 ifndef LOCAL_IS_HOST_MODULE
587 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
588 LOCAL_CHECKED_MODULE :=
592 ###########################################################
593 ## Register with ALL_MODULES
594 ###########################################################
596 ALL_MODULES += $(my_register_name)
598 # Don't use += on subvars, or else they'll end up being
599 # recursively expanded.
600 ALL_MODULES.$(my_register_name).CLASS := \
601 $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
602 ALL_MODULES.$(my_register_name).PATH := \
603 $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
604 ALL_MODULES.$(my_register_name).TAGS := \
605 $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags)
606 ALL_MODULES.$(my_register_name).CHECKED := \
607 $(ALL_MODULES.$(my_register_name).CHECKED) $(LOCAL_CHECKED_MODULE)
608 ALL_MODULES.$(my_register_name).BUILT := \
609 $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
610 ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
611 ALL_MODULES.$(my_register_name).INSTALLED := \
612 $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) $(LOCAL_INSTALLED_MODULE))
613 ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
614 $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE))
616 ifdef LOCAL_PICKUP_FILES
617 # Files or directories ready to pick up by the build system
618 # when $(LOCAL_BUILT_MODULE) is done.
619 ALL_MODULES.$(my_register_name).PICKUP_FILES := \
620 $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
622 ALL_MODULES.$(my_register_name).REQUIRED := \
623 $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(LOCAL_REQUIRED_MODULES) \
624 $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
625 ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
626 $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
627 ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \
628 $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
629 ALL_MODULES.$(my_register_name).MAKEFILE := \
630 $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
631 ifdef LOCAL_MODULE_OWNER
632 ALL_MODULES.$(my_register_name).OWNER := \
633 $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
635 ifdef LOCAL_2ND_ARCH_VAR_PREFIX
636 ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
639 ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources)
642 INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
644 ##########################################################
645 # Track module-level dependencies.
646 # Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness.
647 ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE))
648 ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \
649 $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \
650 $(LOCAL_STATIC_LIBRARIES) \
651 $(LOCAL_WHOLE_STATIC_LIBRARIES) \
652 $(LOCAL_SHARED_LIBRARIES) \
653 $(LOCAL_STATIC_JAVA_LIBRARIES) \
654 $(LOCAL_JAVA_LIBRARIES)\
655 $(LOCAL_JNI_SHARED_LIBRARIES))
657 ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files))
659 ###########################################################
660 ## Take care of my_module_tags
661 ###########################################################
663 # Keep track of all the tags we've seen.
664 ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags))
666 # Add this module name to the tag list of each specified tag.
667 $(foreach tag,$(my_module_tags),\
668 $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name)))
670 ###########################################################
671 ## umbrella targets used to verify builds
672 ###########################################################
674 ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)))
677 ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
681 ifdef LOCAL_IS_HOST_MODULE
688 $(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(LOCAL_CHECKED_MODULE)
689 ifneq (,$(filter $(my_module_tags),tests))
690 $(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(LOCAL_CHECKED_MODULE)
694 ###########################################################
696 ###########################################################
698 include $(BUILD_NOTICE_FILE)