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