blob: 19e63772a3c067f3f2091fad9fc189af6d1c82a2 [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 Crossa6e87822017-12-20 17:33:01 -080075full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
Colin Cross950f1ef2017-04-05 15:30:42 -070076full_classes_proguard_jar := $(intermediates.COMMON)/classes-proguard.jar
Nan Zhang9bd54052017-09-13 13:13:53 -070077full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar
Colin Crossa6e87822017-12-20 17:33:01 -080078built_dex_intermediate := $(intermediates.COMMON)/dex/classes.dex
David Brazdilb8fa6dd2018-01-29 14:43:14 +000079built_dex_hiddenapi := $(intermediates.COMMON)/dex-hiddenapi/classes.dex
Ying Wang957fea52010-09-23 11:48:38 -070080full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
Colin Crossdfc45ec2017-05-26 15:22:02 -070081java_source_list_file := $(intermediates.COMMON)/java-source-list
82
Ying Wang957fea52010-09-23 11:48:38 -070083
Ying Wang37b82aa2013-08-28 17:28:36 -070084ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS)
85# 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 -070086full_classes_jar :=
87built_dex :=
88else
Ying Wang957fea52010-09-23 11:48:38 -070089full_classes_jar := $(intermediates.COMMON)/classes.jar
Ying Wang7b7929a2013-09-12 17:35:21 -070090built_dex := $(intermediates.COMMON)/classes.dex
Ying Wang990cf5e2013-08-28 13:04:46 -070091endif
Joe Onoratoe334d252009-07-17 15:33:40 -040092
93LOCAL_INTERMEDIATE_TARGETS += \
Nan Zhangb3ec5342017-08-31 21:43:04 +000094 $(full_classes_turbine_jar) \
Joe Onoratoe334d252009-07-17 15:33:40 -040095 $(full_classes_compiled_jar) \
Ying Wang957fea52010-09-23 11:48:38 -070096 $(full_classes_jarjar_jar) \
Ying Wang957fea52010-09-23 11:48:38 -070097 $(full_classes_jar) \
Nan Zhang9bd54052017-09-13 13:13:53 -070098 $(full_classes_combined_jar) \
Ying Wanga9c381e2010-10-02 18:35:51 -070099 $(full_classes_proguard_jar) \
Ying Wang957fea52010-09-23 11:48:38 -0700100 $(built_dex_intermediate) \
Guang Zhu155afe32010-03-10 15:48:03 -0800101 $(built_dex) \
Colin Crossdfc45ec2017-05-26 15:22:02 -0700102 $(full_classes_stubs_jar) \
103 $(java_source_list_file)
Ying Wang957fea52010-09-23 11:48:38 -0700104
Joe Onorato77dc0a52010-05-17 18:16:11 -0700105LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
Joe Onoratoe334d252009-07-17 15:33:40 -0400106
Ying Wang956dccc2015-08-28 11:47:03 -0700107###########################################################
108## AIDL: Compile .aidl files to .java
109###########################################################
110aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700111aidl_java_sources :=
Ying Wang956dccc2015-08-28 11:47:03 -0700112
113ifneq ($(strip $(aidl_sources)),)
Ying Wang956dccc2015-08-28 11:47:03 -0700114
115aidl_preprocess_import :=
116ifdef LOCAL_SDK_VERSION
Jiyong Park5ebca302018-01-31 00:14:55 +0900117ifneq ($(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),)
Ying Wang956dccc2015-08-28 11:47:03 -0700118 # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
119 aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
120else
Anton Hansson66d47b82018-04-27 14:11:17 +0100121 aidl_preprocess_import := $(call resolve-prebuilt-sdk-aidl-path,$(LOCAL_SDK_VERSION))
Ying Wang956dccc2015-08-28 11:47:03 -0700122endif # not current or system_current
123else
124# build against the platform.
125LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
126endif # LOCAL_SDK_VERSION
Ying Wang956dccc2015-08-28 11:47:03 -0700127
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700128$(foreach s,$(aidl_sources),\
Dan Willemsen4d995272017-09-29 17:37:31 -0700129 $(eval $(call define-aidl-java-rule,$(s),$(intermediates.COMMON)/aidl,aidl_java_sources)))
Shinichiro Hamaji2a0d1fe2016-01-28 16:10:00 +0900130$(foreach java,$(aidl_java_sources), \
131 $(call include-depfile,$(java:%.java=%.P),$(java)))
Ying Wang956dccc2015-08-28 11:47:03 -0700132
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700133$(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import)
134
135$(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 -0700136$(aidl_java_sources): PRIVATE_MODULE := $(LOCAL_MODULE)
Christopher Wileyd9205ba2016-06-23 16:44:47 -0700137
Ying Wang956dccc2015-08-28 11:47:03 -0700138endif
139
Ying Wang956dccc2015-08-28 11:47:03 -0700140##########################################
141
Ying Wang1d977e32013-01-30 11:22:06 -0800142# All of the rules after full_classes_compiled_jar are very unlikely
143# to fail except for bugs in their respective tools. If you would
144# like to run these rules, add the "all" modifier goal to the make
145# command line.
Ying Wang447d6962015-09-01 19:12:05 -0700146ifndef LOCAL_CHECKED_MODULE
Jean-Philippe Lesot0fbc9ff2015-01-20 14:18:48 +0000147ifdef full_classes_jar
Colin Crossb17f2852017-04-27 13:34:02 -0700148LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
Ying Wang990cf5e2013-08-28 13:04:46 -0700149endif
Yohann Rousselee572682015-08-18 19:18:18 +0200150endif
Ying Wang1d977e32013-01-30 11:22:06 -0800151
The Android Open Source Project88b60792009-03-03 19:28:42 -0800152#######################################
153include $(BUILD_SYSTEM)/base_rules.mk
154#######################################
155
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900156###########################################################
157## logtags: emit java source
158###########################################################
159ifneq ($(strip $(logtags_sources)),)
160
Dan Willemsen4d995272017-09-29 17:37:31 -0700161logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/logtags/, $(logtags_sources)))
Yasuhiro Matsudaff82e822015-09-04 16:23:49 +0900162logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources))
163
Shinichiro Hamajid3ce14c2016-03-29 03:29:21 +0900164$(logtags_java_sources): PRIVATE_MERGED_TAG := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
Colin Crossfdea8932017-12-06 14:38:40 -0800165$(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 +0900166 $(transform-logtags-to-java)
167
168else
169logtags_java_sources :=
170endif
171
Ying Wang956dccc2015-08-28 11:47:03 -0700172##########################################
173java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
174 $(filter %.java,$(LOCAL_GENERATED_SOURCES))
Nan Zhangad818dc2017-10-04 09:26:06 -0700175java_intermediate_sources := $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
176all_java_sources := $(java_sources) $(java_intermediate_sources)
177
Ying Wang956dccc2015-08-28 11:47:03 -0700178include $(BUILD_SYSTEM)/java_common.mk
179
Anton Hansson7ff32d22018-02-21 15:29:44 +0000180include $(BUILD_SYSTEM)/sdk_check.mk
181
Narayan Kamathbbcdc072017-08-22 15:47:08 +0100182# Set the profile source so that the odex / profile code included from java.mk
183# can find it.
184#
185# TODO: b/64896089, this is broken when called from package_internal.mk, since the file
186# we preopt from is a temporary file. This will be addressed in a follow up, possibly
187# by disabling stripping for profile guided preopt (which may be desirable for other
188# reasons anyway).
189#
190# Note that we set this only when called from package_internal.mk and not in other cases.
191ifneq (,$(called_from_package_internal)
192dex_preopt_profile_src_file := $(LOCAL_BUILT_MODULE)
193endif
194
Brian Carlstromced4bff2013-11-14 23:44:56 -0800195#######################################
196# defines built_odex along with rule to install odex
197include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
198#######################################
199
Ying Wang990cf5e2013-08-28 13:04:46 -0700200# Make sure there's something to build.
201ifdef full_classes_jar
202ifndef need_compile_java
Jeff Gaston960acf12018-02-26 21:00:25 -0500203$(call pretty-error,Target java module does not define any source or resource files)
Ying Wang990cf5e2013-08-28 13:04:46 -0700204endif
205endif
206
The Android Open Source Project88b60792009-03-03 19:28:42 -0800207# Since we're using intermediates.COMMON, make sure that it gets cleaned
208# properly.
209$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
210
Ying Wang990cf5e2013-08-28 13:04:46 -0700211ifdef full_classes_jar
The Android Open Source Project88b60792009-03-03 19:28:42 -0800212
Joe Onorato64d85d02009-04-09 19:31:12 -0700213# Droiddoc isn't currently able to generate stubs for modules, so we're just
214# allowing it to use the classes.jar as the "stubs" that would be use to link
215# against, for the cases where someone needs the jar to link against.
Colin Cross0e537342017-03-29 12:17:36 -0700216$(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar)))
Joe Onorato64d85d02009-04-09 19:31:12 -0700217ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
218
Joe Onorato0eccce92011-10-30 21:37:35 -0700219# The layers file allows you to enforce a layering between java packages.
Colin Crossfdea8932017-12-06 14:38:40 -0800220# Run build/make/tools/java-layers.py for more details.
Joe Onorato0eccce92011-10-30 21:37:35 -0700221layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
222$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
Ying Wang057eba02012-10-18 10:54:49 -0700223$(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE)
Joe Onorato0eccce92011-10-30 21:37:35 -0700224
The Android Open Source Project88b60792009-03-03 19:28:42 -0800225# Compile the java files to a .jar file.
226# This intentionally depends on java_sources, not all_java_sources.
227# Deps for generated source files must be handled separately,
228# via deps on the target that generates the sources.
Paul Duffin3ca92982016-09-20 15:12:30 +0100229
230# If error prone is enabled then add LOCAL_ERROR_PRONE_FLAGS to LOCAL_JAVACFLAGS
231ifeq ($(RUN_ERROR_PRONE),true)
232LOCAL_JAVACFLAGS += $(LOCAL_ERROR_PRONE_FLAGS)
233endif
234
Przemyslaw Szczepaniak2e81b3c2017-06-30 14:51:12 +0100235# For user / userdebug builds, strip the local variable table and the local variable
236# type table. This has no bearing on stack traces, but will leave less information
237# available via JDWP.
238ifneq (,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO))
239ifneq (,$(filter userdebug user,$(TARGET_BUILD_VARIANT)))
240LOCAL_JAVACFLAGS+= -g:source,lines
Przemyslaw Szczepaniak2e81b3c2017-06-30 14:51:12 +0100241endif
242endif
243
Colin Crossdfc45ec2017-05-26 15:22:02 -0700244# List of dependencies for anything that needs all java sources in place
245java_sources_deps := \
246 $(java_sources) \
247 $(java_resource_sources) \
Colin Crossdfc45ec2017-05-26 15:22:02 -0700248 $(proto_java_sources_file_stamp) \
Colin Cross11e2d552018-03-07 15:44:54 -0800249 $(LOCAL_SRCJARS) \
Colin Crossdfc45ec2017-05-26 15:22:02 -0700250 $(LOCAL_ADDITIONAL_DEPENDENCIES)
251
252$(java_source_list_file): $(java_sources_deps)
253 $(write-java-source-list)
254
Colin Cross7dc90432017-09-26 16:17:24 -0700255ifneq ($(TURBINE_ENABLED),false)
256
Nan Zhangb3ec5342017-08-31 21:43:04 +0000257$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
Colin Cross11e2d552018-03-07 15:44:54 -0800258$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000259$(full_classes_turbine_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
260$(full_classes_turbine_jar): \
261 $(java_source_list_file) \
262 $(java_sources_deps) \
263 $(full_java_header_libs) \
Colin Cross1d1e5ef2017-09-23 18:19:05 -0700264 $(full_java_bootclasspath_libs) \
Colin Crossf9602572017-10-12 13:34:40 -0700265 $(full_java_system_modules_deps) \
Nan Zhangb3ec5342017-08-31 21:43:04 +0000266 $(NORMALIZE_PATH) \
267 $(JAR_ARGS) \
268 $(ZIPTIME) \
Nan Zhang9bd54052017-09-13 13:13:53 -0700269 | $(TURBINE) \
270 $(MERGE_ZIPS)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000271 $(transform-java-to-header.jar)
272
273.KATI_RESTAT: $(full_classes_turbine_jar)
274
275# Run jarjar before generate classes-header.jar if necessary.
276ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
277$(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
278$(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
279 @echo Header JarJar: $@
280 $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
281else
282full_classes_header_jarjar := $(full_classes_turbine_jar)
283endif
284
285$(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar)))
286
Colin Cross7dc90432017-09-26 16:17:24 -0700287endif # TURBINE_ENABLED != false
288
Colin Cross5ef6e792018-03-07 14:16:43 -0800289$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
290$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
291$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
292$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
293$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
294$(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
295$(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
Colin Cross11e2d552018-03-07 15:44:54 -0800296$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
297$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
298$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
Colin Cross5ef6e792018-03-07 14:16:43 -0800299$(full_classes_compiled_jar): \
300 $(java_source_list_file) \
301 $(full_java_header_libs) \
302 $(java_sources_deps) \
303 $(full_java_bootclasspath_libs) \
304 $(full_java_system_modules_deps) \
305 $(layers_file) \
306 $(annotation_processor_deps) \
307 $(NORMALIZE_PATH) \
308 $(JAR_ARGS) \
Colin Cross3f99cd52018-03-15 16:26:08 -0700309 $(ZIPSYNC) \
Colin Cross5ef6e792018-03-07 14:16:43 -0800310 | $(SOONG_JAVAC_WRAPPER)
311 @echo "Target Java: $@
312 $(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
313
Ying Wangcddeb6c2016-03-24 11:00:30 -0700314javac-check : $(full_classes_compiled_jar)
Paul Duffin32bd0ad2016-09-15 14:34:42 +0100315javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
Ying Wangcddeb6c2016-03-24 11:00:30 -0700316
Nan Zhang9bd54052017-09-13 13:13:53 -0700317$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
318$(full_classes_combined_jar): $(full_classes_compiled_jar) \
Nan Zhangb8801172017-09-20 14:56:48 -0700319 $(jar_manifest_file) \
Nan Zhang9bd54052017-09-13 13:13:53 -0700320 $(full_static_java_libs) | $(MERGE_ZIPS)
Nan Zhangb8801172017-09-20 14:56:48 -0700321 $(if $(PRIVATE_JAR_MANIFEST), $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \
322 $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf)
Colin Cross5b73ab32018-02-14 10:32:48 -0800323 $(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(dir $@)/manifest.mf) \
Nan Zhangb8801172017-09-20 14:56:48 -0700324 $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \
325 $@ $< $(call reverse-list,$(PRIVATE_STATIC_JAVA_LIBRARIES))
Nan Zhang9bd54052017-09-13 13:13:53 -0700326
Colin Crossf8a49c52017-05-22 16:21:49 -0700327ifdef LOCAL_JAR_PROCESSOR
328# LOCAL_JAR_PROCESSOR_ARGS must be evaluated here to set up the rule-local
329# PRIVATE_JAR_PROCESSOR_ARGS variable, but $< and $@ are not available yet.
330# Set ${in} and ${out} so they can be referenced by LOCAL_JAR_PROCESSOR_ARGS
331# using deferred evaluation (LOCAL_JAR_PROCESSOR_ARGS = instead of :=).
Nan Zhang9bd54052017-09-13 13:13:53 -0700332in := $(full_classes_combined_jar)
Colin Crossf8a49c52017-05-22 16:21:49 -0700333out := $(full_classes_processed_jar).tmp
Colin Cross89b802b2017-07-13 19:25:47 -0700334my_jar_processor := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_JAR_PROCESSOR).jar
335
Colin Crossf8a49c52017-05-22 16:21:49 -0700336$(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR_ARGS := $(LOCAL_JAR_PROCESSOR_ARGS)
Colin Cross89b802b2017-07-13 19:25:47 -0700337$(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR := $(my_jar_processor)
Colin Crossf8a49c52017-05-22 16:21:49 -0700338$(full_classes_processed_jar): PRIVATE_TMP_OUT := $(out)
339in :=
340out :=
341
Nan Zhang9bd54052017-09-13 13:13:53 -0700342$(full_classes_processed_jar): $(full_classes_combined_jar) $(my_jar_processor)
Colin Crossf8a49c52017-05-22 16:21:49 -0700343 @echo Processing $@ with $(PRIVATE_JAR_PROCESSOR)
344 $(hide) rm -f $@ $(PRIVATE_TMP_OUT)
Colin Cross0851df82017-06-30 13:55:38 -0700345 $(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS)
Colin Crossf8a49c52017-05-22 16:21:49 -0700346 $(hide) mv $(PRIVATE_TMP_OUT) $@
347
Colin Cross89b802b2017-07-13 19:25:47 -0700348my_jar_processor :=
Colin Crossf8a49c52017-05-22 16:21:49 -0700349else
Nan Zhang9bd54052017-09-13 13:13:53 -0700350full_classes_processed_jar := $(full_classes_combined_jar)
Colin Crossf8a49c52017-05-22 16:21:49 -0700351endif
352
Nan Zhang870025f2017-09-13 14:56:11 -0700353# Run jarjar if necessary
354ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
355$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
356$(full_classes_jarjar_jar): $(full_classes_processed_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
357 @echo JarJar: $@
358 $(hide) $(JAVA) -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
359else
360full_classes_jarjar_jar := $(full_classes_processed_jar)
361endif
362
363$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
364
Colin Cross96873482017-12-22 16:51:23 -0800365LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)
366
367#######################################
368include $(BUILD_SYSTEM)/jacoco.mk
369#######################################
370
Tobias Thierer7ef760b2017-11-17 13:02:12 +0000371# Temporarily enable --multi-dex until proguard supports v53 class files
372# ( http://b/67673860 ) or we move away from proguard altogether.
Tobias Thiererf6bd4952017-11-15 20:55:03 +0000373ifdef TARGET_OPENJDK9
Tobias Thierer89740662017-10-25 02:38:01 +0100374LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex
375endif
376
Colin Crosscf010852018-06-06 21:46:25 +0000377full_classes_pre_proguard_jar := $(LOCAL_FULL_CLASSES_JACOCO_JAR)
Ying Wang3b2bdf12010-02-01 09:51:23 -0800378
Colin Cross950f1ef2017-04-05 15:30:42 -0700379# Keep a copy of the jar just before proguard processing.
380$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(intermediates.COMMON)/classes-pre-proguard.jar))
Shinichiro Hamaji89b255a2015-11-09 16:47:42 +0900381
Colin Cross0e537342017-03-29 12:17:36 -0700382# Run proguard if necessary
Ying Wang7311a342013-08-21 18:32:49 -0700383ifdef LOCAL_PROGUARD_ENABLED
Colin Crosse616f342017-12-28 09:43:41 -0800384ifneq ($(filter-out full custom obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),)
Ying Wang7311a342013-08-21 18:32:49 -0700385 $(warning while processing: $(LOCAL_MODULE))
386 $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
387endif
Joe Onorato2daa2b32009-08-30 13:39:24 -0700388proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
Søren Gjesse9fbdd9e2018-04-13 15:34:20 +0200389proguard_configuration := $(intermediates.COMMON)/proguard_configuration
Ying Wang4f5d0e62015-05-04 19:21:48 -0700390
Colin Crossb5f25a22017-10-20 19:16:41 -0700391# When an app contains references to APIs that are not in the SDK specified by
Anton Hansson400673c2018-04-10 16:16:33 +0100392# its LOCAL_SDK_VERSION for example added by support library or by runtime
Colin Crossb5f25a22017-10-20 19:16:41 -0700393# classes added by desugar, we artifically raise the "SDK version" "linked" by
394# ProGuard, to
Ying Wang4f5d0e62015-05-04 19:21:48 -0700395# - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version.
396# - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
Colin Crossb5f25a22017-10-20 19:16:41 -0700397# See b/20667396
398my_proguard_sdk_raise :=
Ying Wang4f5d0e62015-05-04 19:21:48 -0700399ifdef LOCAL_SDK_VERSION
Ying Wang4f5d0e62015-05-04 19:21:48 -0700400ifdef TARGET_BUILD_APPS
Jiyong Park5ebca302018-01-31 00:14:55 +0900401ifeq (,$(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
Anton Hansson400673c2018-04-10 16:16:33 +0100402 my_proguard_sdk_raise := $(call java-lib-header-files, $(call resolve-prebuilt-sdk-module,current))
Ying Wang742f5832015-06-26 12:33:06 -0700403endif
Ying Wang4f5d0e62015-05-04 19:21:48 -0700404else
405 # For platform build, we can't just raise to the "current" SDK,
406 # that would break apps that use APIs removed from the current SDK.
Colin Crossb5f25a22017-10-20 19:16:41 -0700407 my_proguard_sdk_raise := $(call java-lib-header-files,$(TARGET_DEFAULT_BOOTCLASSPATH_LIBRARIES) $(TARGET_DEFAULT_JAVA_LIBRARIES))
Ying Wang4f5d0e62015-05-04 19:21:48 -0700408endif
409endif
Ying Wang4f5d0e62015-05-04 19:21:48 -0700410
Colin Crossb5f25a22017-10-20 19:16:41 -0700411legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \
412 $(filter-out $(my_proguard_sdk_raise), \
Colin Crossb541aae2017-09-23 19:52:43 -0700413 $(full_java_bootclasspath_libs) \
414 $(full_shared_java_header_libs)))
Nan Zhangb3ec5342017-08-31 21:43:04 +0000415
Colin Crossb5f25a22017-10-20 19:16:41 -0700416legacy_proguard_lib_deps := $(my_proguard_sdk_raise) \
417 $(filter-out $(my_proguard_sdk_raise),$(full_shared_java_header_libs))
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100418
419legacy_proguard_flags += -printmapping $(proguard_dictionary)
Søren Gjesse9fbdd9e2018-04-13 15:34:20 +0200420legacy_proguard_flags += -printconfiguration $(proguard_configuration)
Yohann Rousselb7de0fb2015-11-03 18:33:21 +0100421
422common_proguard_flags := -forceprocessing
Ying Wang7311a342013-08-21 18:32:49 -0700423
Colin Crosse616f342017-12-28 09:43:41 -0800424common_proguard_flag_files := $(BUILD_SYSTEM)/proguard.flags
Ying Wang7311a342013-08-21 18:32:49 -0700425ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200426common_proguard_flags += -dontshrink # don't shrink tests by default
Ying Wang3b2bdf12010-02-01 09:51:23 -0800427endif # test package
Dan Willemsen1d646232017-11-17 13:11:26 -0800428ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
Colin Cross20299032018-05-09 13:29:51 -0700429 ifeq ($(LOCAL_USE_AAPT2),true)
Dan Willemsen1d646232017-11-17 13:11:26 -0800430 common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
431 $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)
432 endif
433endif
Shinichiro Hamaji4eaeef82016-04-07 18:56:42 +0900434ifneq ($(common_proguard_flag_files),)
435common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files))
436# This is included from $(BUILD_SYSTEM)/proguard.flags
437common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_basic_keeps.flags
438endif
439
Ying Wang7311a342013-08-21 18:32:49 -0700440ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
441# By default no obfuscation
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200442common_proguard_flags += -dontobfuscate
Ying Wang7311a342013-08-21 18:32:49 -0700443endif # No obfuscation
444ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),)
445# By default no optimization
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200446common_proguard_flags += -dontoptimize
Ying Wang7311a342013-08-21 18:32:49 -0700447endif # No optimization
Ying Wang3b2bdf12010-02-01 09:51:23 -0800448
Ying Wang7311a342013-08-21 18:32:49 -0700449ifdef LOCAL_INSTRUMENTATION_FOR
450ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
451# If no obfuscation, link in the instrmented package's classes.jar as a library.
452# link_instr_classes_jar is defined in base_rule.mk
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200453legacy_proguard_flags += -libraryjars $(link_instr_classes_jar)
Nan Zhangb3ec5342017-08-31 21:43:04 +0000454legacy_proguard_lib_deps += $(link_instr_classes_jar)
Ying Wang7311a342013-08-21 18:32:49 -0700455else # obfuscation
456# If obfuscation is enabled, the main app must be obfuscated too.
457# We need to run obfuscation using the main app's dictionary,
458# and treat the main app's class.jar as injars instead of libraryjars.
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200459legacy_proguard_flags := -injars $(link_instr_classes_jar) \
Ying Wang7311a342013-08-21 18:32:49 -0700460 -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \
461 -include $(link_instr_intermediates_dir.COMMON)/proguard_options \
462 -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \
463 -verbose \
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200464 $(legacy_proguard_flags)
Ying Wang7311a342013-08-21 18:32:49 -0700465
466# Sometimes (test + main app) uses different keep rules from the main app -
467# apply the main app's dictionary anyway.
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200468legacy_proguard_flags += -ignorewarnings
Ying Wang7311a342013-08-21 18:32:49 -0700469
470# Make sure we run Proguard on the main app first
471$(full_classes_proguard_jar) : $(link_instr_intermediates_dir.COMMON)/proguard.classes.jar
472
473endif # no obfuscation
474endif # LOCAL_INSTRUMENTATION_FOR
Joe Onorato2daa2b32009-08-30 13:39:24 -0700475
Ying Wang0b9382c2010-09-29 14:50:41 -0700476proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES))
Colin Cross5c66c282018-03-14 09:56:04 -0700477ifeq ($(LOCAL_USE_R8),true)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200478proguard_flag_files += $(addprefix $(LOCAL_PATH)/, $(LOCAL_R8_FLAG_FILES))
Colin Cross5c66c282018-03-14 09:56:04 -0700479endif # LOCAL_USE_R8
Ying Wang0b9382c2010-09-29 14:50:41 -0700480LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files))
481
Mihail Dumitrescu4df82b32014-02-07 15:18:59 +0000482ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
483extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar
484else
485extra_input_jar :=
486endif
Paul Duffinf22aca12017-02-21 13:11:13 +0000487
Colin Crosse673deb2017-09-27 14:28:41 -0700488# If building against the current SDK version then filter out the junit,
489# android.test and c.a.i.u.Predicate classes that are to be removed from
490# the Android API as part of b/30188076 but which are still present in
491# the Android API. This is to allow changes to be made to the build to
492# statically include those classes into the application without
Paul Duffinf22aca12017-02-21 13:11:13 +0000493# simultaneously removing those classes from the API.
494proguard_injar_filters :=
Paul Duffinf22aca12017-02-21 13:11:13 +0000495ifdef LOCAL_SDK_VERSION
496ifeq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
Paul Duffin54747a72017-06-15 08:42:23 +0100497proguard_injar_filters := (!junit/framework/**,!junit/runner/**,!junit/textui/**,!android/test/**,!com/android/internal/util/*)
Paul Duffinf22aca12017-02-21 13:11:13 +0000498endif
499endif
Paul Duffinf22aca12017-02-21 13:11:13 +0000500
Dan Willemsenbdd6a752017-09-25 23:36:19 -0700501ifneq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
Colin Cross5c66c282018-03-14 09:56:04 -0700502ifneq ($(LOCAL_USE_R8),true)
Søren Gjesse9fbdd9e2018-04-13 15:34:20 +0200503 $(full_classes_proguard_jar): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) $(proguard_configuration)
Søren Gjesse4ab5b022017-10-25 17:10:59 +0200504else
Søren Gjesse9fbdd9e2018-04-13 15:34:20 +0200505 $(built_dex_intermediate): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) $(proguard_configuration)
Søren Gjesse4ab5b022017-10-25 17:10:59 +0200506endif
Dan Willemsenbdd6a752017-09-25 23:36:19 -0700507endif
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200508
509# If R8 is not enabled run Proguard.
Colin Cross5c66c282018-03-14 09:56:04 -0700510ifneq ($(LOCAL_USE_R8),true)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200511# Changes to these dependencies need to be replicated below when using R8
512# instead of Proguard + dx.
Paul Duffinf22aca12017-02-21 13:11:13 +0000513$(full_classes_proguard_jar): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters)
Mihail Dumitrescu4df82b32014-02-07 15:18:59 +0000514$(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200515$(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
Colin Crossb5f25a22017-10-20 19:16:41 -0700516$(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 -0800517 $(call transform-jar-to-proguard)
Colin Cross5c66c282018-03-14 09:56:04 -0700518else # !LOCAL_USE_R8
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200519# Running R8 instead of Proguard, proguarded jar is actually the pre-Proguarded jar.
520full_classes_proguard_jar := $(full_classes_pre_proguard_jar)
Colin Cross5c66c282018-03-14 09:56:04 -0700521endif # !LOCAL_USE_R8
Ying Wang3b2bdf12010-02-01 09:51:23 -0800522
Ying Wang7311a342013-08-21 18:32:49 -0700523else # LOCAL_PROGUARD_ENABLED not defined
ShuJie Wang76e93ba2017-11-06 14:35:52 +0800524proguard_flag_files :=
Colin Cross950f1ef2017-04-05 15:30:42 -0700525full_classes_proguard_jar := $(full_classes_pre_proguard_jar)
Ying Wang7311a342013-08-21 18:32:49 -0700526endif # LOCAL_PROGUARD_ENABLED defined
527
Colin Cross96476c12017-04-06 09:56:19 -0700528ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
Colin Cross79e2f732016-12-21 14:29:13 -0800529$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200530
531my_r8 :=
532ifdef LOCAL_PROGUARD_ENABLED
Colin Cross5c66c282018-03-14 09:56:04 -0700533ifeq ($(LOCAL_USE_R8),true)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200534# These are the dependencies for the proguarded jar when running
535# Proguard + dx. They are used for the generated dex when using R8, as
536# R8 does Proguard + dx
537my_r8 := true
538$(built_dex_intermediate): PRIVATE_PROGUARD_INJAR_FILTERS := $(proguard_injar_filters)
539$(built_dex_intermediate): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
540$(built_dex_intermediate): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
Colin Crossc27df2b2018-05-10 12:35:56 -0700541$(built_dex_intermediate) : $(full_classes_proguard_jar) $(extra_input_jar) $(my_proguard_sdk_raise) $(common_proguard_flag_files) $(proguard_flag_files) $(legacy_proguard_lib_deps) $(R8_COMPAT_PROGUARD)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200542 $(transform-jar-to-dex-r8)
Colin Cross5c66c282018-03-14 09:56:04 -0700543endif # LOCAL_USE_R8
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200544endif # LOCAL_PROGUARD_ENABLED
545
546ifndef my_r8
Alan Leung5eb88c02017-12-20 20:03:58 -0800547$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX) $(ZIP2ZIP)
Colin Cross79e2f732016-12-21 14:29:13 -0800548 $(transform-classes.jar-to-dex)
Søren Gjesse0c1fe642017-10-12 16:09:13 +0200549endif
Colin Cross79e2f732016-12-21 14:29:13 -0800550
David Brazdilb8fa6dd2018-01-29 14:43:14 +0000551ifneq ($(filter $(LOCAL_MODULE),$(PRODUCT_BOOT_JARS)),) # is_boot_jar
552 $(eval $(call hiddenapi-copy-dex-files,$(built_dex_intermediate),$(built_dex_hiddenapi)))
553 built_dex_copy_from := $(built_dex_hiddenapi)
554else # !is_boot_jar
555 built_dex_copy_from := $(built_dex_intermediate)
556endif # is_boot_jar
557
558$(built_dex): $(built_dex_copy_from)
Guang Zhu155afe32010-03-10 15:48:03 -0800559 @echo Copying: $@
Yohann Roussel8ffe9c32013-08-20 17:05:27 +0200560 $(hide) mkdir -p $(dir $@)
561 $(hide) rm -f $(dir $@)/classes*.dex
Colin Cross0e537342017-03-29 12:17:36 -0700562 $(hide) cp -fp $(dir $<)/classes*.dex $(dir $@)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800563
Colin Cross9eff8302017-04-27 15:05:44 -0700564java-dex: $(built_dex)
565
Colin Cross96476c12017-04-06 09:56:19 -0700566endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
567
The Android Open Source Project88b60792009-03-03 19:28:42 -0800568findbugs_xml := $(intermediates.COMMON)/findbugs.xml
Ying Wang702e01e2015-10-21 10:30:51 -0700569$(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
570 $(call normalize-path-list,$(filter %.jar,$(full_java_libs)))))
571$(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS)
Colin Cross950f1ef2017-04-05 15:30:42 -0700572$(findbugs_xml) : $(full_classes_pre_proguard_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800573 @echo Findbugs: $@
574 $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \
Ying Wang702e01e2015-10-21 10:30:51 -0700575 $(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \
Yohann Rousseld2a76c12015-02-05 16:10:58 +0100576 $< \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800577 > $@
578
579ALL_FINDBUGS_FILES += $(findbugs_xml)
580
581findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html
582$(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml)
583$(LOCAL_MODULE)-findbugs : $(findbugs_html)
584$(findbugs_html) : $(findbugs_xml)
585 @mkdir -p $(dir $@)
Andrew Stadlercef9ed92009-05-13 00:44:59 -0700586 @echo ConvertXmlToText: $@
Yuncheol Heo623d7062014-05-20 17:04:16 +0900587 $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl $(PRIVATE_XML_FILE) \
The Android Open Source Project88b60792009-03-03 19:28:42 -0800588 > $@
589
590$(LOCAL_MODULE)-findbugs : $(findbugs_html)
591
Ying Wang990cf5e2013-08-28 13:04:46 -0700592endif # full_classes_jar is defined
Yohann Rousselb4c49cb2014-09-08 14:45:14 +0200593
Jiyong Park5ebca302018-01-31 00:14:55 +0900594ifneq (,$(filter-out current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
Sundong Ahn5a44d1f2017-10-16 19:20:34 +0900595 my_default_app_target_sdk := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
596 my_sdk_version := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
Colin Cross536ef4e2017-02-21 16:14:55 -0800597else
Colin Cross9deb3312017-09-28 16:17:36 -0700598 my_default_app_target_sdk := $(DEFAULT_APP_TARGET_SDK)
599 my_sdk_version := $(PLATFORM_SDK_VERSION)
Colin Cross536ef4e2017-02-21 16:14:55 -0800600endif
601
Colin Cross9deb3312017-09-28 16:17:36 -0700602ifdef LOCAL_MIN_SDK_VERSION
603 my_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
604else
605 my_min_sdk_version := $(call codename-or-sdk-to-sdk,$(my_default_app_target_sdk))
606endif
607
608$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(my_default_app_target_sdk)
609$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(my_sdk_version)
610$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version)