• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Common to host and target Java modules.
2
3my_soong_problems :=
4
5ifneq ($(filter ../%,$(LOCAL_SRC_FILES)),)
6my_soong_problems += dotdot_srcs
7endif
8
9ifneq (,$(LOCAL_JNI_SHARED_LIBRARIES))
10my_soong_problems += jni_libs
11endif
12
13###########################################################
14## Java version
15###########################################################
16# Use the LOCAL_JAVA_LANGUAGE_VERSION if it is set, otherwise
17# use one based on the LOCAL_SDK_VERSION. If it is < 24
18# pass "1.7" to the tools, if it is unset, >= 24 or "current"
19# pass "1.8".
20#
21# The LOCAL_SDK_VERSION behavior is to ensure that, by default,
22# code that is expected to run on older releases of Android
23# does not use any 1.8 language features that are not supported
24# on earlier runtimes (like default / static interface methods).
25# Modules can override this logic by specifying
26# LOCAL_JAVA_LANGUAGE_VERSION explicitly.
27ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION))
28  ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_18_SUPPORT)))
29    LOCAL_JAVA_LANGUAGE_VERSION := 1.7
30  else ifneq (,$(filter $(LOCAL_SDK_VERSION), $(TARGET_SDK_VERSIONS_WITHOUT_JAVA_19_SUPPORT)))
31    LOCAL_JAVA_LANGUAGE_VERSION := 1.8
32  else ifneq (,$(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS_USE_PREBUILT_SDK))
33    # TODO(ccross): allow 1.9 for current and unbundled once we have SDK system modules
34    LOCAL_JAVA_LANGUAGE_VERSION := 1.8
35  else
36    # DEFAULT_JAVA_LANGUAGE_VERSION is 1.8, unless TARGET_OPENJDK9 in which case it is 1.9
37    LOCAL_JAVA_LANGUAGE_VERSION := $(DEFAULT_JAVA_LANGUAGE_VERSION)
38  endif
39endif
40LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION)
41
42###########################################################
43
44# OpenJDK versions up to 8 shipped with bootstrap and tools jars
45# (rt.jar, jce.jar, tools.jar etc.). These are no longer part of
46# OpenJDK 9, but we still make them available for host tools that
47# are targeting older versions.
48USE_HOST_BOOTSTRAP_JARS := true
49ifeq (,$(filter $(LOCAL_JAVA_LANGUAGE_VERSION), 1.6 1.7 1.8))
50USE_HOST_BOOTSTRAP_JARS := false
51endif
52
53###########################################################
54
55# Drop HOST_JDK_TOOLS_JAR from classpath when targeting versions > 9 (which don't have it).
56# TODO: Remove HOST_JDK_TOOLS_JAR and all references to it once host
57# bootstrap jars are no longer supported (ie. when USE_HOST_BOOTSTRAP_JARS
58# is always false). http://b/38418220
59ifneq ($(USE_HOST_BOOTSTRAP_JARS),true)
60LOCAL_CLASSPATH := $(filter-out $(HOST_JDK_TOOLS_JAR),$(LOCAL_CLASSPATH))
61endif
62
63###########################################################
64## .proto files: Compile proto files to .java
65###########################################################
66ifeq ($(strip $(LOCAL_PROTOC_OPTIMIZE_TYPE)),)
67  LOCAL_PROTOC_OPTIMIZE_TYPE := lite
68endif
69proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
70# Because names of the .java files compiled from .proto files are unknown until the
71# .proto files are compiled, we use a timestamp file as depedency.
72proto_java_sources_file_stamp :=
73ifneq ($(proto_sources),)
74proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
75
76proto_java_intemediate_dir := $(intermediates.COMMON)/proto
77proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
78proto_java_sources_dir := $(proto_java_intemediate_dir)/src
79
80$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
81$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
82$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
83$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
84ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
85$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
86else
87  ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
88$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
89  else
90    ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream)
91$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javastream_out
92$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS += --plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-javastream
93$(proto_java_sources_file_stamp): $(HOST_OUT_EXECUTABLES)/protoc-gen-javastream
94    else
95$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
96    endif
97  endif
98endif
99$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(if $(filter lite,$(LOCAL_PROTOC_OPTIMIZE_TYPE)),lite$(if $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS),:,),)$(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
100$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
101	$(call transform-proto-to-java)
102
103#TODO: protoc should output the dependencies introduced by imports.
104
105ALL_MODULES.$(my_register_name).PROTO_FILES := $(proto_sources_fullpath)
106endif # proto_sources
107
108#########################################
109## Java resources
110
111# Look for resource files in any specified directories.
112# Non-java and non-doc files will be picked up as resources
113# and included in the output jar file.
114java_resource_file_groups :=
115
116LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
117ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
118  # This makes a list of words like
119  #     <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>:
120  # where each of the files is relative to the directory it's grouped with.
121  # Directories that don't contain any resource files will result in groups
122  # that end with a colon, and they are stripped out in the next step.
123  java_resource_file_groups += \
124    $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
125	$(subst $(space),:,$(strip \
126		$(LOCAL_PATH)/$(dir): \
127	    $(patsubst ./%,%,$(sort $(shell cd $(LOCAL_PATH)/$(dir) && \
128		find . \
129		    -type d -a -name ".svn" -prune -o \
130		    -type f \
131			-a \! -name "*.java" \
132			-a \! -name "package.html" \
133			-a \! -name "overview.html" \
134			-a \! -name ".*.swp" \
135			-a \! -name ".DS_Store" \
136			-a \! -name "*~" \
137			-print \
138		    ))) \
139	)) \
140    )
141  java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
142endif # LOCAL_JAVA_RESOURCE_DIRS
143
144ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
145  # Converts LOCAL_JAVA_RESOURCE_FILES := <file> to $(dir $(file))::$(notdir $(file))
146  # and LOCAL_JAVA_RESOURCE_FILES := <dir>:<file> to <dir>::<file>
147  java_resource_file_groups += $(strip $(foreach res,$(LOCAL_JAVA_RESOURCE_FILES), \
148    $(eval _file := $(call word-colon,2,$(res))) \
149    $(if $(_file), \
150      $(eval _base := $(call word-colon,1,$(res))), \
151      $(eval _base := $(dir $(res))) \
152        $(eval _file := $(notdir $(res)))) \
153    $(if $(filter /%, \
154      $(filter-out $(OUT_DIR)/%,$(_base) $(_file))), \
155        $(call pretty-error,LOCAL_JAVA_RESOURCE_FILES may not include absolute paths: $(_base) $(_file))) \
156    $(patsubst %/,%,$(_base))::$(_file)))
157
158endif # LOCAL_JAVA_RESOURCE_FILES
159
160ifdef java_resource_file_groups
161  # The full paths to all resources, used for dependencies.
162  java_resource_sources := \
163    $(foreach group,$(java_resource_file_groups), \
164	$(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
165	    $(wordlist 2,9999,$(subst :,$(space),$(group))) \
166	) \
167    )
168  # The arguments to jar that will include these files in a jar file.
169  # Quote the file name to handle special characters (such as #) correctly.
170  extra_jar_args := \
171    $(foreach group,$(java_resource_file_groups), \
172	$(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
173	    $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
174	) \
175    )
176  java_resource_file_groups :=
177else
178  java_resource_sources :=
179  extra_jar_args :=
180endif # java_resource_file_groups
181
182#####################################
183## Warn if there is unrecognized file in LOCAL_SRC_FILES.
184my_unknown_src_files := $(filter-out \
185  %.java %.aidl %.proto %.logtags, \
186  $(LOCAL_SRC_FILES) $(LOCAL_INTERMEDIATE_SOURCES) $(LOCAL_GENERATED_SOURCES))
187ifneq ($(my_unknown_src_files),)
188$(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unknown_src_files))
189endif
190
191######################################
192## PRIVATE java vars
193# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
194# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
195# You have to set up the dependency in some other way.
196need_compile_java := $(strip $(all_java_sources)$(LOCAL_SRCJARS)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
197ifdef need_compile_java
198
199annotation_processor_flags :=
200annotation_processor_deps :=
201annotation_processor_jars :=
202
203# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS
204ifeq ($(RUN_ERROR_PRONE),true)
205annotation_processor_jars += $(ERROR_PRONE_JARS)
206LOCAL_JAVACFLAGS += $(ERROR_PRONE_FLAGS)
207LOCAL_JAVACFLAGS += '-Xplugin:ErrorProne $(ERROR_PRONE_CHECKS) $(LOCAL_ERROR_PRONE_FLAGS)'
208endif
209
210ifdef LOCAL_ANNOTATION_PROCESSORS
211  annotation_processor_jars += $(call java-lib-files,$(LOCAL_ANNOTATION_PROCESSORS),true)
212
213  # b/25860419: annotation processors must be explicitly specified for grok
214  annotation_processor_flags += $(foreach class,$(LOCAL_ANNOTATION_PROCESSOR_CLASSES),-processor $(class))
215endif
216
217ifneq (,$(strip $(annotation_processor_jars)))
218annotation_processor_flags += -processorpath $(call normalize-path-list,$(annotation_processor_jars))
219annotation_processor_deps += $(annotation_processor_jars)
220endif
221
222full_static_java_libs := $(call java-lib-files,$(LOCAL_STATIC_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
223full_static_java_header_libs := $(call java-lib-header-files,$(LOCAL_STATIC_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
224
225$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
226$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_HEADER_LIBRARIES := $(full_static_java_header_libs)
227
228$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
229$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
230
231$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
232$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANNO_INTERMEDIATES_DIR := $(intermediates.COMMON)/anno
233$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
234$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_PROTO_SOURCES := $(if $(proto_sources),true)
235$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/proto
236$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES :=
237$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
238$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
239
240$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
241
242# Sanity check class path vars.
243disallowed_deps := $(foreach sdk,$(TARGET_AVAILABLE_SDK_VERSIONS),$(call resolve-prebuilt-sdk-module,$(sdk)))
244disallowed_deps += $(foreach sdk,$(TARGET_AVAILABLE_SDK_VERSIONS),\
245  $(foreach sdk_lib,$(JAVA_SDK_LIBRARIES),$(call resolve-prebuilt-sdk-module,$(sdk),$(sdk_lib))))
246bad_deps := $(filter $(disallowed_deps),$(LOCAL_JAVA_LIBRARIES) $(LOCAL_STATIC_JAVA_LIBRARIES))
247ifneq (,$(bad_deps))
248  $(call pretty-error,SDK modules should not be depended on directly. Please use LOCAL_SDK_VERSION for $(bad_deps))
249endif
250
251full_java_bootclasspath_libs :=
252empty_bootclasspath :=
253my_system_modules :=
254exported_sdk_libs_files :=
255my_exported_sdk_libs_file :=
256
257ifndef LOCAL_IS_HOST_MODULE
258  sdk_libs :=
259
260  # When an sdk lib name is listed in LOCAL_JAVA_LIBRARIES, move it to LOCAL_SDK_LIBRARIES, so that
261  # it is correctly redirected to the stubs library.
262  LOCAL_SDK_LIBRARIES += $(filter $(JAVA_SDK_LIBRARIES),$(LOCAL_JAVA_LIBRARIES))
263  LOCAL_JAVA_LIBRARIES := $(filter-out $(JAVA_SDK_LIBRARIES),$(LOCAL_JAVA_LIBRARIES))
264
265  ifeq ($(LOCAL_SDK_VERSION),)
266    ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
267      # No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath.
268      empty_bootclasspath := ""
269      # Most users of LOCAL_NO_STANDARD_LIBRARIES really mean no framework libs,
270      # and manually add back the core libs.  The ones that don't are in soong
271      # now, so just always assume that they want the default system modules
272      my_system_modules := $(DEFAULT_SYSTEM_MODULES)
273    else  # LOCAL_NO_STANDARD_LIBRARIES
274      full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES))
275      LOCAL_JAVA_LIBRARIES := $(filter-out $(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES),$(LOCAL_JAVA_LIBRARIES))
276      my_system_modules := $(DEFAULT_SYSTEM_MODULES)
277    endif  # LOCAL_NO_STANDARD_LIBRARIES
278
279    ifneq (,$(TARGET_BUILD_APPS_USE_PREBUILT_SDK))
280      sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(call resolve-prebuilt-sdk-module,system_current,$(lib_name)))
281    else
282      # When SDK libraries are referenced from modules built without SDK, provide the all APIs to them
283      sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(lib_name))
284    endif
285  else
286    ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
287      $(call pretty-error,Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION)
288    endif
289    ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),)
290      $(call pretty-error,Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \
291             Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS))
292    endif
293
294    ifneq (,$(TARGET_BUILD_APPS_USE_PREBUILT_SDK)$(filter-out %current,$(LOCAL_SDK_VERSION)))
295      # TARGET_BUILD_APPS mode or numbered SDK. Use prebuilt modules.
296      sdk_module := $(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION))
297      sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(call resolve-prebuilt-sdk-module,$(LOCAL_SDK_VERSION),$(lib_name)))
298    else
299      # Note: the lib naming scheme must be kept in sync with build/soong/java/sdk_library.go.
300      sdk_lib_suffix = $(call pretty-error,sdk_lib_suffix was not set correctly)
301      ifeq (current,$(LOCAL_SDK_VERSION))
302        sdk_module := android_stubs_current
303        sdk_lib_suffix := .stubs
304      else ifeq (system_current,$(LOCAL_SDK_VERSION))
305        sdk_module := android_system_stubs_current
306        sdk_lib_suffix := .stubs.system
307      else ifeq (test_current,$(LOCAL_SDK_VERSION))
308        sdk_module := android_test_stubs_current
309        sdk_lib_suffix := .stubs.test
310      else ifeq (core_current,$(LOCAL_SDK_VERSION))
311        sdk_module := core.current.stubs
312        sdk_lib_suffix = $(call pretty-error,LOCAL_SDK_LIBRARIES not supported for LOCAL_SDK_VERSION = core_current)
313      endif
314      sdk_libs := $(foreach lib_name,$(LOCAL_SDK_LIBRARIES),$(lib_name)$(sdk_lib_suffix))
315    endif
316    full_java_bootclasspath_libs := $(call java-lib-header-files,$(sdk_module))
317  endif # LOCAL_SDK_VERSION
318
319  ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
320    ifneq ($(LOCAL_MODULE),jacocoagent)
321      ifeq ($(EMMA_INSTRUMENT),true)
322        ifneq ($(EMMA_INSTRUMENT_STATIC),true)
323          # For instrumented build, if Jacoco is not being included statically
324          # in instrumented packages then include Jacoco classes into the
325          # bootclasspath.
326          full_java_bootclasspath_libs += $(call java-lib-header-files,jacocoagent)
327        endif # EMMA_INSTRUMENT_STATIC
328      endif # EMMA_INSTRUMENT
329    endif # LOCAL_MODULE == jacocoagent
330  endif # LOCAL_NO_STANDARD_LIBRARIES
331
332  # In order to compile lambda code javac requires various invokedynamic-
333  # related classes to be present. This change adds stubs needed for
334  # javac to compile lambdas.
335  ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
336    ifdef TARGET_BUILD_APPS_USE_PREBUILT_SDK
337      full_java_bootclasspath_libs += $(call java-lib-header-files,sdk-core-lambda-stubs)
338    else
339      full_java_bootclasspath_libs += $(call java-lib-header-files,core-lambda-stubs)
340    endif
341  endif
342  full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(sdk_libs),$(LOCAL_IS_HOST_MODULE))
343  full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES) $(sdk_libs),$(LOCAL_IS_HOST_MODULE))
344  sdk_libs :=
345
346  # Files that contains the names of SDK libraries exported from dependencies. These will be re-exported.
347  # Note: No need to consider LOCAL_*_ANDROID_LIBRARIES and LOCAL_STATIC_JAVA_AAR_LIBRARIES. They are all appended to
348  # LOCAL_*_JAVA_LIBRARIES in java.mk
349  exported_sdk_libs_files := $(call exported-sdk-libs-files,$(LOCAL_JAVA_LIBRARIES) $(LOCAL_STATIC_JAVA_LIBRARIES))
350  # The file that contains the names of all SDK libraries that this module exports and re-exports
351  my_exported_sdk_libs_file := $(call local-intermediates-dir,COMMON)/exported-sdk-libs
352
353else # LOCAL_IS_HOST_MODULE
354
355  ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
356    ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
357      empty_bootclasspath := ""
358    else
359      full_java_bootclasspath_libs := $(call java-lib-header-files,$(addsuffix -hostdex,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)),true)
360    endif
361
362    my_system_modules := $(DEFAULT_SYSTEM_MODULES)
363    full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true)
364    full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),true)
365  else # !USE_CORE_LIB_BOOTCLASSPATH
366    # Give host-side tools a version of OpenJDK's standard libraries
367    # close to what they're targeting. As of Dec 2017, AOSP is only
368    # bundling OpenJDK 8 and 9, so nothing < 8 is available.
369    #
370    # When building with OpenJDK 8, the following should have no
371    # effect since those jars would be available by default.
372    #
373    # When building with OpenJDK 9 but targeting a version < 1.8,
374    # putting them on the bootclasspath means that:
375    # a) code can't (accidentally) refer to OpenJDK 9 specific APIs
376    # b) references to existing APIs are not reinterpreted in an
377    #    OpenJDK 9-specific way, eg. calls to subclasses of
378    #    java.nio.Buffer as in http://b/70862583
379    ifeq ($(USE_HOST_BOOTSTRAP_JARS),true)
380      full_java_bootclasspath_libs += $(ANDROID_JAVA8_HOME)/jre/lib/jce.jar
381      full_java_bootclasspath_libs += $(ANDROID_JAVA8_HOME)/jre/lib/rt.jar
382    endif
383    full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
384      $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
385    full_shared_java_header_libs := $(full_shared_java_libs)
386  endif # USE_CORE_LIB_BOOTCLASSPATH
387endif # !LOCAL_IS_HOST_MODULE
388
389ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS) $(full_java_bootclasspath_libs)
390
391# Export the SDK libs. The sdk library names listed in LOCAL_SDK_LIBRARIES are first exported.
392# Then sdk library names exported from dependencies are all re-exported.
393$(my_exported_sdk_libs_file): PRIVATE_EXPORTED_SDK_LIBS_FILES := $(exported_sdk_libs_files)
394$(my_exported_sdk_libs_file): PRIVATE_SDK_LIBS := $(sort $(LOCAL_SDK_LIBRARIES))
395$(my_exported_sdk_libs_file): $(exported_sdk_libs_files)
396	@echo "Export SDK libs $@"
397	$(hide) mkdir -p $(dir $@) && rm -f $@ $@.temp
398	$(if $(PRIVATE_SDK_LIBS),\
399		echo $(PRIVATE_SDK_LIBS) | tr ' ' '\n' > $@.temp,\
400		touch $@.temp)
401	$(if $(PRIVATE_EXPORTED_SDK_LIBS_FILES),\
402		cat $(PRIVATE_EXPORTED_SDK_LIBS_FILES) >> $@.temp)
403	$(hide) cat $@.temp | sort -u > $@
404	$(hide) rm -f $@.temp
405
406ifdef empty_bootclasspath
407  ifdef full_java_bootclasspath_libs
408    $(call pretty-error,internal error: empty_bootclasspath and full_java_bootclasspath_libs should not both be set)
409  endif
410endif
411
412full_java_system_modules_deps :=
413my_system_modules_dir :=
414$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_USE_SYSTEM_MODULES :=
415ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.9)
416  $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_USE_SYSTEM_MODULES := true
417  ifdef my_system_modules
418    ifneq ($(my_system_modules),none)
419      ifndef SOONG_SYSTEM_MODULES_$(my_system_modules)
420        $(call pretty-error, Invalid system modules $(my_system_modules))
421      endif
422      full_java_system_modules_deps := $(SOONG_SYSTEM_MODULES_$(my_system_modules))
423      my_system_modules_dir := $(patsubst %/lib/modules,%,$(SOONG_SYSTEM_MODULES_$(my_system_modules)))
424    endif
425  endif
426endif
427
428$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(full_java_bootclasspath_libs)
429$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EMPTY_BOOTCLASSPATH := $(empty_bootclasspath)
430$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES := $(my_system_modules)
431$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES_DIR := $(my_system_modules_dir)
432$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SYSTEM_MODULES_LIBS := $(call java-lib-files,$(SOONG_SYSTEM_MODULES_LIBS_$(my_system_modules)))
433$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PATCH_MODULE := $(LOCAL_PATCH_MODULE)
434
435ifndef LOCAL_IS_HOST_MODULE
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.
438apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES))
439ifneq ($(apk_libraries),)
440  link_apk_libraries := $(call app-lib-files,$(apk_libraries))
441  link_apk_header_libs := $(call app-lib-header-files,$(apk_libraries))
442
443  # link against the jar with full original names (before proguard processing).
444  full_shared_java_libs += $(link_apk_libraries)
445  full_shared_java_header_libs += $(link_apk_header_libs)
446endif
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.
451LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
452ifdef 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-pre-proguard.jar
462  ifneq ($(TURBINE_ENABLED),false)
463    link_instr_classes_header_jar := $(link_instr_intermediates_dir.COMMON)/classes-header.jar
464  else
465    link_instr_classes_header_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
466  endif
467  full_shared_java_libs += $(link_instr_classes_jar)
468  full_shared_java_header_libs += $(link_instr_classes_header_jar)
469endif  # LOCAL_INSTRUMENTATION_FOR
470endif  # LOCAL_IS_HOST_MODULE
471
472endif  # need_compile_java
473
474# We may want to add jar manifest or jar resource files even if there is no java code at all.
475$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
476jar_manifest_file :=
477ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
478jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
479$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
480else
481$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
482endif
483
484##########################################################
485
486full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
487full_java_header_libs := $(full_shared_java_header_libs) $(full_static_java_header_libs)
488
489$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs)
490$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
491$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SHARED_JAVA_HEADER_LIBRARIES := $(full_shared_java_header_libs)
492
493ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \
494    $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
495
496
497##########################################################
498# Copy NOTICE files of transitive static dependencies
499# Don't do this in mm, since many of the targets won't exist.
500ifeq ($(ONE_SHOT_MAKEFILE),)
501installed_static_library_notice_file_targets := \
502    $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
503      NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-JAVA_LIBRARIES-$(lib))
504else
505installed_static_library_notice_file_targets :=
506endif
507
508$(notice_target): | $(installed_static_library_notice_file_targets)
509$(LOCAL_INSTALLED_MODULE): | $(notice_target)
510
511###########################################################
512# Verify that all libraries are safe to use
513###########################################################
514ifndef LOCAL_IS_HOST_MODULE
515ifeq ($(LOCAL_SDK_VERSION),system_current)
516my_link_type := java:system
517my_warn_types :=
518my_allowed_types := java:sdk java:system java:core
519else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION)))
520my_link_type := java:system
521my_warn_types :=
522my_allowed_types := java:sdk java:system java:core
523else ifeq ($(LOCAL_SDK_VERSION),core_current)
524my_link_type := java:core
525my_warn_types :=
526my_allowed_types := java:core
527else ifneq ($(LOCAL_SDK_VERSION),)
528my_link_type := java:sdk
529my_warn_types :=
530my_allowed_types := java:sdk java:core
531else
532my_link_type := java:platform
533my_warn_types :=
534my_allowed_types := java:sdk java:system java:platform java:core
535endif
536
537ifdef LOCAL_AAPT2_ONLY
538my_link_type += aapt2_only
539endif
540ifeq ($(LOCAL_USE_AAPT2),true)
541my_allowed_types += aapt2_only
542endif
543
544my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES))
545my_link_deps += $(addprefix APPS:,$(apk_libraries))
546
547my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
548my_common := COMMON
549include $(BUILD_SYSTEM)/link_type.mk
550endif  # !LOCAL_IS_HOST_MODULE
551
552ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
553
554SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
555    $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems)
556SOONG_CONV.$(LOCAL_MODULE).DEPS := \
557    $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \
558    $(LOCAL_STATIC_JAVA_LIBRARIES) \
559    $(LOCAL_JAVA_LIBRARIES) \
560    $(LOCAL_JNI_SHARED_LIBRARIES)
561SOONG_CONV.$(LOCAL_MODULE).TYPE := java
562SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
563
564endif
565