blob: 3c9b18f8cb6a1f142b12388ad4d951bf25ed5092 [file] [log] [blame]
Ying Wang956dccc2015-08-28 11:47:03 -07001# Common to host and target Java modules.
2
3###########################################################
Neil Fullerad022512016-01-29 14:22:29 +00004## Java version
5###########################################################
Neil Fullerdecb7972016-03-04 18:00:00 +00006# Use the LOCAL_JAVA_LANGUAGE_VERSION if it is set, otherwise
7# use one based on the LOCAL_SDK_VERSION. If it is < 24
8# pass "1.7" to the tools, if it is unset, >= 24 or "current"
9# pass "1.8".
10#
11# The LOCAL_SDK_VERSION behavior is to ensure that, by default,
12# code that is expected to run on older releases of Android
13# does not use any 1.8 language features that are not supported
14# on earlier runtimes (like default / static interface methods).
15# Modules can override this logic by specifying
16# LOCAL_JAVA_LANGUAGE_VERSION explicitly.
Neil Fullerad022512016-01-29 14:22:29 +000017ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION))
Neil Fullerdecb7972016-03-04 18:00:00 +000018 private_sdk_versions_without_any_java_18_support := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
19 ifneq (,$(filter $(LOCAL_SDK_VERSION), $(private_sdk_versions_without_any_java_18_support)))
Nicolas Geoffray8d772e22016-02-29 12:07:00 +000020 LOCAL_JAVA_LANGUAGE_VERSION := 1.7
Neil Fullerdecb7972016-03-04 18:00:00 +000021 else
Tobias Thiererc61bd992017-05-23 14:16:59 +010022 LOCAL_JAVA_LANGUAGE_VERSION := 1.8
Nicolas Geoffray8d772e22016-02-29 12:07:00 +000023 endif
Neil Fullerad022512016-01-29 14:22:29 +000024endif
25LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION)
26
27###########################################################
Ying Wang956dccc2015-08-28 11:47:03 -070028## .proto files: Compile proto files to .java
29###########################################################
30proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
31# Because names of the .java files compiled from .proto files are unknown until the
32# .proto files are compiled, we use a timestamp file as depedency.
33proto_java_sources_file_stamp :=
34ifneq ($(proto_sources),)
35proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
36
Dan Willemsencf324af2016-12-21 17:37:00 -080037proto_java_intemediate_dir := $(intermediates.COMMON)/proto
Ying Wang956dccc2015-08-28 11:47:03 -070038proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
39proto_java_sources_dir := $(proto_java_intemediate_dir)/src
40
41$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
42$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
43$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
44ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
45$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
46else
47 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
48$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
49 else
50$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
51 endif
52endif
53$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
54$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
55$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
56 $(call transform-proto-to-java)
57
58#TODO: protoc should output the dependencies introduced by imports.
Ying Wangd5ffec92016-03-01 22:05:25 -080059
60ALL_MODULES.$(my_register_name).PROTO_FILES := $(proto_sources_fullpath)
Ying Wang956dccc2015-08-28 11:47:03 -070061endif # proto_sources
62
63#########################################
64## Java resources
65
66# Look for resource files in any specified directories.
67# Non-java and non-doc files will be picked up as resources
68# and included in the output jar file.
69java_resource_file_groups :=
70
71LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
72ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
73 # This makes a list of words like
74 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
75 # where each of the files is relative to the directory it's grouped with.
76 # Directories that don't contain any resource files will result in groups
77 # that end with a colon, and they are stripped out in the next step.
78 java_resource_file_groups += \
79 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
80 $(subst $(space),:,$(strip \
81 $(LOCAL_PATH)/$(dir): \
Dan Willemsen7c3e3f82015-09-29 16:30:21 -070082 $(patsubst ./%,%,$(sort $(shell cd $(LOCAL_PATH)/$(dir) && \
Ying Wang956dccc2015-08-28 11:47:03 -070083 find . \
84 -type d -a -name ".svn" -prune -o \
85 -type f \
86 -a \! -name "*.java" \
87 -a \! -name "package.html" \
88 -a \! -name "overview.html" \
89 -a \! -name ".*.swp" \
90 -a \! -name ".DS_Store" \
91 -a \! -name "*~" \
92 -print \
Dan Willemsen7c3e3f82015-09-29 16:30:21 -070093 ))) \
Ying Wang956dccc2015-08-28 11:47:03 -070094 )) \
95 )
96 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
97endif # LOCAL_JAVA_RESOURCE_DIRS
98
99LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
100ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
101 java_resource_file_groups += \
102 $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
103 $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
104 )
105endif # LOCAL_JAVA_RESOURCE_FILES
106
107ifdef java_resource_file_groups
108 # The full paths to all resources, used for dependencies.
109 java_resource_sources := \
110 $(foreach group,$(java_resource_file_groups), \
111 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
112 $(wordlist 2,9999,$(subst :,$(space),$(group))) \
113 ) \
114 )
115 # The arguments to jar that will include these files in a jar file.
116 # Quote the file name to handle special characters (such as #) correctly.
117 extra_jar_args := \
118 $(foreach group,$(java_resource_file_groups), \
119 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
120 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
121 ) \
122 )
123 java_resource_file_groups :=
124else
125 java_resource_sources :=
126 extra_jar_args :=
127endif # java_resource_file_groups
128
Ying Wangf8d15d62016-04-26 15:49:56 -0700129#####################################
130## Warn if there is unrecognized file in LOCAL_SRC_FILES.
131my_unknown_src_files := $(filter-out \
132 %.java %.aidl %.proto %.logtags %.fs %.rs, \
133 $(LOCAL_SRC_FILES) $(LOCAL_INTERMEDIATE_SOURCES) $(LOCAL_GENERATED_SOURCES))
134ifneq ($(my_unknown_src_files),)
135$(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unknown_src_files))
136endif
137
Ying Wang956dccc2015-08-28 11:47:03 -0700138######################################
139## PRIVATE java vars
140# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
141# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
142# You have to set up the dependency in some other way.
143need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
144ifdef need_compile_java
145
Colin Crosscde14982017-04-07 16:28:41 -0700146annotation_processor_flags :=
147annotation_processor_deps :=
148
149ifdef LOCAL_ANNOTATION_PROCESSORS
150 annotation_processor_jars := $(call java-lib-deps,$(LOCAL_ANNOTATION_PROCESSORS),true)
151 annotation_processor_flags += -processorpath $(call normalize-path-list,$(annotation_processor_jars))
152 annotation_processor_deps += $(annotation_processor_jars)
153
154 # b/25860419: annotation processors must be explicitly specified for grok
155 annotation_processor_flags += $(foreach class,$(LOCAL_ANNOTATION_PROCESSOR_CLASSES),-processor $(class))
156
157 annotation_processor_jars :=
158endif
159
Ying Wang956dccc2015-08-28 11:47:03 -0700160full_static_java_libs := \
161 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
162 $(call intermediates-dir-for, \
Colin Cross941b6822017-03-29 13:53:29 -0700163 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jar)
Ying Wang956dccc2015-08-28 11:47:03 -0700164
165$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
166
167$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
168$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
169
170$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
Colin Crosscde14982017-04-07 16:28:41 -0700171$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANNO_INTERMEDIATES_DIR := $(intermediates.COMMON)/anno
Ying Wang956dccc2015-08-28 11:47:03 -0700172$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
Dan Willemsencf324af2016-12-21 17:37:00 -0800173$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_PROTO_SOURCES := $(if $(proto_sources),true)
174$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/proto
175$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES :=
Ying Wang956dccc2015-08-28 11:47:03 -0700176$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
177
178$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
179
180# full_java_libs: The list of files that should be used as the classpath.
181# Using this list as a dependency list WILL NOT WORK.
182# full_java_lib_deps: Should be specified as a prerequisite of this module
183# to guarantee that the files in full_java_libs will
184# be up-to-date.
185ifndef LOCAL_IS_HOST_MODULE
186ifeq ($(LOCAL_SDK_VERSION),)
Ying Wangc6a30172015-11-23 14:57:26 -0800187ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
188# No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath.
189my_bootclasspath := ""
190else # LOCAL_NO_STANDARD_LIBRARIES
191my_bootclasspath := $(call java-lib-files,core-oj):$(call java-lib-files,core-libart)
192endif # LOCAL_NO_STANDARD_LIBRARIES
Ying Wang956dccc2015-08-28 11:47:03 -0700193else
194ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
195# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
Ying Wangc6a30172015-11-23 14:57:26 -0800196my_bootclasspath := $(call java-lib-files,android_stubs_current)
Ying Wang956dccc2015-08-28 11:47:03 -0700197else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
Ying Wangc6a30172015-11-23 14:57:26 -0800198my_bootclasspath := $(call java-lib-files,android_system_stubs_current)
Michael Wright0fb087f2015-11-06 15:20:51 +0000199else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
200my_bootclasspath := $(call java-lib-files,android_test_stubs_current)
Ying Wang956dccc2015-08-28 11:47:03 -0700201else
Ying Wangc6a30172015-11-23 14:57:26 -0800202my_bootclasspath := $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
Michael Wright0fb087f2015-11-06 15:20:51 +0000203endif # current, system_current, or test_current
Ying Wang956dccc2015-08-28 11:47:03 -0700204endif # LOCAL_SDK_VERSION
Ying Wangc6a30172015-11-23 14:57:26 -0800205$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_bootclasspath)
Ying Wang956dccc2015-08-28 11:47:03 -0700206
Neil Fullerb08544e2016-02-19 10:37:22 +0000207# In order to compile lambda code javac requires various invokedynamic-
208# related classes to be present. This change adds stubs needed for
209# javac to compile lambdas.
210my_additional_javac_libs :=
211ifndef TARGET_BUILD_APPS
212# TODO: support to build lamdbas using javac in unbundled build.
213# We may need to check in a prebuilt core-lambda-stubs to prebuilts/sdk.
214ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
215my_additional_javac_libs := core-lambda-stubs
216endif
217endif
218
219full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
220full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900221full_java_lib_deps := $(addsuffix .toc, $(full_java_lib_deps))
Ying Wang956dccc2015-08-28 11:47:03 -0700222
223else # LOCAL_IS_HOST_MODULE
224
225ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
Ying Wangc6a30172015-11-23 14:57:26 -0800226ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
227my_bootclasspath := ""
228else
Colin Cross941b6822017-03-29 13:53:29 -0700229my_bootclasspath := $(call normalize-path-list,$(call java-lib-files,core-oj-hostdex core-libart-hostdex,true))
Ying Wangc6a30172015-11-23 14:57:26 -0800230endif
231$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_bootclasspath)
Ying Wang956dccc2015-08-28 11:47:03 -0700232
Colin Cross941b6822017-03-29 13:53:29 -0700233full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
Ying Wang063d0452016-03-02 17:25:01 -0800234full_java_lib_deps := $(full_shared_java_libs)
235else # !USE_CORE_LIB_BOOTCLASSPATH
Ying Wang956dccc2015-08-28 11:47:03 -0700236$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
237
238full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
239 $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
240full_java_lib_deps := $(full_shared_java_libs)
241endif # USE_CORE_LIB_BOOTCLASSPATH
242endif # !LOCAL_IS_HOST_MODULE
243
244full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
245full_java_lib_deps := $(full_java_lib_deps) $(full_static_java_libs) $(LOCAL_CLASSPATH)
246
247ifndef LOCAL_IS_HOST_MODULE
248# This is set by packages that are linking to other packages that export
249# shared libraries, allowing them to make use of the code in the linked apk.
250apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES))
251ifneq ($(apk_libraries),)
252 link_apk_libraries := \
253 $(foreach lib,$(apk_libraries), \
254 $(call intermediates-dir-for, \
Colin Cross950f1ef2017-04-05 15:30:42 -0700255 APPS,$(lib),,COMMON)/classes-pre-proguard.jar)
Ying Wang956dccc2015-08-28 11:47:03 -0700256
257 # link against the jar with full original names (before proguard processing).
258 full_shared_java_libs += $(link_apk_libraries)
259 full_java_libs += $(link_apk_libraries)
260 full_java_lib_deps += $(link_apk_libraries)
261endif
262
263# This is set by packages that contain instrumentation, allowing them to
264# link against the package they are instrumenting. Currently only one such
265# package is allowed.
266LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
267ifdef LOCAL_INSTRUMENTATION_FOR
268 ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
269 $(error \
270 $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
271 endif
272
273 link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
274 APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
275 # link against the jar with full original names (before proguard processing).
Colin Cross950f1ef2017-04-05 15:30:42 -0700276 link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes-pre-proguard.jar
Ying Wang956dccc2015-08-28 11:47:03 -0700277 full_java_libs += $(link_instr_classes_jar)
278 full_java_lib_deps += $(link_instr_classes_jar)
279endif # LOCAL_INSTRUMENTATION_FOR
280endif # LOCAL_IS_HOST_MODULE
281
282endif # need_compile_java
283
284# We may want to add jar manifest or jar resource files even if there is no java code at all.
285$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
286jar_manifest_file :=
287ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
288jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
289$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
290else
291$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
292endif
293
294##########################################################
295ifndef LOCAL_IS_HOST_MODULE
296## AAPT Flags
297# aapt doesn't accept multiple --extra-packages flags.
298# We have to collapse them into a single --extra-packages flag here.
299LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
300ifdef LOCAL_AAPT_FLAGS
301ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
302aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
303aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
304aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
305LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
306 --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
307aapt_flags_extra_packages :=
308aapt_flags :=
309endif
310endif
311
Ying Wang6f9bd2a2016-03-29 12:41:42 -0700312$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS)
313$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS)
314$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
315$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
Ying Wang956dccc2015-08-28 11:47:03 -0700316
Ying Wang956dccc2015-08-28 11:47:03 -0700317ifdef aidl_sources
318ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources)
319endif
Ying Wangd5ffec92016-03-01 22:05:25 -0800320ifdef renderscript_sources
321ALL_MODULES.$(my_register_name).RS_FILES := $(renderscript_sources_fullpath)
322endif
Ying Wang956dccc2015-08-28 11:47:03 -0700323endif # !LOCAL_IS_HOST_MODULE
324
Ying Wang6f9bd2a2016-03-29 12:41:42 -0700325$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs)
Ying Wang956dccc2015-08-28 11:47:03 -0700326
327ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \
328 $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
329
330###########################################################
331# JACK
332###########################################################
Colin Cross79e2f732016-12-21 14:29:13 -0800333ifdef LOCAL_JACK_ENABLED
Ying Wang956dccc2015-08-28 11:47:03 -0700334ifdef need_compile_java
335
Neil Fullerad022512016-01-29 14:22:29 +0000336LOCAL_JACK_FLAGS += -D jack.java.source.version=$(LOCAL_JAVA_LANGUAGE_VERSION)
337
Ying Wang956dccc2015-08-28 11:47:03 -0700338full_static_jack_libs := \
339 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
340 $(call intermediates-dir-for, \
341 JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jack)
342
343$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JACK_LIBRARIES := $(full_static_jack_libs)
Ying Wang956dccc2015-08-28 11:47:03 -0700344
Ying Wang956dccc2015-08-28 11:47:03 -0700345full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
Yohann Rousselae2fc812016-04-21 16:49:10 +0200346full_jack_deps := $(full_shared_jack_libs)
347
348ifndef LOCAL_IS_HOST_MODULE
Shinichiro Hamajif972a4a2015-12-09 18:06:20 +0900349# Turn off .toc optimization for apps build as we cannot build dexdump.
350ifeq (,$(TARGET_BUILD_APPS))
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100351full_jack_deps := $(patsubst %.jack, %.dex.toc, $(full_jack_deps))
Shinichiro Hamajif972a4a2015-12-09 18:06:20 +0900352endif
Ying Wang956dccc2015-08-28 11:47:03 -0700353endif # !LOCAL_IS_HOST_MODULE
Yohann Roussel2dc79b12016-04-21 16:30:18 +0200354full_shared_jack_libs += $(LOCAL_JACK_CLASSPATH)
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100355full_jack_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
Ying Wang956dccc2015-08-28 11:47:03 -0700356
357ifndef LOCAL_IS_HOST_MODULE
358# This is set by packages that are linking to other packages that export
359# shared libraries, allowing them to make use of the code in the linked apk.
360ifneq ($(apk_libraries),)
361 link_apk_jack_libraries := \
362 $(foreach lib,$(apk_libraries), \
363 $(call intermediates-dir-for, \
364 APPS,$(lib),,COMMON)/classes.jack)
365
366 # link against the jar with full original names (before proguard processing).
367 full_shared_jack_libs += $(link_apk_jack_libraries)
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100368 full_jack_deps += $(link_apk_jack_libraries)
Ying Wang956dccc2015-08-28 11:47:03 -0700369endif
370
371# This is set by packages that contain instrumentation, allowing them to
372# link against the package they are instrumenting. Currently only one such
373# package is allowed.
374ifdef LOCAL_INSTRUMENTATION_FOR
375 # link against the jar with full original names (before proguard processing).
376 link_instr_classes_jack := $(link_instr_intermediates_dir.COMMON)/classes.noshrob.jack
Yohann Roussel2dc79b12016-04-21 16:30:18 +0200377 full_shared_jack_libs += $(link_instr_classes_jack)
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100378 full_jack_deps += $(link_instr_classes_jack)
Ying Wang956dccc2015-08-28 11:47:03 -0700379endif # LOCAL_INSTRUMENTATION_FOR
380endif # !LOCAL_IS_HOST_MODULE
381
382# Propagate local configuration options to this target.
Yohann Rousselb6232d92016-04-22 18:45:45 +0200383$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_SHARED_LIBRARIES:= $(full_shared_jack_libs)
Ying Wang6f9bd2a2016-03-29 12:41:42 -0700384$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
Ying Wang956dccc2015-08-28 11:47:03 -0700385
386endif # need_compile_java
Colin Cross79e2f732016-12-21 14:29:13 -0800387endif # LOCAL_JACK_ENABLED
Dan Willemsen62dfb592016-07-08 21:33:05 -0700388
389
390###########################################################
391# Verify that all libraries are safe to use
392###########################################################
393ifndef LOCAL_IS_HOST_MODULE
Dan Willemsen62dfb592016-07-08 21:33:05 -0700394ifeq ($(LOCAL_SDK_VERSION),system_current)
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700395my_link_type := java:system
396my_warn_types := java:platform
397my_allowed_types := java:sdk java:system
Dan Willemsen62dfb592016-07-08 21:33:05 -0700398else ifneq ($(LOCAL_SDK_VERSION),)
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700399my_link_type := java:sdk
400my_warn_types := java:system java:platform
401my_allowed_types := java:sdk
Dan Willemsen62dfb592016-07-08 21:33:05 -0700402else
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700403my_link_type := java:platform
404my_warn_types :=
405my_allowed_types := java:sdk java:system java:platform
Dan Willemsen62dfb592016-07-08 21:33:05 -0700406endif
Dan Willemsen62dfb592016-07-08 21:33:05 -0700407
Dan Willemsenb47d4e92017-04-08 00:31:31 -0700408my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES))
409my_link_deps += $(addprefix APPS:,$(apk_libraries))
410
411my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
412my_common := COMMON
413include $(BUILD_SYSTEM)/link_type.mk
Dan Willemsen62dfb592016-07-08 21:33:05 -0700414endif # !LOCAL_IS_HOST_MODULE