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