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