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