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