Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 1 | # Common to host and target Java modules. |
| 2 | |
| 3 | ########################################################### |
Neil Fuller | ad02251 | 2016-01-29 14:22:29 +0000 | [diff] [blame] | 4 | ## Java version |
| 5 | ########################################################### |
Neil Fuller | decb797 | 2016-03-04 18:00:00 +0000 | [diff] [blame] | 6 | # Use the LOCAL_JAVA_LANGUAGE_VERSION if it is set, otherwise |
| 7 | # use one based on the LOCAL_SDK_VERSION. If it is < 24 |
| 8 | # pass "1.7" to the tools, if it is unset, >= 24 or "current" |
| 9 | # pass "1.8". |
| 10 | # |
| 11 | # The LOCAL_SDK_VERSION behavior is to ensure that, by default, |
| 12 | # code that is expected to run on older releases of Android |
| 13 | # does not use any 1.8 language features that are not supported |
| 14 | # on earlier runtimes (like default / static interface methods). |
| 15 | # Modules can override this logic by specifying |
| 16 | # LOCAL_JAVA_LANGUAGE_VERSION explicitly. |
Neil Fuller | ad02251 | 2016-01-29 14:22:29 +0000 | [diff] [blame] | 17 | ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION)) |
Neil Fuller | decb797 | 2016-03-04 18:00:00 +0000 | [diff] [blame] | 18 | private_sdk_versions_without_any_java_18_support := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
| 19 | ifneq (,$(filter $(LOCAL_SDK_VERSION), $(private_sdk_versions_without_any_java_18_support))) |
Nicolas Geoffray | 8d772e2 | 2016-02-29 12:07:00 +0000 | [diff] [blame] | 20 | LOCAL_JAVA_LANGUAGE_VERSION := 1.7 |
Neil Fuller | decb797 | 2016-03-04 18:00:00 +0000 | [diff] [blame] | 21 | else |
Tobias Thierer | d61f28b | 2017-07-18 16:37:07 +0100 | [diff] [blame] | 22 | ifneq ($(EXPERIMENTAL_USE_OPENJDK9),true) |
| 23 | LOCAL_JAVA_LANGUAGE_VERSION := 1.8 |
| 24 | else |
| 25 | LOCAL_JAVA_LANGUAGE_VERSION := 1.9 |
| 26 | endif |
Nicolas Geoffray | 8d772e2 | 2016-02-29 12:07:00 +0000 | [diff] [blame] | 27 | endif |
Neil Fuller | ad02251 | 2016-01-29 14:22:29 +0000 | [diff] [blame] | 28 | endif |
| 29 | LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION) |
| 30 | |
| 31 | ########################################################### |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 32 | ## .proto files: Compile proto files to .java |
| 33 | ########################################################### |
| 34 | proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) |
| 35 | # Because names of the .java files compiled from .proto files are unknown until the |
| 36 | # .proto files are compiled, we use a timestamp file as depedency. |
| 37 | proto_java_sources_file_stamp := |
| 38 | ifneq ($(proto_sources),) |
| 39 | proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) |
| 40 | |
Dan Willemsen | cf324af | 2016-12-21 17:37:00 -0800 | [diff] [blame] | 41 | proto_java_intemediate_dir := $(intermediates.COMMON)/proto |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 42 | proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp |
| 43 | proto_java_sources_dir := $(proto_java_intemediate_dir)/src |
| 44 | |
| 45 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP) |
| 46 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath) |
| 47 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir) |
| 48 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) |
| 49 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out |
| 50 | else |
| 51 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) |
| 52 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out |
| 53 | else |
Joe Onorato | c05a8ee | 2016-10-05 18:01:10 -0700 | [diff] [blame] | 54 | ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream) |
| 55 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javastream_out |
| 56 | $(proto_java_sources_file_stamp): $(HOST_OUT_EXECUTABLES)/protoc-gen-javastream |
| 57 | else |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 58 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out |
Joe Onorato | c05a8ee | 2016-10-05 18:01:10 -0700 | [diff] [blame] | 59 | endif |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 60 | endif |
| 61 | endif |
| 62 | $(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) |
| 63 | $(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS) |
| 64 | $(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC) |
| 65 | $(call transform-proto-to-java) |
| 66 | |
| 67 | #TODO: protoc should output the dependencies introduced by imports. |
Ying Wang | d5ffec9 | 2016-03-01 22:05:25 -0800 | [diff] [blame] | 68 | |
| 69 | ALL_MODULES.$(my_register_name).PROTO_FILES := $(proto_sources_fullpath) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 70 | endif # proto_sources |
| 71 | |
| 72 | ######################################### |
| 73 | ## Java resources |
| 74 | |
| 75 | # Look for resource files in any specified directories. |
| 76 | # Non-java and non-doc files will be picked up as resources |
| 77 | # and included in the output jar file. |
| 78 | java_resource_file_groups := |
| 79 | |
| 80 | LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS)) |
| 81 | ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),) |
| 82 | # This makes a list of words like |
| 83 | # <dir1>::<file1>:<file2> <dir2>::<file1> <dir3>: |
| 84 | # where each of the files is relative to the directory it's grouped with. |
| 85 | # Directories that don't contain any resource files will result in groups |
| 86 | # that end with a colon, and they are stripped out in the next step. |
| 87 | java_resource_file_groups += \ |
| 88 | $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \ |
| 89 | $(subst $(space),:,$(strip \ |
| 90 | $(LOCAL_PATH)/$(dir): \ |
Dan Willemsen | 7c3e3f8 | 2015-09-29 16:30:21 -0700 | [diff] [blame] | 91 | $(patsubst ./%,%,$(sort $(shell cd $(LOCAL_PATH)/$(dir) && \ |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 92 | find . \ |
| 93 | -type d -a -name ".svn" -prune -o \ |
| 94 | -type f \ |
| 95 | -a \! -name "*.java" \ |
| 96 | -a \! -name "package.html" \ |
| 97 | -a \! -name "overview.html" \ |
| 98 | -a \! -name ".*.swp" \ |
| 99 | -a \! -name ".DS_Store" \ |
| 100 | -a \! -name "*~" \ |
| 101 | -print \ |
Dan Willemsen | 7c3e3f8 | 2015-09-29 16:30:21 -0700 | [diff] [blame] | 102 | ))) \ |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 103 | )) \ |
| 104 | ) |
| 105 | java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups)) |
| 106 | endif # LOCAL_JAVA_RESOURCE_DIRS |
| 107 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 108 | ifneq ($(LOCAL_JAVA_RESOURCE_FILES),) |
Colin Cross | 34a9885 | 2017-09-22 13:34:10 -0700 | [diff] [blame] | 109 | # Converts LOCAL_JAVA_RESOURCE_FILES := <file> to $(dir $(file))::$(notdir $(file)) |
| 110 | # and LOCAL_JAVA_RESOURCE_FILES := <dir>:<file> to <dir>::<file> |
| 111 | java_resource_file_groups += $(strip $(foreach res,$(LOCAL_JAVA_RESOURCE_FILES), \ |
| 112 | $(eval _file := $(call word-colon,2,$(res))) \ |
| 113 | $(if $(_file), \ |
| 114 | $(eval _base := $(call word-colon,1,$(res))), \ |
| 115 | $(eval _base := $(dir $(res))) \ |
| 116 | $(eval _file := $(notdir $(res)))) \ |
| 117 | $(if $(filter /%, \ |
| 118 | $(filter-out $(OUT_DIR)/%,$(_base) $(_file))), \ |
| 119 | $(call pretty-error,LOCAL_JAVA_RESOURCE_FILES may not include absolute paths: $(_base) $(_file))) \ |
| 120 | $(patsubst %/,%,$(_base))::$(_file))) |
| 121 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 122 | endif # LOCAL_JAVA_RESOURCE_FILES |
| 123 | |
| 124 | ifdef java_resource_file_groups |
| 125 | # The full paths to all resources, used for dependencies. |
| 126 | java_resource_sources := \ |
| 127 | $(foreach group,$(java_resource_file_groups), \ |
| 128 | $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \ |
| 129 | $(wordlist 2,9999,$(subst :,$(space),$(group))) \ |
| 130 | ) \ |
| 131 | ) |
| 132 | # The arguments to jar that will include these files in a jar file. |
| 133 | # Quote the file name to handle special characters (such as #) correctly. |
| 134 | extra_jar_args := \ |
| 135 | $(foreach group,$(java_resource_file_groups), \ |
| 136 | $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \ |
| 137 | $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \ |
| 138 | ) \ |
| 139 | ) |
| 140 | java_resource_file_groups := |
| 141 | else |
| 142 | java_resource_sources := |
| 143 | extra_jar_args := |
| 144 | endif # java_resource_file_groups |
| 145 | |
Ying Wang | f8d15d6 | 2016-04-26 15:49:56 -0700 | [diff] [blame] | 146 | ##################################### |
| 147 | ## Warn if there is unrecognized file in LOCAL_SRC_FILES. |
| 148 | my_unknown_src_files := $(filter-out \ |
| 149 | %.java %.aidl %.proto %.logtags %.fs %.rs, \ |
| 150 | $(LOCAL_SRC_FILES) $(LOCAL_INTERMEDIATE_SOURCES) $(LOCAL_GENERATED_SOURCES)) |
| 151 | ifneq ($(my_unknown_src_files),) |
| 152 | $(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unknown_src_files)) |
| 153 | endif |
| 154 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 155 | ###################################### |
| 156 | ## PRIVATE java vars |
| 157 | # LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, |
| 158 | # but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. |
| 159 | # You have to set up the dependency in some other way. |
| 160 | need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED)) |
| 161 | ifdef need_compile_java |
| 162 | |
Colin Cross | e8ee68b | 2017-04-07 16:28:41 -0700 | [diff] [blame] | 163 | annotation_processor_flags := |
| 164 | annotation_processor_deps := |
| 165 | |
| 166 | ifdef LOCAL_ANNOTATION_PROCESSORS |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 167 | annotation_processor_jars := $(call java-lib-files,$(LOCAL_ANNOTATION_PROCESSORS),true) |
Colin Cross | e8ee68b | 2017-04-07 16:28:41 -0700 | [diff] [blame] | 168 | annotation_processor_flags += -processorpath $(call normalize-path-list,$(annotation_processor_jars)) |
| 169 | annotation_processor_deps += $(annotation_processor_jars) |
| 170 | |
| 171 | # b/25860419: annotation processors must be explicitly specified for grok |
| 172 | annotation_processor_flags += $(foreach class,$(LOCAL_ANNOTATION_PROCESSOR_CLASSES),-processor $(class)) |
| 173 | |
| 174 | annotation_processor_jars := |
| 175 | endif |
| 176 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 177 | full_static_java_libs := \ |
| 178 | $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ |
| 179 | $(call intermediates-dir-for, \ |
Colin Cross | 941b682 | 2017-03-29 13:53:29 -0700 | [diff] [blame] | 180 | JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jar) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 181 | |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 182 | full_static_java_header_libs := \ |
| 183 | $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ |
| 184 | $(call intermediates-dir-for, \ |
| 185 | JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes-header.jar) |
| 186 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 187 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 188 | $(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] | 189 | |
| 190 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR) |
| 191 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR) |
| 192 | |
| 193 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes |
Colin Cross | e8ee68b | 2017-04-07 16:28:41 -0700 | [diff] [blame] | 194 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANNO_INTERMEDIATES_DIR := $(intermediates.COMMON)/anno |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 195 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src |
Dan Willemsen | cf324af | 2016-12-21 17:37:00 -0800 | [diff] [blame] | 196 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_PROTO_SOURCES := $(if $(proto_sources),true) |
| 197 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROTO_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/proto |
| 198 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HAS_RS_SOURCES := |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 199 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources) |
Colin Cross | dfc45ec | 2017-05-26 15:22:02 -0700 | [diff] [blame] | 200 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 201 | |
| 202 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS) |
| 203 | |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 204 | full_java_bootclasspath_libs := |
| 205 | empty_bootclasspath := |
| 206 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 207 | # full_java_libs: The list of files that should be used as the classpath. |
| 208 | # Using this list as a dependency list WILL NOT WORK. |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 209 | ifndef LOCAL_IS_HOST_MODULE |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 210 | ifeq ($(LOCAL_SDK_VERSION),) |
| 211 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 212 | # 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] | 213 | empty_bootclasspath := "" |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 214 | else # LOCAL_NO_STANDARD_LIBRARIES |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame^] | 215 | full_java_bootclasspath_libs := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES)) |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 216 | endif # LOCAL_NO_STANDARD_LIBRARIES |
| 217 | else |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame^] | 218 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 219 | $(call pretty-error,Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION) |
| 220 | endif |
| 221 | ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),) |
| 222 | $(call pretty-error,Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \ |
| 223 | Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS)) |
| 224 | endif |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 225 | ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) |
| 226 | # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 227 | full_java_bootclasspath_libs := $(call java-lib-header-files,android_stubs_current) |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 228 | else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current) |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 229 | full_java_bootclasspath_libs := $(call java-lib-header-files,android_system_stubs_current) |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 230 | else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current) |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 231 | full_java_bootclasspath_libs := $(call java-lib-header-files,android_test_stubs_current) |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 232 | else |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 233 | full_java_bootclasspath_libs := $(call java-lib-header-files,sdk_v$(LOCAL_SDK_VERSION)) |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 234 | endif # current, system_current, or test_current |
| 235 | endif # LOCAL_SDK_VERSION |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 236 | |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 237 | # In order to compile lambda code javac requires various invokedynamic- |
| 238 | # related classes to be present. This change adds stubs needed for |
| 239 | # javac to compile lambdas. |
| 240 | my_additional_javac_libs := |
| 241 | ifndef TARGET_BUILD_APPS |
| 242 | # TODO: support to build lamdbas using javac in unbundled build. |
| 243 | # We may need to check in a prebuilt core-lambda-stubs to prebuilts/sdk. |
| 244 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 245 | my_additional_javac_libs := core-lambda-stubs |
| 246 | endif |
| 247 | endif |
Neil Fuller | b08544e | 2016-02-19 10:37:22 +0000 | [diff] [blame] | 248 | |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 249 | full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE)) |
| 250 | full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE)) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 251 | |
| 252 | else # LOCAL_IS_HOST_MODULE |
| 253 | |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 254 | ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true) |
| 255 | ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 256 | empty_bootclasspath := "" |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 257 | else |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame^] | 258 | 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] | 259 | endif |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 260 | |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 261 | full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES),true) |
| 262 | full_shared_java_header_libs := $(call java-lib-header-files,$(LOCAL_JAVA_LIBRARIES),true) |
| 263 | else # !USE_CORE_LIB_BOOTCLASSPATH |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 264 | |
Colin Cross | f6bc1a1 | 2017-09-23 19:47:37 -0700 | [diff] [blame] | 265 | full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\ |
| 266 | $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES))) |
| 267 | endif # USE_CORE_LIB_BOOTCLASSPATH |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 268 | endif # !LOCAL_IS_HOST_MODULE |
| 269 | |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 270 | ifdef empty_bootclasspath |
| 271 | ifdef full_java_bootclasspath_libs |
| 272 | $(call pretty-error,internal error: empty_bootclasspath and full_java_bootclasspath_libs should not both be set) |
| 273 | endif |
| 274 | endif |
| 275 | |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame^] | 276 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := $(full_java_bootclasspath_libs) |
| 277 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EMPTY_BOOTCLASSPATH := $(empty_bootclasspath) |
Colin Cross | 1d1e5ef | 2017-09-23 18:19:05 -0700 | [diff] [blame] | 278 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 279 | full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 280 | full_java_header_libs := $(full_shared_java_header_libs) $(full_static_java_header_libs) |
| 281 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 282 | ifndef LOCAL_IS_HOST_MODULE |
| 283 | # This is set by packages that are linking to other packages that export |
| 284 | # shared libraries, allowing them to make use of the code in the linked apk. |
| 285 | apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES)) |
| 286 | ifneq ($(apk_libraries),) |
| 287 | link_apk_libraries := \ |
| 288 | $(foreach lib,$(apk_libraries), \ |
| 289 | $(call intermediates-dir-for, \ |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 290 | APPS,$(lib),,COMMON)/classes-pre-proguard.jar) |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 291 | link_apk_header_libs := \ |
| 292 | $(foreach lib,$(apk_libraries), \ |
| 293 | $(call intermediates-dir-for, \ |
| 294 | APPS,$(lib),,COMMON)/classes-header.jar) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 295 | |
| 296 | # link against the jar with full original names (before proguard processing). |
| 297 | full_shared_java_libs += $(link_apk_libraries) |
| 298 | full_java_libs += $(link_apk_libraries) |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 299 | full_java_header_libs += $(link_apk_header_libs) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 300 | endif |
| 301 | |
| 302 | # This is set by packages that contain instrumentation, allowing them to |
| 303 | # link against the package they are instrumenting. Currently only one such |
| 304 | # package is allowed. |
| 305 | LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR)) |
| 306 | ifdef LOCAL_INSTRUMENTATION_FOR |
| 307 | ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1) |
| 308 | $(error \ |
| 309 | $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined) |
| 310 | endif |
| 311 | |
| 312 | link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \ |
| 313 | APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON) |
| 314 | # link against the jar with full original names (before proguard processing). |
Colin Cross | 950f1ef | 2017-04-05 15:30:42 -0700 | [diff] [blame] | 315 | link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes-pre-proguard.jar |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 316 | link_instr_classes_header_jar := $(link_instr_intermediates_dir.COMMON)/classes-header.jar |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 317 | full_java_libs += $(link_instr_classes_jar) |
Nan Zhang | 9bd5405 | 2017-09-13 13:13:53 -0700 | [diff] [blame] | 318 | full_java_header_libs += $(link_instr_classes_header_jar) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 319 | endif # LOCAL_INSTRUMENTATION_FOR |
| 320 | endif # LOCAL_IS_HOST_MODULE |
| 321 | |
| 322 | endif # need_compile_java |
| 323 | |
| 324 | # We may want to add jar manifest or jar resource files even if there is no java code at all. |
| 325 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) |
| 326 | jar_manifest_file := |
| 327 | ifneq ($(strip $(LOCAL_JAR_MANIFEST)),) |
| 328 | jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST) |
| 329 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file) |
| 330 | else |
| 331 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := |
| 332 | endif |
| 333 | |
| 334 | ########################################################## |
| 335 | ifndef LOCAL_IS_HOST_MODULE |
| 336 | ## AAPT Flags |
| 337 | # aapt doesn't accept multiple --extra-packages flags. |
| 338 | # We have to collapse them into a single --extra-packages flag here. |
| 339 | LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS)) |
| 340 | ifdef LOCAL_AAPT_FLAGS |
| 341 | ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),) |
| 342 | aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS)) |
| 343 | aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags))) |
| 344 | aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages))) |
| 345 | LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \ |
| 346 | --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages)) |
| 347 | aapt_flags_extra_packages := |
| 348 | aapt_flags := |
| 349 | endif |
| 350 | endif |
| 351 | |
Ying Wang | 6f9bd2a | 2016-03-29 12:41:42 -0700 | [diff] [blame] | 352 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS) |
| 353 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS) |
| 354 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME) |
| 355 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 356 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 357 | ifdef aidl_sources |
| 358 | ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources) |
| 359 | endif |
Ying Wang | d5ffec9 | 2016-03-01 22:05:25 -0800 | [diff] [blame] | 360 | ifdef renderscript_sources |
| 361 | ALL_MODULES.$(my_register_name).RS_FILES := $(renderscript_sources_fullpath) |
| 362 | endif |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 363 | endif # !LOCAL_IS_HOST_MODULE |
| 364 | |
Ying Wang | 6f9bd2a | 2016-03-29 12:41:42 -0700 | [diff] [blame] | 365 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs) |
Nan Zhang | b3ec534 | 2017-08-31 21:43:04 +0000 | [diff] [blame] | 366 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 367 | |
| 368 | ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \ |
| 369 | $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR) |
| 370 | |
| 371 | ########################################################### |
| 372 | # JACK |
| 373 | ########################################################### |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 374 | ifdef LOCAL_JACK_ENABLED |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 375 | ifdef need_compile_java |
| 376 | |
Neil Fuller | ad02251 | 2016-01-29 14:22:29 +0000 | [diff] [blame] | 377 | LOCAL_JACK_FLAGS += -D jack.java.source.version=$(LOCAL_JAVA_LANGUAGE_VERSION) |
| 378 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 379 | full_static_jack_libs := \ |
| 380 | $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \ |
| 381 | $(call intermediates-dir-for, \ |
| 382 | JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jack) |
| 383 | |
| 384 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JACK_LIBRARIES := $(full_static_jack_libs) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 385 | |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 386 | full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE)) |
Colin Cross | b541aae | 2017-09-23 19:52:43 -0700 | [diff] [blame^] | 387 | ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) |
| 388 | my_jack_bootclasspath := $(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) |
| 389 | ifdef LOCAL_IS_HOST_MODULE |
| 390 | my_jack_bootclasspath := $(addsuffix -hostdex,$(my_jack_bootclasspath)) |
| 391 | endif |
| 392 | full_shared_jack_libs := $(call jack-lib-files,$(my_jack_bootclasspath),$(LOCAL_IS_HOST_MODULE)) $(full_shared_jack_libs) |
| 393 | endif |
Yohann Roussel | ae2fc81 | 2016-04-21 16:49:10 +0200 | [diff] [blame] | 394 | full_jack_deps := $(full_shared_jack_libs) |
| 395 | |
| 396 | ifndef LOCAL_IS_HOST_MODULE |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 397 | # Turn off .toc optimization for apps build as we cannot build dexdump. |
| 398 | ifeq (,$(TARGET_BUILD_APPS)) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 399 | full_jack_deps := $(patsubst %.jack, %.dex.toc, $(full_jack_deps)) |
Shinichiro Hamaji | f972a4a | 2015-12-09 18:06:20 +0900 | [diff] [blame] | 400 | endif |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 401 | endif # !LOCAL_IS_HOST_MODULE |
Yohann Roussel | 2dc79b1 | 2016-04-21 16:30:18 +0200 | [diff] [blame] | 402 | full_shared_jack_libs += $(LOCAL_JACK_CLASSPATH) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 403 | full_jack_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 404 | |
| 405 | ifndef LOCAL_IS_HOST_MODULE |
| 406 | # This is set by packages that are linking to other packages that export |
| 407 | # shared libraries, allowing them to make use of the code in the linked apk. |
| 408 | ifneq ($(apk_libraries),) |
| 409 | link_apk_jack_libraries := \ |
| 410 | $(foreach lib,$(apk_libraries), \ |
| 411 | $(call intermediates-dir-for, \ |
| 412 | APPS,$(lib),,COMMON)/classes.jack) |
| 413 | |
| 414 | # link against the jar with full original names (before proguard processing). |
| 415 | full_shared_jack_libs += $(link_apk_jack_libraries) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 416 | full_jack_deps += $(link_apk_jack_libraries) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 417 | endif |
| 418 | |
| 419 | # This is set by packages that contain instrumentation, allowing them to |
| 420 | # link against the package they are instrumenting. Currently only one such |
| 421 | # package is allowed. |
| 422 | ifdef LOCAL_INSTRUMENTATION_FOR |
| 423 | # link against the jar with full original names (before proguard processing). |
| 424 | link_instr_classes_jack := $(link_instr_intermediates_dir.COMMON)/classes.noshrob.jack |
Yohann Roussel | 2dc79b1 | 2016-04-21 16:30:18 +0200 | [diff] [blame] | 425 | full_shared_jack_libs += $(link_instr_classes_jack) |
Yohann Roussel | b7de0fb | 2015-11-03 18:33:21 +0100 | [diff] [blame] | 426 | full_jack_deps += $(link_instr_classes_jack) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 427 | endif # LOCAL_INSTRUMENTATION_FOR |
| 428 | endif # !LOCAL_IS_HOST_MODULE |
| 429 | |
| 430 | # Propagate local configuration options to this target. |
Yohann Roussel | b6232d9 | 2016-04-22 18:45:45 +0200 | [diff] [blame] | 431 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_SHARED_LIBRARIES:= $(full_shared_jack_libs) |
Ying Wang | 6f9bd2a | 2016-03-29 12:41:42 -0700 | [diff] [blame] | 432 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) |
Ying Wang | 956dccc | 2015-08-28 11:47:03 -0700 | [diff] [blame] | 433 | |
| 434 | endif # need_compile_java |
Colin Cross | 79e2f73 | 2016-12-21 14:29:13 -0800 | [diff] [blame] | 435 | endif # LOCAL_JACK_ENABLED |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 436 | |
| 437 | |
| 438 | ########################################################### |
| 439 | # Verify that all libraries are safe to use |
| 440 | ########################################################### |
| 441 | ifndef LOCAL_IS_HOST_MODULE |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 442 | ifeq ($(LOCAL_SDK_VERSION),system_current) |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 443 | my_link_type := java:system |
| 444 | my_warn_types := java:platform |
| 445 | my_allowed_types := java:sdk java:system |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 446 | else ifneq ($(LOCAL_SDK_VERSION),) |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 447 | my_link_type := java:sdk |
| 448 | my_warn_types := java:system java:platform |
| 449 | my_allowed_types := java:sdk |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 450 | else |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 451 | my_link_type := java:platform |
| 452 | my_warn_types := |
| 453 | my_allowed_types := java:sdk java:system java:platform |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 454 | endif |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 455 | |
Dan Willemsen | b47d4e9 | 2017-04-08 00:31:31 -0700 | [diff] [blame] | 456 | my_link_deps := $(addprefix JAVA_LIBRARIES:,$(LOCAL_STATIC_JAVA_LIBRARIES)) |
| 457 | my_link_deps += $(addprefix APPS:,$(apk_libraries)) |
| 458 | |
| 459 | my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX) |
| 460 | my_common := COMMON |
| 461 | include $(BUILD_SYSTEM)/link_type.mk |
Dan Willemsen | 62dfb59 | 2016-07-08 21:33:05 -0700 | [diff] [blame] | 462 | endif # !LOCAL_IS_HOST_MODULE |