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