• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Target Java.
2# Requires:
3# LOCAL_MODULE_SUFFIX
4# LOCAL_MODULE_CLASS
5# all_res_assets
6
7LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES))
8LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
9
10proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
11ifneq ($(proto_sources),)
12ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
13    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-micro
14else
15  ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
16    LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano
17  else
18    ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),stream)
19      # No library for stream protobufs
20    else
21      LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite
22    endif
23  endif
24endif
25endif
26
27# LOCAL_STATIC_JAVA_AAR_LIBRARIES and LOCAL_STATIC_ANDROID_LIBRARIES are also LOCAL_STATIC_JAVA_LIBRARIES.
28LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) \
29    $(LOCAL_STATIC_JAVA_AAR_LIBRARIES) \
30    $(LOCAL_STATIC_ANDROID_LIBRARIES))
31# LOCAL_SHARED_ANDROID_LIBRARIES are also LOCAL_JAVA_LIBRARIES.
32LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES) $(LOCAL_SHARED_ANDROID_LIBRARIES))
33
34LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
35ifeq ($(LOCAL_BUILT_MODULE_STEM),)
36$(error $(LOCAL_PATH): Target java template must define LOCAL_BUILT_MODULE_STEM)
37endif
38ifneq ($(filter classes-compiled.jar classes.jar,$(LOCAL_BUILT_MODULE_STEM)),)
39$(error LOCAL_BUILT_MODULE_STEM may not be "$(LOCAL_BUILT_MODULE_STEM)")
40endif
41
42
43##############################################################################
44# Define the intermediate targets before including base_rules so they get
45# the correct environment.
46##############################################################################
47
48intermediates := $(call local-intermediates-dir)
49intermediates.COMMON := $(call local-intermediates-dir,COMMON)
50
51ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
52LOCAL_PROGUARD_ENABLED :=
53endif
54
55full_classes_turbine_jar := $(intermediates.COMMON)/classes-turbine.jar
56full_classes_header_jarjar := $(intermediates.COMMON)/classes-header-jarjar.jar
57full_classes_header_jar := $(intermediates.COMMON)/classes-header.jar
58full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
59full_classes_processed_jar := $(intermediates.COMMON)/classes-processed.jar
60full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
61full_classes_combined_jar := $(intermediates.COMMON)/classes-combined.jar
62built_dex_intermediate := $(intermediates.COMMON)/dex/classes.dex
63full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
64java_source_list_file := $(intermediates.COMMON)/java-source-list
65
66ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS)
67# If this is an apk without any Java code (e.g. framework-res), we should skip compiling Java.
68full_classes_jar :=
69built_dex :=
70else
71full_classes_jar := $(intermediates.COMMON)/classes.jar
72built_dex := $(intermediates.COMMON)/classes.dex
73endif
74
75LOCAL_INTERMEDIATE_TARGETS += \
76    $(full_classes_turbine_jar) \
77    $(full_classes_compiled_jar) \
78    $(full_classes_jarjar_jar) \
79    $(full_classes_jar) \
80    $(full_classes_combined_jar) \
81    $(built_dex_intermediate) \
82    $(built_dex) \
83    $(full_classes_stubs_jar) \
84    $(java_source_list_file)
85
86###########################################################
87## AIDL: Compile .aidl files to .java
88###########################################################
89aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
90aidl_java_sources :=
91
92ifneq ($(strip $(aidl_sources)),)
93
94aidl_preprocess_import :=
95ifdef LOCAL_SDK_VERSION
96ifneq ($(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_USE_PREBUILT_SDKS)),)
97  # LOCAL_SDK_VERSION is current and no TARGET_BUILD_USE_PREBUILT_SDKS
98  aidl_preprocess_import := $(FRAMEWORK_AIDL)
99else
100  aidl_preprocess_import := $(call resolve-prebuilt-sdk-aidl-path,$(LOCAL_SDK_VERSION))
101endif # not current or system_current
102else
103# build against the platform.
104LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
105endif # LOCAL_SDK_VERSION
106
107$(foreach s,$(aidl_sources),\
108    $(eval $(call define-aidl-java-rule,$(s),$(intermediates.COMMON)/aidl,aidl_java_sources)))
109$(foreach java,$(aidl_java_sources), \
110    $(call include-depfile,$(java:%.java=%.P),$(java)))
111
112$(aidl_java_sources) : $(LOCAL_ADDITIONAL_DEPENDENCIES) $(aidl_preprocess_import)
113
114$(aidl_java_sources): PRIVATE_AIDL_FLAGS := $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
115$(aidl_java_sources): PRIVATE_MODULE := $(LOCAL_MODULE)
116
117endif
118
119##########################################
120
121# All of the rules after full_classes_compiled_jar are very unlikely
122# to fail except for bugs in their respective tools.  If you would
123# like to run these rules, add the "all" modifier goal to the make
124# command line.
125ifndef LOCAL_CHECKED_MODULE
126ifdef full_classes_jar
127LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
128endif
129endif
130
131#######################################
132include $(BUILD_SYSTEM)/base_rules.mk
133#######################################
134
135###########################################################
136## logtags: emit java source
137###########################################################
138ifneq ($(strip $(logtags_sources)),)
139
140logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/logtags/, $(logtags_sources)))
141logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources))
142
143$(logtags_java_sources): $(intermediates.COMMON)/logtags/%.java: $(LOCAL_PATH)/%.logtags $(JAVATAGS)
144	$(transform-logtags-to-java)
145
146else
147logtags_java_sources :=
148endif
149
150##########################################
151java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
152                $(filter %.java,$(LOCAL_GENERATED_SOURCES))
153java_intermediate_sources := $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
154all_java_sources := $(java_sources) $(java_intermediate_sources)
155ALL_MODULES.$(my_register_name).SRCS := $(ALL_MODULES.$(my_register_name).SRCS) $(all_java_sources)
156
157include $(BUILD_SYSTEM)/java_common.mk
158
159include $(BUILD_SYSTEM)/sdk_check.mk
160
161# Set the profile source so that the odex / profile code included from java.mk
162# can find it.
163#
164# TODO: b/64896089, this is broken when called from package_internal.mk, since the file
165# we preopt from is a temporary file. This will be addressed in a follow up, possibly
166# by disabling stripping for profile guided preopt (which may be desirable for other
167# reasons anyway).
168#
169# Note that we set this only when called from package_internal.mk and not in other cases.
170ifneq (,$(called_from_package_internal)
171dex_preopt_profile_src_file := $(LOCAL_BUILT_MODULE)
172endif
173
174#######################################
175# defines built_odex along with rule to install odex
176my_manifest_or_apk := $(full_android_manifest)
177include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
178my_manifest_or_apk :=
179#######################################
180
181# Make sure there's something to build.
182ifdef full_classes_jar
183ifndef need_compile_java
184$(call pretty-error,Target java module does not define any source or resource files)
185endif
186endif
187
188# Since we're using intermediates.COMMON, make sure that it gets cleaned
189# properly.
190$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
191
192ifdef full_classes_jar
193
194# Droiddoc isn't currently able to generate stubs for modules, so we're just
195# allowing it to use the classes.jar as the "stubs" that would be use to link
196# against, for the cases where someone needs the jar to link against.
197$(eval $(call copy-one-file,$(full_classes_jar),$(full_classes_stubs_jar)))
198ALL_MODULES.$(my_register_name).STUBS := $(full_classes_stubs_jar)
199
200$(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE)
201
202# Compile the java files to a .jar file.
203# This intentionally depends on java_sources, not all_java_sources.
204# Deps for generated source files must be handled separately,
205# via deps on the target that generates the sources.
206
207# For user / userdebug builds, strip the local variable table and the local variable
208# type table. This has no bearing on stack traces, but will leave less information
209# available via JDWP.
210ifneq (,$(PRODUCT_MINIMIZE_JAVA_DEBUG_INFO))
211ifneq (,$(filter userdebug user,$(TARGET_BUILD_VARIANT)))
212LOCAL_JAVACFLAGS+= -g:source,lines
213endif
214endif
215
216# List of dependencies for anything that needs all java sources in place
217java_sources_deps := \
218    $(java_sources) \
219    $(java_resource_sources) \
220    $(LOCAL_SRCJARS) \
221    $(LOCAL_ADDITIONAL_DEPENDENCIES)
222
223$(java_source_list_file): $(java_sources_deps) $(NORMALIZE_PATH)
224	$(write-java-source-list)
225
226ALL_MODULES.$(my_register_name).SRCJARS := $(LOCAL_SRCJARS)
227
228ifneq ($(TURBINE_ENABLED),false)
229
230$(full_classes_turbine_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
231$(full_classes_turbine_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
232$(full_classes_turbine_jar): \
233    $(java_source_list_file) \
234    $(java_sources_deps) \
235    $(full_java_header_libs) \
236    $(full_java_bootclasspath_libs) \
237    $(full_java_system_modules_deps) \
238    $(NORMALIZE_PATH) \
239    $(JAR_ARGS) \
240    $(ZIPTIME) \
241    | $(TURBINE) \
242    $(MERGE_ZIPS)
243	$(transform-java-to-header.jar)
244
245.KATI_RESTAT: $(full_classes_turbine_jar)
246
247# Run jarjar before generate classes-header.jar if necessary.
248ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
249$(full_classes_header_jarjar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
250$(full_classes_header_jarjar): $(full_classes_turbine_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
251	$(call transform-jarjar)
252else
253full_classes_header_jarjar := $(full_classes_turbine_jar)
254endif
255
256$(eval $(call copy-one-file,$(full_classes_header_jarjar),$(full_classes_header_jar)))
257
258endif # TURBINE_ENABLED != false
259
260# TODO(b/143658984): goma can't handle the --system argument to javac.
261#$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(GOMA_POOL)
262$(full_classes_compiled_jar): .KATI_NINJA_POOL := $(JAVAC_NINJA_POOL)
263$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) $(annotation_processor_flags)
264$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
265$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
266$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
267$(full_classes_compiled_jar): PRIVATE_JAVA_SOURCE_LIST := $(java_source_list_file)
268$(full_classes_compiled_jar): PRIVATE_ALL_JAVA_HEADER_LIBRARIES := $(full_java_header_libs)
269$(full_classes_compiled_jar): PRIVATE_SRCJARS := $(LOCAL_SRCJARS)
270$(full_classes_compiled_jar): PRIVATE_SRCJAR_LIST_FILE := $(intermediates.COMMON)/srcjar-list
271$(full_classes_compiled_jar): PRIVATE_SRCJAR_INTERMEDIATES_DIR := $(intermediates.COMMON)/srcjars
272$(full_classes_compiled_jar): \
273    $(java_source_list_file) \
274    $(full_java_header_libs) \
275    $(java_sources_deps) \
276    $(full_java_bootclasspath_libs) \
277    $(full_java_system_modules_deps) \
278    $(layers_file) \
279    $(annotation_processor_deps) \
280    $(NORMALIZE_PATH) \
281    $(JAR_ARGS) \
282    $(ZIPSYNC) \
283    $(SOONG_ZIP) \
284    | $(SOONG_JAVAC_WRAPPER)
285	@echo "Target Java: $@
286	$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_ALL_JAVA_HEADER_LIBRARIES))
287
288javac-check : $(full_classes_compiled_jar)
289javac-check-$(LOCAL_MODULE) : $(full_classes_compiled_jar)
290.PHONY: javac-check-$(LOCAL_MODULE)
291
292$(full_classes_combined_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
293$(full_classes_combined_jar): $(full_classes_compiled_jar) \
294                              $(jar_manifest_file) \
295                              $(full_static_java_libs) | $(MERGE_ZIPS)
296	$(MERGE_ZIPS) -j --ignore-duplicates $(if $(PRIVATE_JAR_MANIFEST),-m $(PRIVATE_JAR_MANIFEST)) \
297            $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,-stripDir META-INF -zipToNotStrip $<) \
298            $@ $< $(PRIVATE_STATIC_JAVA_LIBRARIES)
299
300ifdef LOCAL_JAR_PROCESSOR
301# LOCAL_JAR_PROCESSOR_ARGS must be evaluated here to set up the rule-local
302# PRIVATE_JAR_PROCESSOR_ARGS variable, but $< and $@ are not available yet.
303# Set ${in} and ${out} so they can be referenced by LOCAL_JAR_PROCESSOR_ARGS
304# using deferred evaluation (LOCAL_JAR_PROCESSOR_ARGS = instead of :=).
305in := $(full_classes_combined_jar)
306out := $(full_classes_processed_jar).tmp
307my_jar_processor := $(HOST_OUT_JAVA_LIBRARIES)/$(LOCAL_JAR_PROCESSOR).jar
308
309$(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR_ARGS := $(LOCAL_JAR_PROCESSOR_ARGS)
310$(full_classes_processed_jar): PRIVATE_JAR_PROCESSOR := $(my_jar_processor)
311$(full_classes_processed_jar): PRIVATE_TMP_OUT := $(out)
312in :=
313out :=
314
315$(full_classes_processed_jar): $(full_classes_combined_jar) $(my_jar_processor)
316	@echo Processing $@ with $(PRIVATE_JAR_PROCESSOR)
317	$(hide) rm -f $@ $(PRIVATE_TMP_OUT)
318	$(hide) $(JAVA) -jar $(PRIVATE_JAR_PROCESSOR) $(PRIVATE_JAR_PROCESSOR_ARGS)
319	$(hide) mv $(PRIVATE_TMP_OUT) $@
320
321my_jar_processor :=
322else
323full_classes_processed_jar := $(full_classes_combined_jar)
324endif
325
326# Run jarjar if necessary
327ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
328$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
329$(full_classes_jarjar_jar): $(full_classes_processed_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
330	$(call transform-jarjar)
331else
332full_classes_jarjar_jar := $(full_classes_processed_jar)
333endif
334
335$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
336
337#######################################
338LOCAL_FULL_CLASSES_PRE_JACOCO_JAR := $(full_classes_jar)
339
340include $(BUILD_SYSTEM)/jacoco.mk
341#######################################
342
343# Temporarily enable --multi-dex until proguard supports v53 class files
344# ( http://b/67673860 ) or we move away from proguard altogether.
345LOCAL_DX_FLAGS := $(filter-out --multi-dex,$(LOCAL_DX_FLAGS)) --multi-dex
346
347full_classes_pre_proguard_jar := $(LOCAL_FULL_CLASSES_JACOCO_JAR)
348
349# Keep a copy of the jar just before proguard processing.
350$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(intermediates.COMMON)/classes-pre-proguard.jar))
351
352# Run proguard if necessary
353ifdef LOCAL_PROGUARD_ENABLED
354ifneq ($(filter-out full custom obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),)
355    $(warning while processing: $(LOCAL_MODULE))
356    $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
357endif
358proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
359proguard_configuration := $(intermediates.COMMON)/proguard_configuration
360
361# When an app contains references to APIs that are not in the SDK specified by
362# its LOCAL_SDK_VERSION for example added by support library or by runtime
363# classes added by desugar, we artifically raise the "SDK version" "linked" by
364# ProGuard, to
365# - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version.
366# - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
367# See b/20667396
368my_proguard_sdk_raise :=
369ifdef LOCAL_SDK_VERSION
370ifdef TARGET_BUILD_APPS
371ifeq (,$(filter current system_current test_current core_current, $(LOCAL_SDK_VERSION)))
372  my_proguard_sdk_raise := $(call java-lib-header-files, $(call resolve-prebuilt-sdk-module,current))
373endif
374else
375  # For platform build, we can't just raise to the "current" SDK,
376  # that would break apps that use APIs removed from the current SDK.
377  my_proguard_sdk_raise := $(call java-lib-header-files,$(LEGACY_CORE_PLATFORM_BOOTCLASSPATH_LIBRARIES) $(FRAMEWORK_LIBRARIES))
378endif
379ifdef BOARD_SYSTEMSDK_VERSIONS
380ifneq (,$(filter true,$(LOCAL_VENDOR_MODULE) $(LOCAL_ODM_MODULE) $(LOCAL_PROPRIETARY_MODULE)))
381  # But for vendor or odm apks, don't raise SDK as the apks are required to
382  # use SDK APIs only
383  my_proguard_sdk_raise :=
384endif
385endif
386endif
387
388legacy_proguard_flags := $(addprefix -libraryjars ,$(my_proguard_sdk_raise) \
389  $(filter-out $(my_proguard_sdk_raise), \
390    $(full_java_bootclasspath_libs) \
391    $(full_shared_java_header_libs)))
392
393legacy_proguard_lib_deps := $(my_proguard_sdk_raise) \
394  $(filter-out $(my_proguard_sdk_raise),$(full_java_bootclasspath_libs) $(full_shared_java_header_libs))
395
396legacy_proguard_flags += -printmapping $(proguard_dictionary)
397legacy_proguard_flags += -printconfiguration $(proguard_configuration)
398
399common_proguard_flags :=
400common_proguard_flag_files := $(BUILD_SYSTEM)/proguard.flags
401ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
402common_proguard_flags += -dontshrink # don't shrink tests by default
403endif # test package
404ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
405  common_proguard_flag_files += $(foreach l,$(LOCAL_STATIC_ANDROID_LIBRARIES),\
406      $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/export_proguard_flags)
407endif
408ifneq ($(common_proguard_flag_files),)
409common_proguard_flags += $(addprefix -include , $(common_proguard_flag_files))
410# This is included from $(BUILD_SYSTEM)/proguard.flags
411common_proguard_flag_files += $(BUILD_SYSTEM)/proguard_basic_keeps.flags
412endif
413
414ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
415# By default no obfuscation
416common_proguard_flags += -dontobfuscate
417endif  # No obfuscation
418ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),)
419# By default no optimization
420common_proguard_flags += -dontoptimize
421endif  # No optimization
422
423ifdef LOCAL_INSTRUMENTATION_FOR
424ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
425# If no obfuscation, link in the instrmented package's classes.jar as a library.
426# link_instr_classes_jar is defined in base_rule.mk
427legacy_proguard_flags += -libraryjars $(link_instr_classes_jar)
428legacy_proguard_lib_deps += $(link_instr_classes_jar)
429else # obfuscation
430# If obfuscation is enabled, the main app must be obfuscated too.
431# We need to run obfuscation using the main app's dictionary,
432# and treat the main app's class.jar as injars instead of libraryjars.
433legacy_proguard_flags := -injars  $(link_instr_classes_jar) \
434    -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \
435    -include $(link_instr_intermediates_dir.COMMON)/proguard_options \
436    -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \
437    -verbose \
438    $(legacy_proguard_flags)
439legacy_proguard_lib_deps += \
440  $(link_instr_classes_jar) \
441  $(link_instr_intermediates_dir.COMMON)/proguard_options \
442  $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \
443
444# Sometimes (test + main app) uses different keep rules from the main app -
445# apply the main app's dictionary anyway.
446legacy_proguard_flags += -ignorewarnings
447
448endif # no obfuscation
449endif # LOCAL_INSTRUMENTATION_FOR
450
451proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES))
452proguard_flag_files += $(addprefix $(LOCAL_PATH)/, $(LOCAL_R8_FLAG_FILES))
453LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files))
454LOCAL_PROGUARD_FLAGS_DEPS += $(proguard_flag_files)
455proguard_flag_files :=
456
457ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
458extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar
459else
460extra_input_jar :=
461endif
462
463ifneq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
464  $(built_dex_intermediate): .KATI_IMPLICIT_OUTPUTS := $(proguard_dictionary) $(proguard_configuration)
465
466  # Make a rule to copy the proguard_dictionary to a packaging directory.
467  $(eval $(call copy-one-file,$(proguard_dictionary),\
468    $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary))
469  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
470    $(call local-packaging-dir,proguard_dictionary)/proguard_dictionary)
471
472  $(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),\
473    $(call local-packaging-dir,proguard_dictionary)/classes.jar))
474  $(call add-dependency,$(LOCAL_BUILT_MODULE),\
475    $(call local-packaging-dir,proguard_dictionary)/classes.jar)
476endif
477
478endif # LOCAL_PROGUARD_ENABLED defined
479
480ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
481$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
482
483ifdef LOCAL_PROGUARD_ENABLED
484  $(built_dex_intermediate): .KATI_NINJA_POOL := $(R8_NINJA_POOL)
485  $(built_dex_intermediate): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
486  $(built_dex_intermediate): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
487  $(built_dex_intermediate): PRIVATE_PROGUARD_DICTIONARY := $(proguard_dictionary)
488  $(built_dex_intermediate) : $(full_classes_pre_proguard_jar) $(extra_input_jar) $(my_proguard_sdk_raise) $(common_proguard_flag_files) $(legacy_proguard_lib_deps) $(R8) $(LOCAL_PROGUARD_FLAGS_DEPS)
489	$(transform-jar-to-dex-r8)
490else # !LOCAL_PROGUARD_ENABLED
491  $(built_dex_intermediate): .KATI_NINJA_POOL := $(D8_NINJA_POOL)
492  $(built_dex_intermediate): PRIVATE_D8_LIBS := $(full_java_bootclasspath_libs) $(full_shared_java_header_libs)
493  $(built_dex_intermediate): $(full_java_bootclasspath_libs) $(full_shared_java_header_libs)
494  $(built_dex_intermediate): $(full_classes_pre_proguard_jar) $(D8) $(ZIP2ZIP)
495	$(transform-classes.jar-to-dex)
496endif
497
498$(foreach pair,$(PRODUCT_BOOT_JARS), \
499  $(if $(filter $(LOCAL_MODULE),$(call word-colon,2,$(pair))), \
500    $(call pretty-error,Modules in PRODUCT_BOOT_JARS must be defined in Android.bp files)))
501
502$(built_dex): $(built_dex_intermediate)
503	@echo Copying: $@
504	$(hide) mkdir -p $(dir $@)
505	$(hide) rm -f $(dir $@)/classes*.dex
506	$(hide) cp -fp $(dir $<)/classes*.dex $(dir $@)
507
508java-dex: $(built_dex)
509
510endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
511
512findbugs_xml := $(intermediates.COMMON)/findbugs.xml
513$(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
514    $(call normalize-path-list,$(filter %.jar,$(full_java_libs)))))
515$(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS)
516$(findbugs_xml) : $(full_classes_pre_proguard_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS))
517	@echo Findbugs: $@
518	$(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \
519		$(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \
520		$< \
521		> $@
522
523ALL_FINDBUGS_FILES += $(findbugs_xml)
524
525findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html
526$(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml)
527$(LOCAL_MODULE)-findbugs : $(findbugs_html)
528.PHONY: $(LOCAL_MODULE)-findbugs
529$(findbugs_html) : $(findbugs_xml)
530	@mkdir -p $(dir $@)
531	@echo ConvertXmlToText: $@
532	$(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl $(PRIVATE_XML_FILE) \
533	> $@
534
535$(LOCAL_MODULE)-findbugs : $(findbugs_html)
536
537endif  # full_classes_jar is defined
538
539$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(call module-target-sdk-version)
540$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(call module-sdk-version)
541$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MIN_SDK_VERSION := $(call codename-or-sdk-to-sdk,$(call module-min-sdk-version))
542