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. If it is < 24 14# pass "1.7" to the tools, if it is unset, >= 24 or "current" 15# pass "1.8". 16# 17# The LOCAL_SDK_VERSION behavior is to ensure that, by default, 18# code that is expected to run on older releases of Android 19# does not use any 1.8 language features that are not supported 20# on earlier runtimes (like default / static interface methods). 21# Modules can override this logic by specifying 22# LOCAL_JAVA_LANGUAGE_VERSION explicitly. 23ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION)) 24 ifdef LOCAL_IS_HOST_MODULE 25 # Host modules always default to 1.9 26 LOCAL_JAVA_LANGUAGE_VERSION := 1.9 27 else 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_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 36 LOCAL_JAVA_LANGUAGE_VERSION := 1.9 37 endif 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)) 70ifneq ($(proto_sources),) 71proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) 72 73proto_java_intemediate_dir := $(intermediates.COMMON)/proto 74proto_java_sources_dir := $(proto_java_intemediate_dir)/src 75proto_java_srcjar := $(intermediates.COMMON)/proto.srcjar 76 77LOCAL_SRCJARS += $(proto_java_srcjar) 78 79$(proto_java_srcjar): PRIVATE_PROTO_INCLUDES := $(TOP) 80$(proto_java_srcjar): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath) 81$(proto_java_srcjar): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir) 82$(proto_java_srcjar): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) 83ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) 84 $(proto_java_srcjar): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out 85 $(proto_java_srcjar): PRIVATE_PROTOC_FLAGS += --plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-javamicro 86 $(proto_java_srcjar): $(HOST_OUT_EXECUTABLES)/protoc-gen-javamicro 87else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) 88 $(proto_java_srcjar): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out 89 $(proto_java_srcjar): PRIVATE_PROTOC_FLAGS += --plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-javanano 90 $(proto_java_srcjar): $(HOST_OUT_EXECUTABLES)/protoc-gen-javanano 91else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream) 92 $(proto_java_srcjar): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javastream_out 93 $(proto_java_srcjar): PRIVATE_PROTOC_FLAGS += --plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-javastream 94 $(proto_java_srcjar): $(HOST_OUT_EXECUTABLES)/protoc-gen-javastream 95else 96 $(proto_java_srcjar): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out 97endif 98$(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) 99$(proto_java_srcjar) : $(proto_sources_fullpath) $(PROTOC) $(SOONG_ZIP) 100 $(call transform-proto-to-java) 101 102#TODO: protoc should output the dependencies introduced by imports. 103 104ALL_MODULES.$(my_register_name).PROTO_FILES := $(proto_sources_fullpath) 105endif # proto_sources 106 107######################################### 108## Java resources 109 110# Look for resource files in any specified directories. 111# Non-java and non-doc files will be picked up as resources 112# and included in the output jar file. 113java_resource_file_groups := 114 115LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS)) 116ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),) 117 # This makes a list of words like 118 # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>: 119 # where each of the files is relative to the directory it's grouped with. 120 # Directories that don't contain any resource files will result in groups 121 # that end with a colon, and they are stripped out in the next step. 122 java_resource_file_groups += \ 123 $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \ 124 $(subst $(space),:,$(strip \ 125 $(LOCAL_PATH)/$(dir): \ 126 $(patsubst ./%,%,$(sort $(shell cd $(LOCAL_PATH)/$(dir) && \ 127 find . \ 128 -type d -a -name ".svn" -prune -o \ 129 -type f \ 130 -a \! -name "*.java" \ 131 -a \! -name "package.html" \ 132 -a \! -name "overview.html" \ 133 -a \! -name ".*.swp" \ 134 -a \! -name ".DS_Store" \ 135 -a \! -name "*~" \ 136 -print \ 137 ))) \ 138 )) \ 139 ) 140 java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups)) 141endif # LOCAL_JAVA_RESOURCE_DIRS 142 143ifneq ($(LOCAL_JAVA_RESOURCE_FILES),) 144 # Converts LOCAL_JAVA_RESOURCE_FILES := <file> to $(dir $(file))::$(notdir $(file)) 145 # and LOCAL_JAVA_RESOURCE_FILES := <dir>:<file> to <dir>::<file> 146 java_resource_file_groups += $(strip $(foreach res,$(LOCAL_JAVA_RESOURCE_FILES), \ 147 $(eval _file := $(call word-colon,2,$(res))) \ 148 $(if $(_file), \ 149 $(eval _base := $(call word-colon,1,$(res))), \ 150 $(eval _base := $(dir $(res))) \ 151 $(eval _file := $(notdir $(res)))) \ 152 $(if $(filter /%, \ 153 $(filter-out $(OUT_DIR)/%,$(_base) $(_file))), \ 154 $(call pretty-error,LOCAL_JAVA_RESOURCE_FILES may not include absolute paths: $(_base) $(_file))) \ 155 $(patsubst %/,%,$(_base))::$(_file))) 156 157endif # LOCAL_JAVA_RESOURCE_FILES 158 159ifdef java_resource_file_groups 160 # The full paths to all resources, used for dependencies. 161 java_resource_sources := \ 162 $(foreach group,$(java_resource_file_groups), \ 163 $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \ 164 $(wordlist 2,9999,$(subst :,$(space),$(group))) \ 165 ) \ 166 ) 167 # The arguments to jar that will include these files in a jar file. 168 # Quote the file name to handle special characters (such as #) correctly. 169 extra_jar_args := \ 170 $(foreach group,$(java_resource_file_groups), \ 171 $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \ 172 $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \ 173 ) \ 174 ) 175 java_resource_file_groups := 176else 177 java_resource_sources := 178 extra_jar_args := 179endif # java_resource_file_groups 180 181##################################### 182## Warn if there is unrecognized file in LOCAL_SRC_FILES. 183my_unknown_src_files := $(filter-out \ 184 %.java %.aidl %.proto %.logtags, \ 185 $(LOCAL_SRC_FILES) $(LOCAL_INTERMEDIATE_SOURCES) $(LOCAL_GENERATED_SOURCES)) 186ifneq ($(my_unknown_src_files),) 187$(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unknown_src_files)) 188endif 189 190###################################### 191## PRIVATE java vars 192# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, 193# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. 194# You have to set up the dependency in some other way. 195need_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)) 196ifdef need_compile_java 197 198annotation_processor_flags := 199annotation_processor_deps := 200annotation_processor_jars := 201 202# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS 203ifeq ($(RUN_ERROR_PRONE),true) 204annotation_processor_jars += $(ERROR_PRONE_JARS) 205LOCAL_JAVACFLAGS += $(ERROR_PRONE_FLAGS) 206LOCAL_JAVACFLAGS += '-Xplugin:ErrorProne $(ERROR_PRONE_CHECKS) $(LOCAL_ERROR_PRONE_FLAGS)' 207endif 208 209ifdef LOCAL_ANNOTATION_PROCESSORS 210 annotation_processor_jars += $(call java-lib-files,$(LOCAL_ANNOTATION_PROCESSORS),true) 211 212 # b/25860419: annotation processors must be explicitly specified for grok 213 annotation_processor_flags += $(foreach class,$(LOCAL_ANNOTATION_PROCESSOR_CLASSES),-processor $(class)) 214endif 215 216ifneq (,$(strip $(annotation_processor_jars))) 217annotation_processor_flags += -processorpath $(call normalize-path-list,$(annotation_processor_jars)) 218annotation_processor_deps += $(annotation_processor_jars) 219endif 220 221full_static_java_libs := $(call java-lib-files,$(LOCAL_STATIC_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 222full_static_java_header_libs := $(call java-lib-header-files,$(LOCAL_STATIC_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) 223 224$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs) 225$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_HEADER_LIBRARIES := $(full_static_java_header_libs) 226 227$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) 228$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR) 229 230$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes 231$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANNO_INTERMEDIATES_DIR := $(intermediates.COMMON)/anno 232$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src 233$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES := 234$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources) 235$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file) 236 237$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS) 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_stubs_current 300 sdk_lib_suffix := .stubs 301 else ifeq (system_current,$(LOCAL_SDK_VERSION)) 302 sdk_module := android_system_stubs_current 303 sdk_lib_suffix := .stubs.system 304 else ifeq (test_current,$(LOCAL_SDK_VERSION)) 305 sdk_module := android_test_stubs_current 306 sdk_lib_suffix := .stubs.test 307 else ifeq (core_current,$(LOCAL_SDK_VERSION)) 308 sdk_module := core.current.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_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(ALL_DEPS.$(LOCAL_MODULE).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 ($(LOCAL_JAVA_LANGUAGE_VERSION),1.9) 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 491ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \ 492 $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR) 493 494 495########################################################## 496# Copy NOTICE files of transitive static dependencies 497# Don't do this in mm, since many of the targets won't exist. 498installed_static_library_notice_file_targets := \ 499 $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ 500 NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST$(if $(my_host_cross),_CROSS,),TARGET)-JAVA_LIBRARIES-$(lib)) 501 502$(notice_target): | $(installed_static_library_notice_file_targets) 503$(LOCAL_INSTALLED_MODULE): | $(notice_target) 504 505########################################################### 506# Verify that all libraries are safe to use 507########################################################### 508ifndef LOCAL_IS_HOST_MODULE 509ifeq ($(LOCAL_SDK_VERSION),system_current) 510my_link_type := java:system 511my_warn_types := 512my_allowed_types := java:sdk java:system java:core 513else ifneq (,$(call has-system-sdk-version,$(LOCAL_SDK_VERSION))) 514my_link_type := java:system 515my_warn_types := 516my_allowed_types := java:sdk java:system java:core 517else ifeq ($(LOCAL_SDK_VERSION),core_current) 518my_link_type := java:core 519my_warn_types := 520my_allowed_types := java:core 521else ifneq ($(LOCAL_SDK_VERSION),) 522my_link_type := java:sdk 523my_warn_types := 524my_allowed_types := java:sdk java:core 525else 526my_link_type := java:platform 527my_warn_types := 528my_allowed_types := java:sdk java:system java:platform java:core 529endif 530 531my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES)) 532my_link_deps += $(addprefix APPS:,$(apk_libraries)) 533 534my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) 535my_common := COMMON 536include $(BUILD_SYSTEM)/link_type.mk 537endif # !LOCAL_IS_HOST_MODULE 538 539ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)) 540 541SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \ 542 $(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems) 543SOONG_CONV.$(LOCAL_MODULE).DEPS := \ 544 $(SOONG_CONV.$(LOCAL_MODULE).DEPS) \ 545 $(LOCAL_STATIC_JAVA_LIBRARIES) \ 546 $(LOCAL_JAVA_LIBRARIES) \ 547 $(LOCAL_JNI_SHARED_LIBRARIES) 548SOONG_CONV.$(LOCAL_MODULE).TYPE := java 549SOONG_CONV.$(LOCAL_MODULE).MAKEFILES := \ 550 $(SOONG_CONV.$(LOCAL_MODULE).MAKEFILES) $(LOCAL_MODULE_MAKEFILE) 551SOONG_CONV.$(LOCAL_MODULE).INSTALLED := \ 552 $(SOONG_CONV.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE) 553SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE) 554 555endif 556