blob: 6ee2c043d6d8d23e4560e84c445031fbab3a5111 [file] [log] [blame]
Ying Wang956dccc2015-08-28 11:47:03 -07001# Target Java.
The Android Open Source Project88b60792009-03-03 19:28:42 -08002# Requires:
3# LOCAL_MODULE_SUFFIX
4# LOCAL_MODULE_CLASS
5# all_res_assets
6
Keun young Parkebb351e2012-04-19 15:36:18 -07007ifeq ($(TARGET_BUILD_PDK),true)
Keun young Parkefe02ce2012-06-06 17:19:29 -07008ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
Keun young Parkebb351e2012-04-19 15:36:18 -07009# LOCAL_SDK not defined or set to current
10ifeq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
Ying Wang2fee3a82014-10-17 18:26:39 -070011ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
Keun young Parkebb351e2012-04-19 15:36:18 -070012LOCAL_SDK_VERSION := $(PDK_BUILD_SDK_VERSION)
Ying Wang2fee3a82014-10-17 18:26:39 -070013endif #!LOCAL_NO_STANDARD_LIBRARIES
Keun young Parkebb351e2012-04-19 15:36:18 -070014endif
Keun young Park816b9fd2012-05-16 10:32:41 -070015endif # !PDK_JAVA
Keun young Parkebb351e2012-04-19 15:36:18 -070016endif #PDK
17
Colin Cross5c66c282018-03-14 09:56:04 -070018ifndef LOCAL_USE_R8
19LOCAL_USE_R8 := $(USE_R8)
20endif
21
The Android Open Source Project88b60792009-03-03 19:28:42 -080022LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES))
23LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
24
Ying Wanga5fc87a2010-11-02 18:43:16 -070025proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
26ifneq ($(proto_sources),)
27ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
Jeff Davidsonb8ddd552014-09-15 17:51:11 -070028 LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-micro
Ying Wanga5fc87a2010-11-02 18:43:16 -070029else
Ulas Kirazcibde274e2013-03-28 14:02:14 -070030 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
Jeff Davidsonb8ddd552014-09-15 17:51:11 -070031 LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano
Ulas Kirazcibde274e2013-03-28 14:02:14 -070032 else
Joe Onoratoc05a8ee2016-10-05 18:01:10 -070033 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream)
34 # No library for stream protobufs
35 else
36 LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite
37 endif
Ulas Kirazcibde274e2013-03-28 14:02:14 -070038 endif
Ying Wanga5fc87a2010-11-02 18:43:16 -070039endif
40endif
41
Ying Wange295c3d2016-02-24 14:11:55 -080042# LOCAL_STATIC_JAVA_AAR_LIBRARIES and LOCAL_STATIC_ANDROID_LIBRARIES are also LOCAL_STATIC_JAVA_LIBRARIES.
43LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) \
44 $(LOCAL_STATIC_JAVA_AAR_LIBRARIES) \
45 $(LOCAL_STATIC_ANDROID_LIBRARIES))
46# LOCAL_SHARED_ANDROID_LIBRARIES are also LOCAL_JAVA_LIBRARIES.
47LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES) $(LOCAL_SHARED_ANDROID_LIBRARIES))
The Android Open Source Project88b60792009-03-03 19:28:42 -080048
49LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
50ifeq ($(LOCAL_BUILT_MODULE_STEM),)
51$(error $(LOCAL_PATH): Target java template must define LOCAL_BUILT_MODULE_STEM)
52endif
53ifneq ($(filter classes-compiled.jar classes.jar,$(LOCAL_BUILT_MODULE_STEM)),)
54$(error LOCAL_BUILT_MODULE_STEM may not be "$(LOCAL_BUILT_MODULE_STEM)")
55endif
56
Joe Onoratoe334d252009-07-17 15:33:40 -040057
58##############################################################################
59# Define the intermediate targets before including base_rules so they get
60# the correct environment.
61##############################################################################
62
63intermediates := $(call local-intermediates-dir)
64intermediates.COMMON := $(call local-intermediates-dir,COMMON)
65
Ying Wang957fea52010-09-23 11:48:38 -070066ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
67LOCAL_PROGUARD_ENABLED :=
68endif
69
Nan Zhangb3ec5342017-08-31 21:43:04 +000070full_classes_turbine_jar := $(intermediates.COMMON)/classes-turbine.jar
71full_classes_header_jarjar := $(intermediates.COMMON)/classes-header-jarjar.jar
72full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
Colin Crossa6e87822017-12-20 17:33:01 -080073full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
Colin Crossf8a49c52017-05-22 16:21:49 -070074full_classes_processed_jar := $(intermediates.COMMON)/classes-processed.jar
Colin Cross950f1ef2017-04-05 15:30:42 -070075full_classes_desugar_jar := $(intermediates.COMMON)/classes-desugar.jar
Colin Crossa6e87822017-12-20 17:33:01 -080076full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
Colin Cross950f1ef2017-04-05 15:30:42 -070077full_classes_proguard_jar := $(intermediates.COMMON)/classes-proguard.jar
Nan Zhang9bd54052017-09-13 13:13:53 -070078full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar
Colin Crossa6e87822017-12-20 17:33:01 -080079built_dex_intermediate := $(intermediates.COMMON)/dex/classes.dex
David Brazdilb8fa6dd2018-01-29 14:43:14 +000080built_dex_hiddenapi := $(intermediates.COMMON)/dex-hiddenapi/classes.dex
Ying Wang957fea52010-09-23 11:48:38 -070081full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
Colin Crossdfc45ec2017-05-26 15:22:02 -070082java_source_list_file := $(intermediates.COMMON)/java-source-list
83
Ying Wang957fea52010-09-23 11:48:38 -070084
Ying Wang37b82aa2013-08-28 17:28:36 -070085ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS)
86# If this is an apk without any Java code (e.g. framework-res), we should skip compiling Java.
Ying Wang990cf5e2013-08-28 13:04:46 -070087full_classes_jar :=
88built_dex :=
89else
Ying Wang957fea52010-09-23 11:48:38 -070090full_classes_jar := $(intermediates.COMMON)/classes.jar
Ying Wang7b7929a2013-09-12 17:35:21 -070091built_dex := $(intermediates.COMMON)/classes.dex
Ying Wang990cf5e2013-08-28 13:04:46 -070092endif
Joe Onoratoe334d252009-07-17 15:33:40 -040093
94LOCAL_INTERMEDIATE_TARGETS += \
Nan Zhangb3ec5342017-08-31 21:43:04 +000095 $(full_classes_turbine_jar) \
Joe Onoratoe334d252009-07-17 15:33:40 -040096 $(full_classes_compiled_jar) \
Colin Crosseac5ce42016-12-21 17:11:03 -080097 $(full_classes_desugar_jar) \
Ying Wang957fea52010-09-23 11:48:38 -070098 $(full_classes_jarjar_jar) \
Ying Wang957fea52010-09-23 11:48:38 -070099 $(full_classes_jar) \
Nan Zhang9bd54052017-09-13 13:13:53 -0700100 $(full_classes_combined_jar) \
Ying Wanga9c381e2010-10-02 18:35:51 -0700101 $(full_classes_proguard_jar) \
Ying Wang957fea52010-09-23 11:48:38 -0700102 $(built_dex_intermediate) \
Guang Zhu155afe32010-03-10 15:48:03 -0800103 $(built_dex) \
Colin Crossdfc45ec2017-05-26 15:22:02 -0700104 $(full_classes_stubs_jar) \
105 $(java_source_list_file)
Ying Wang957fea52010-09-23 11:48:38 -0700106
Joe Onorato77dc0a52010-05-17 18:16:11 -0700107LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
Joe Onoratoe334d252009-07-17 15:33:40 -0400108
Ying Wang0bd59a02010-07-15 17:17:52 -0700109###############################################################
110## .rs files: RenderScript sources to .java files and .bc files
111###############################################################
Colin Cross1e047d32018-03-12 18:23:15 -0700112include $(BUILD_SYSTEM)/java_renderscript.mk
Ying Wang956dccc2015-08-28 11:47:03 -0700113
114###########################################################
115## AIDL: Compile .aidl files to .java
116###########################################################
117aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700118aidl_java_sources :=
Ying Wang956dccc2015-08-28 11:47:03 -0700119
120ifneq ($(strip $(aidl_sources)),)
Ying Wang956dccc2015-08-28 11:47:03 -0700121
122aidl_preprocess_import :=
123ifdef LOCAL_SDK_VERSION
Jiyong Park5ebca302018-01-31 00:14:55 +0900124ifneq ($(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),)
Ying Wang956dccc2015-08-28 11:47:03 -0700125 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
126 aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
127else
128 aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
129endif # not current or system_current
130else
131# build against the platform.
132LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
133endif # LOCAL_SDK_VERSION
Ying Wang956dccc2015-08-28 11:47:03 -0700134
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700135$(foreach s,$(aidl_sources),\
Dan Willemsen4d995272017-09-29 17:37:31 -0700136 $(eval $(call define-aidl-java-rule,$(s),$(intermediates.COMMON)/aidl,aidl_java_sources)))
Shinichiro Hamaji2a0d1fe2016-01-28 16:10:00 +0900137$(foreach java,$(aidl_java_sources), \
138 $(call include-depfile,$(java:%.java=%.P),$(java)))
Ying Wang956dccc2015-08-28 11:47:03 -0700139
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700140$(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import)
141
142$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
Christopher Wileydc9e2672016-06-24 13:13:52 -0700143$(aidl_java_sources): PRIVATE_MODULE := $(LOCAL_MODULE)
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700144
Ying Wang956dccc2015-08-28 11:47:03 -0700145endif
146
Ying Wang956dccc2015-08-28 11:47:03 -0700147##########################################
148
Ying Wang1d977e32013-01-30 11:22:06 -0800149# All of the rules after full_classes_compiled_jar are very unlikely
150# to fail except for bugs in their respective tools. If you would
151# like to run these rules, add the "all" modifier goal to the make
152# command line.
Ying Wang447d6962015-09-01 19:12:05 -0700153ifndef LOCAL_CHECKED_MODULE
Jean-Philippe Lesot0fbc9ff2015-01-20 14:18:48 +0000154ifdef full_classes_jar
Colin Crossb17f2852017-04-27 13:34:02 -0700155LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
Ying Wang990cf5e2013-08-28 13:04:46 -0700156endif
Yohann Rousselee572682015-08-18 19:18:18 +0200157endif
Ying Wang1d977e32013-01-30 11:22:06 -0800158
The Android Open Source Project88b60792009-03-03 19:28:42 -0800159#######################################
160include $(BUILD_SYSTEM)/base_rules.mk
161#######################################
162
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900163###########################################################
164## logtags: emit java source
165###########################################################
166ifneq ($(strip $(logtags_sources)),)
167
Dan Willemsen4d995272017-09-29 17:37:31 -0700168logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/logtags/, $(logtags_sources)))
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900169logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources))
170
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900171$(logtags_java_sources): PRIVATE_MERGED_TAG := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
Colin Crossfdea8932017-12-06 14:38:40 -0800172$(logtags_java_sources): $(intermediates.COMMON)/logtags/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt $(JAVATAGS) build/make/tools/event_log_tags.py
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900173 $(transform-logtags-to-java)
174
175else
176logtags_java_sources :=
177endif
178
Ying Wang956dccc2015-08-28 11:47:03 -0700179##########################################
180java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
181 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
Nan Zhangad818dc2017-10-04 09:26:06 -0700182java_intermediate_sources := $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
183all_java_sources := $(java_sources) $(java_intermediate_sources)
184
Ying Wang956dccc2015-08-28 11:47:03 -0700185include $(BUILD_SYSTEM)/java_common.mk
186
Anton Hansson7ff32d22018-02-21 15:29:44 +0000187include $(BUILD_SYSTEM)/sdk_check.mk
188
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100189# Set the profile source so that the odex / profile code included from java.mk
190# can find it.
191#
192# TODO: b/64896089, this is broken when called from package_internal.mk, since the file
193# we preopt from is a temporary file. This will be addressed in a follow up, possibly
194# by disabling stripping for profile guided preopt (which may be desirable for other
195# reasons anyway).
196#
197# Note that we set this only when called from package_internal.mk and not in other cases.
198ifneq (,$(called_from_package_internal)
199dex_preopt_profile_src_file := $(LOCAL_BUILT_MODULE)
200endif
201
Brian Carlstromced4bff2013-11-14 23:44:56 -0800202#######################################
203# defines built_odex along with rule to install odex
204include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
205#######################################
206
Ying Wang990cf5e2013-08-28 13:04:46 -0700207# Make sure there's something to build.
208ifdef full_classes_jar
209ifndef need_compile_java
Jeff Gaston960acf12018-02-26 21:00:25 -0500210$(call pretty-error,Target java module does not define any source or resource files)
Ying Wang990cf5e2013-08-28 13:04:46 -0700211endif
212endif
213
The Android Open Source Project88b60792009-03-03 19:28:42 -0800214# Since we're using intermediates.COMMON, make sure that it gets cleaned
215# properly.
216$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
217
Ying Wang990cf5e2013-08-28 13:04:46 -0700218ifdef full_classes_jar
The Android Open Source Project88b60792009-03-03 19:28:42 -0800219
Joe Onorato64d85d02009-04-09 19:31:12 -0700220# Droiddoc isn't currently able to generate stubs for modules, so we're just
221# allowing it to use the classes.jar as the "stubs" that would be use to link
222# against, for the cases where someone needs the jar to link against.
Colin Cross0e537342017-03-29 12:17:36 -0700223$(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar)))
Joe Onorato64d85d02009-04-09 19:31:12 -0700224ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
225
Joe Onorato0eccce92011-10-30 21:37:35 -0700226# The layers file allows you to enforce a layering between java packages.
Colin Crossfdea8932017-12-06 14:38:40 -0800227# Run build/make/tools/java-layers.py for more details.
Joe Onorato0eccce92011-10-30 21:37:35 -0700228layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
229$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
Ying Wang057eba02012-10-18 10:54:49 -0700230$(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE)
Joe Onorato0eccce92011-10-30 21:37:35 -0700231
The Android Open Source Project88b60792009-03-03 19:28:42 -0800232# Compile the java files to a .jar file.
233# This intentionally depends on java_sources, not all_java_sources.
234# Deps for generated source files must be handled separately,
235# via deps on the target that generates the sources.
Paul Duffin3ca92982016-09-20 15:12:30 +0100236
237# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS
238ifeq ($(RUN_ERROR_PRONE),true)
239LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
240endif
241
Przemyslaw Szczepaniak2e81b3c2017-06-30 14:51:12 +0100242# For user / userdebug builds, strip the local variable table and the local variable
243# type table. This has no bearing on stack traces, but will leave less information
244# available via JDWP.
245ifneq (,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO))
246ifneq (,$(filter userdebug user,$(TARGET_BUILD_VARIANT)))
247LOCAL_JAVACFLAGS+= -g:source,lines
Przemyslaw Szczepaniak2e81b3c2017-06-30 14:51:12 +0100248endif
249endif
250
Colin Crossdfc45ec2017-05-26 15:22:02 -0700251# List of dependencies for anything that needs all java sources in place
252java_sources_deps := \
253 $(java_sources) \
254 $(java_resource_sources) \
Colin Crossdfc45ec2017-05-26 15:22:02 -0700255 $(proto_java_sources_file_stamp) \
Colin Cross11e2d552018-03-07 15:44:54 -0800256 $(LOCAL_SRCJARS) \
Colin Crossdfc45ec2017-05-26 15:22:02 -0700257 $(LOCAL_ADDITIONAL_DEPENDENCIES)
258
259$(java_source_list_file): $(java_sources_deps)
260 $(write-java-source-list)
261
Colin Cross7dc90432017-09-26 16:17:24 -0700262ifneq ($(TURBINE_ENABLED),false)
263
Nan Zhangb3ec5342017-08-31 21:43:04 +0000264$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
Colin Cross11e2d552018-03-07 15:44:54 -0800265$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000266$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
267$(full_classes_turbine_jar): \
268 $(java_source_list_file) \
269 $(java_sources_deps) \
270 $(full_java_header_libs) \
Colin Cross1d1e5ef2017-09-23 18:19:05 -0700271 $(full_java_bootclasspath_libs) \
Colin Crossf9602572017-10-12 13:34:40 -0700272 $(full_java_system_modules_deps) \
Nan Zhangb3ec5342017-08-31 21:43:04 +0000273 $(NORMALIZE_PATH) \
274 $(JAR_ARGS) \
275 $(ZIPTIME) \
Nan Zhang9bd54052017-09-13 13:13:53 -0700276 | $(TURBINE) \
277 $(MERGE_ZIPS)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000278 $(transform-java-to-header.jar)
279
280.KATI_RESTAT: $(full_classes_turbine_jar)
281
282# Run jarjar before generate classes-header.jar if necessary.
283ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
284$(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
285$(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
286 @echo Header JarJar: $@
287 $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
288else
289full_classes_header_jarjar := $(full_classes_turbine_jar)
290endif
291
292$(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar)))
293
Colin Cross7dc90432017-09-26 16:17:24 -0700294endif # TURBINE_ENABLED != false
295
Colin Cross5ef6e792018-03-07 14:16:43 -0800296$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
297$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
298$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
299$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
300$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
301$(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
302$(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
Colin Cross11e2d552018-03-07 15:44:54 -0800303$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
304$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
305$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
Colin Cross5ef6e792018-03-07 14:16:43 -0800306$(full_classes_compiled_jar): \
307 $(java_source_list_file) \
308 $(full_java_header_libs) \
309 $(java_sources_deps) \
310 $(full_java_bootclasspath_libs) \
311 $(full_java_system_modules_deps) \
312 $(layers_file) \
313 $(annotation_processor_deps) \
314 $(NORMALIZE_PATH) \
315 $(JAR_ARGS) \
Colin Cross3f99cd52018-03-15 16:26:08 -0700316 $(ZIPSYNC) \
Colin Cross5ef6e792018-03-07 14:16:43 -0800317 | $(SOONG_JAVAC_WRAPPER)
318 @echo "Target Java: $@
319 $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
320
Ying Wangcddeb6c2016-03-24 11:00:30 -0700321javac-check : $(full_classes_compiled_jar)
Paul Duffin32bd0ad2016-09-15 14:34:42 +0100322javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
Ying Wangcddeb6c2016-03-24 11:00:30 -0700323
Nan Zhang9bd54052017-09-13 13:13:53 -0700324$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
325$(full_classes_combined_jar): $(full_classes_compiled_jar) \
Nan Zhangb8801172017-09-20 14:56:48 -0700326 $(jar_manifest_file) \
Nan Zhang9bd54052017-09-13 13:13:53 -0700327 $(full_static_java_libs) | $(MERGE_ZIPS)
Nan Zhangb8801172017-09-20 14:56:48 -0700328 $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \
329 $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf)
Colin Cross5b73ab32018-02-14 10:32:48 -0800330 $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \
Nan Zhangb8801172017-09-20 14:56:48 -0700331 $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \
332 $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
Nan Zhang9bd54052017-09-13 13:13:53 -0700333
Colin Crossf8a49c52017-05-22 16:21:49 -0700334ifdef LOCAL_JAR_PROCESSOR
335# LOCAL_JAR_PROCESSOR_ARGS must be evaluated here to set up the rule-local
336# PRIVATE_JAR_PROCESSOR_ARGS variable, but $< and $@ are not available yet.
337# Set ${in} and ${out} so they can be referenced by LOCAL_JAR_PROCESSOR_ARGS
338# using deferred evaluation (LOCAL_JAR_PROCESSOR_ARGS = instead of :=).
Nan Zhang9bd54052017-09-13 13:13:53 -0700339in := $(full_classes_combined_jar)
Colin Crossf8a49c52017-05-22 16:21:49 -0700340out := $(full_classes_processed_jar).tmp
Colin Cross89b802b2017-07-13 19:25:47 -0700341my_jar_processor := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_JAR_PROCESSOR).jar
342
Colin Crossf8a49c52017-05-22 16:21:49 -0700343$(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR_ARGS := $(LOCAL_JAR_PROCESSOR_ARGS)
Colin Cross89b802b2017-07-13 19:25:47 -0700344$(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR := $(my_jar_processor)
Colin Crossf8a49c52017-05-22 16:21:49 -0700345$(full_classes_processed_jar): PRIVATE_TMP_OUT := $(out)
346in :=
347out :=
348
Nan Zhang9bd54052017-09-13 13:13:53 -0700349$(full_classes_processed_jar): $(full_classes_combined_jar) $(my_jar_processor)
Colin Crossf8a49c52017-05-22 16:21:49 -0700350 @echo Processing $@ with $(PRIVATE_JAR_PROCESSOR)
351 $(hide) rm -f $@ $(PRIVATE_TMP_OUT)
Colin Cross0851df82017-06-30 13:55:38 -0700352 $(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS)
Colin Crossf8a49c52017-05-22 16:21:49 -0700353 $(hide) mv $(PRIVATE_TMP_OUT) $@
354
Colin Cross89b802b2017-07-13 19:25:47 -0700355my_jar_processor :=
Colin Crossf8a49c52017-05-22 16:21:49 -0700356else
Nan Zhang9bd54052017-09-13 13:13:53 -0700357full_classes_processed_jar := $(full_classes_combined_jar)
Colin Crossf8a49c52017-05-22 16:21:49 -0700358endif
359
Nan Zhang870025f2017-09-13 14:56:11 -0700360# Run jarjar if necessary
361ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
362$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
363$(full_classes_jarjar_jar): $(full_classes_processed_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
364 @echo JarJar: $@
365 $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
366else
367full_classes_jarjar_jar := $(full_classes_processed_jar)
368endif
369
370$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
371
Colin Cross96873482017-12-22 16:51:23 -0800372LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)
373
374#######################################
375include $(BUILD_SYSTEM)/jacoco.mk
376#######################################
377
Tobias Thierer7ef760b2017-11-17 13:02:12 +0000378# Temporarily enable --multi-dex until proguard supports v53 class files
379# ( http://b/67673860 ) or we move away from proguard altogether.
Tobias Thiererf6bd4952017-11-15 20:55:03 +0000380ifdef TARGET_OPENJDK9
Tobias Thierer89740662017-10-25 02:38:01 +0100381LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex
382endif
383
Alan Leungeaafb3c2017-12-01 14:32:58 -0800384ifneq ($(USE_D8_DESUGAR),true)
Colin Crosseac5ce42016-12-21 17:11:03 -0800385my_desugaring :=
Colin Cross31060fd2017-03-21 10:17:04 -0700386ifndef LOCAL_IS_STATIC_JAVA_LIBRARY
Colin Crosseac5ce42016-12-21 17:11:03 -0800387my_desugaring := true
388$(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
Colin Cross96873482017-12-22 16:51:23 -0800389$(full_classes_desugar_jar): $(LOCAL_FULL_CLASSES_JACOCO_JAR) $(full_java_header_libs) $(DESUGAR)
Colin Crosseac5ce42016-12-21 17:11:03 -0800390 $(desugar-classes-jar)
391endif
Alan Leungeaafb3c2017-12-01 14:32:58 -0800392else
393my_desugaring :=
394endif
Colin Crosseac5ce42016-12-21 17:11:03 -0800395
396ifndef my_desugaring
Colin Cross96873482017-12-22 16:51:23 -0800397full_classes_desugar_jar := $(LOCAL_FULL_CLASSES_JACOCO_JAR)
Colin Crosseac5ce42016-12-21 17:11:03 -0800398endif
399
Colin Cross96873482017-12-22 16:51:23 -0800400full_classes_pre_proguard_jar := $(full_classes_desugar_jar)
Ying Wang3b2bdf12010-02-01 09:51:23 -0800401
Colin Cross950f1ef2017-04-05 15:30:42 -0700402# Keep a copy of the jar just before proguard processing.
403$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(intermediates.COMMON)/classes-pre-proguard.jar))
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900404
Colin Cross0e537342017-03-29 12:17:36 -0700405# Run proguard if necessary
Ying Wang7311a342013-08-21 18:32:49 -0700406ifdef LOCAL_PROGUARD_ENABLED
Colin Crosse616f342017-12-28 09:43:41 -0800407ifneq ($(filter-out full custom obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),)
Ying Wang7311a342013-08-21 18:32:49 -0700408 $(warning while processing: $(LOCAL_MODULE))
409 $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
410endif
Joe Onorato2daa2b32009-08-30 13:39:24 -0700411proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
Ying Wang4f5d0e62015-05-04 19:21:48 -0700412
Colin Crossb5f25a22017-10-20 19:16:41 -0700413# When an app contains references to APIs that are not in the SDK specified by
414# its LOCAL_SDK_VERSION for example added by support library or by runtime
415# classes added by desugar, we artifically raise the "SDK version" "linked" by
416# ProGuard, to
Ying Wang4f5d0e62015-05-04 19:21:48 -0700417# - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version.
418# - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
Colin Crossb5f25a22017-10-20 19:16:41 -0700419# See b/20667396
420my_proguard_sdk_raise :=
Ying Wang4f5d0e62015-05-04 19:21:48 -0700421ifdef LOCAL_SDK_VERSION
Ying Wang4f5d0e62015-05-04 19:21:48 -0700422ifdef TARGET_BUILD_APPS
Jiyong Park5ebca302018-01-31 00:14:55 +0900423ifeq (,$(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
Colin Crossb5f25a22017-10-20 19:16:41 -0700424 my_proguard_sdk_raise := $(call java-lib-header-files, sdk_vcurrent)
Ying Wang742f5832015-06-26 12:33:06 -0700425endif
Ying Wang4f5d0e62015-05-04 19:21:48 -0700426else
427 # For platform build, we can't just raise to the "current" SDK,
428 # that would break apps that use APIs removed from the current SDK.
Colin Crossb5f25a22017-10-20 19:16:41 -0700429 my_proguard_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES))
Ying Wang4f5d0e62015-05-04 19:21:48 -0700430endif
431endif
Ying Wang4f5d0e62015-05-04 19:21:48 -0700432
Colin Crossb5f25a22017-10-20 19:16:41 -0700433legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \
434 $(filter-out $(my_proguard_sdk_raise), \
Colin Crossb541aae2017-09-23 19:52:43 -0700435 $(full_java_bootclasspath_libs) \
436 $(full_shared_java_header_libs)))
Nan Zhangb3ec5342017-08-31 21:43:04 +0000437
Colin Crossb5f25a22017-10-20 19:16:41 -0700438legacy_proguard_lib_deps := $(my_proguard_sdk_raise) \
439 $(filter-out $(my_proguard_sdk_raise),$(full_shared_java_header_libs))
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100440
441legacy_proguard_flags += -printmapping $(proguard_dictionary)
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100442
443common_proguard_flags := -forceprocessing
Ying Wang7311a342013-08-21 18:32:49 -0700444
Colin Crosse616f342017-12-28 09:43:41 -0800445common_proguard_flag_files := $(BUILD_SYSTEM)/proguard.flags
Ying Wang7311a342013-08-21 18:32:49 -0700446ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200447common_proguard_flags += -dontshrink # don't shrink tests by default
Ying Wang3b2bdf12010-02-01 09:51:23 -0800448endif # test package
Dan Willemsen1d646232017-11-17 13:11:26 -0800449ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
450 ifdef LOCAL_USE_AAPT2
451 common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
452 $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)
453 endif
454endif
Shinichiro Hamaji4eaeef82016-04-07 18:56:42 +0900455ifneq ($(common_proguard_flag_files),)
456common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files))
457# This is included from $(BUILD_SYSTEM)/proguard.flags
458common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_basic_keeps.flags
459endif
460
Ying Wang7311a342013-08-21 18:32:49 -0700461ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
462# By default no obfuscation
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200463common_proguard_flags += -dontobfuscate
Ying Wang7311a342013-08-21 18:32:49 -0700464endif # No obfuscation
465ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),)
466# By default no optimization
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200467common_proguard_flags += -dontoptimize
Ying Wang7311a342013-08-21 18:32:49 -0700468endif # No optimization
Ying Wang3b2bdf12010-02-01 09:51:23 -0800469
Ying Wang7311a342013-08-21 18:32:49 -0700470ifdef LOCAL_INSTRUMENTATION_FOR
471ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
472# If no obfuscation, link in the instrmented package's classes.jar as a library.
473# link_instr_classes_jar is defined in base_rule.mk
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200474legacy_proguard_flags += -libraryjars $(link_instr_classes_jar)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000475legacy_proguard_lib_deps += $(link_instr_classes_jar)
Ying Wang7311a342013-08-21 18:32:49 -0700476else # obfuscation
477# If obfuscation is enabled, the main app must be obfuscated too.
478# We need to run obfuscation using the main app's dictionary,
479# and treat the main app's class.jar as injars instead of libraryjars.
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200480legacy_proguard_flags := -injars $(link_instr_classes_jar) \
Ying Wang7311a342013-08-21 18:32:49 -0700481 -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \
482 -include $(link_instr_intermediates_dir.COMMON)/proguard_options \
483 -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \
484 -verbose \
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200485 $(legacy_proguard_flags)
Ying Wang7311a342013-08-21 18:32:49 -0700486
487# Sometimes (test + main app) uses different keep rules from the main app -
488# apply the main app's dictionary anyway.
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200489legacy_proguard_flags += -ignorewarnings
Ying Wang7311a342013-08-21 18:32:49 -0700490
491# Make sure we run Proguard on the main app first
492$(full_classes_proguard_jar) : $(link_instr_intermediates_dir.COMMON)/proguard.classes.jar
493
494endif # no obfuscation
495endif # LOCAL_INSTRUMENTATION_FOR
Joe Onorato2daa2b32009-08-30 13:39:24 -0700496
Ying Wang0b9382c2010-09-29 14:50:41 -0700497proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES))
Colin Cross5c66c282018-03-14 09:56:04 -0700498ifeq ($(LOCAL_USE_R8),true)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200499proguard_flag_files += $(addprefix $(LOCAL_PATH)/, $(LOCAL_R8_FLAG_FILES))
Colin Cross5c66c282018-03-14 09:56:04 -0700500endif # LOCAL_USE_R8
Ying Wang0b9382c2010-09-29 14:50:41 -0700501LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files))
502
Mihail Dumitrescu4df82b32014-02-07 15:18:59 +0000503ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
504extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar
505else
506extra_input_jar :=
507endif
Paul Duffinf22aca12017-02-21 13:11:13 +0000508
Colin Crosse673deb2017-09-27 14:28:41 -0700509# If building against the current SDK version then filter out the junit,
510# android.test and c.a.i.u.Predicate classes that are to be removed from
511# the Android API as part of b/30188076 but which are still present in
512# the Android API. This is to allow changes to be made to the build to
513# statically include those classes into the application without
Paul Duffinf22aca12017-02-21 13:11:13 +0000514# simultaneously removing those classes from the API.
515proguard_injar_filters :=
Paul Duffinf22aca12017-02-21 13:11:13 +0000516ifdef LOCAL_SDK_VERSION
517ifeq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
Paul Duffin54747a72017-06-15 08:42:23 +0100518proguard_injar_filters := (!junit/framework/**,!junit/runner/**,!junit/textui/**,!android/test/**,!com/android/internal/util/*)
Paul Duffinf22aca12017-02-21 13:11:13 +0000519endif
520endif
Paul Duffinf22aca12017-02-21 13:11:13 +0000521
Dan Willemsenbdd6a752017-09-25 23:36:19 -0700522ifneq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
Colin Cross5c66c282018-03-14 09:56:04 -0700523ifneq ($(LOCAL_USE_R8),true)
Dan Willemsenbdd6a752017-09-25 23:36:19 -0700524 $(full_classes_proguard_jar): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary)
Søren Gjesse4ab5b022017-10-25 17:10:59 +0200525else
526 $(built_dex_intermediate): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary)
527endif
Dan Willemsenbdd6a752017-09-25 23:36:19 -0700528endif
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200529
530# If R8 is not enabled run Proguard.
Colin Cross5c66c282018-03-14 09:56:04 -0700531ifneq ($(LOCAL_USE_R8),true)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200532# Changes to these dependencies need to be replicated below when using R8
533# instead of Proguard + dx.
Paul Duffinf22aca12017-02-21 13:11:13 +0000534$(full_classes_proguard_jar): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters)
Mihail Dumitrescu4df82b32014-02-07 15:18:59 +0000535$(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200536$(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
Colin Crossb5f25a22017-10-20 19:16:41 -0700537$(full_classes_proguard_jar) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_proguard_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) | $(PROGUARD)
Ying Wang3b2bdf12010-02-01 09:51:23 -0800538 $(call transform-jar-to-proguard)
Colin Cross5c66c282018-03-14 09:56:04 -0700539else # !LOCAL_USE_R8
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200540# Running R8 instead of Proguard, proguarded jar is actually the pre-Proguarded jar.
541full_classes_proguard_jar := $(full_classes_pre_proguard_jar)
Colin Cross5c66c282018-03-14 09:56:04 -0700542endif # !LOCAL_USE_R8
Ying Wang3b2bdf12010-02-01 09:51:23 -0800543
Ying Wang7311a342013-08-21 18:32:49 -0700544else # LOCAL_PROGUARD_ENABLED not defined
ShuJie Wang76e93ba2017-11-06 14:35:52 +0800545proguard_flag_files :=
Colin Cross950f1ef2017-04-05 15:30:42 -0700546full_classes_proguard_jar := $(full_classes_pre_proguard_jar)
Ying Wang7311a342013-08-21 18:32:49 -0700547endif # LOCAL_PROGUARD_ENABLED defined
548
Colin Cross96476c12017-04-06 09:56:19 -0700549ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
Colin Cross79e2f732016-12-21 14:29:13 -0800550$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200551
552my_r8 :=
553ifdef LOCAL_PROGUARD_ENABLED
Colin Cross5c66c282018-03-14 09:56:04 -0700554ifeq ($(LOCAL_USE_R8),true)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200555# These are the dependencies for the proguarded jar when running
556# Proguard + dx. They are used for the generated dex when using R8, as
557# R8 does Proguard + dx
558my_r8 := true
559$(built_dex_intermediate): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters)
560$(built_dex_intermediate): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
561$(built_dex_intermediate): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
Alan Leung7d6144d2017-11-16 15:51:07 -0800562$(built_dex_intermediate) : $(full_classes_proguard_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) $(R8_COMPAT_PROGUARD)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200563 $(transform-jar-to-dex-r8)
Colin Cross5c66c282018-03-14 09:56:04 -0700564endif # LOCAL_USE_R8
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200565endif # LOCAL_PROGUARD_ENABLED
566
567ifndef my_r8
Alan Leung5eb88c02017-12-20 20:03:58 -0800568$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX) $(ZIP2ZIP)
Alan Leungeaafb3c2017-12-01 14:32:58 -0800569ifneq ($(USE_D8_DESUGAR),true)
Colin Cross79e2f732016-12-21 14:29:13 -0800570 $(transform-classes.jar-to-dex)
Alan Leungeaafb3c2017-12-01 14:32:58 -0800571else
572 $(transform-classes-d8.jar-to-dex)
573endif
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200574endif
Colin Cross79e2f732016-12-21 14:29:13 -0800575
David Brazdilb8fa6dd2018-01-29 14:43:14 +0000576ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) # is_boot_jar
577 $(eval $(call hiddenapi-copy-dex-files,$(built_dex_intermediate),$(built_dex_hiddenapi)))
578 built_dex_copy_from := $(built_dex_hiddenapi)
579else # !is_boot_jar
580 built_dex_copy_from := $(built_dex_intermediate)
581endif # is_boot_jar
582
583$(built_dex): $(built_dex_copy_from)
Guang Zhu155afe32010-03-10 15:48:03 -0800584 @echo Copying: $@
Yohann Roussel8ffe9c32013-08-20 17:05:27 +0200585 $(hide) mkdir -p $(dir $@)
586 $(hide) rm -f $(dir $@)/classes*.dex
Colin Cross0e537342017-03-29 12:17:36 -0700587 $(hide) cp -fp $(dir $<)/classes*.dex $(dir $@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800588
Colin Cross9eff8302017-04-27 15:05:44 -0700589java-dex: $(built_dex)
590
Colin Cross96476c12017-04-06 09:56:19 -0700591endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
592
The Android Open Source Project88b60792009-03-03 19:28:42 -0800593findbugs_xml := $(intermediates.COMMON)/findbugs.xml
Ying Wang702e01e2015-10-21 10:30:51 -0700594$(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
595 $(call normalize-path-list,$(filter %.jar,$(full_java_libs)))))
596$(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS)
Colin Cross950f1ef2017-04-05 15:30:42 -0700597$(findbugs_xml) : $(full_classes_pre_proguard_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800598 @echo Findbugs: $@
599 $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \
Ying Wang702e01e2015-10-21 10:30:51 -0700600 $(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \
Yohann Rousseld2a76c12015-02-05 16:10:58 +0100601 $< \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800602 > $@
603
604ALL_FINDBUGS_FILES += $(findbugs_xml)
605
606findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html
607$(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml)
608$(LOCAL_MODULE)-findbugs : $(findbugs_html)
609$(findbugs_html) : $(findbugs_xml)
610 @mkdir -p $(dir $@)
Andrew Stadlercef9ed92009-05-13 00:44:59 -0700611 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +0900612 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl $(PRIVATE_XML_FILE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800613 > $@
614
615$(LOCAL_MODULE)-findbugs : $(findbugs_html)
616
Ying Wang990cf5e2013-08-28 13:04:46 -0700617endif # full_classes_jar is defined
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200618
Jiyong Park5ebca302018-01-31 00:14:55 +0900619ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900620 my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
621 my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
Colin Cross536ef4e2017-02-21 16:14:55 -0800622else
Colin Cross9deb3312017-09-28 16:17:36 -0700623 my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK)
624 my_sdk_version := $(PLATFORM_SDK_VERSION)
Colin Cross536ef4e2017-02-21 16:14:55 -0800625endif
626
Colin Cross9deb3312017-09-28 16:17:36 -0700627ifdef LOCAL_MIN_SDK_VERSION
628 my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
629else
630 my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk))
631endif
632
633$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk)
634$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version)
635$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version)