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