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