java.mk revision 576e0146a91f0f092cf67208c864ab9635b42222
1# Requires: 2# LOCAL_MODULE_SUFFIX 3# LOCAL_MODULE_CLASS 4# all_res_assets 5 6ifeq ($(TARGET_BUILD_PDK),true) 7ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),) 8# LOCAL_SDK not defined or set to current 9ifeq ($(filter-out current,$(LOCAL_SDK_VERSION)),) 10LOCAL_SDK_VERSION := $(PDK_BUILD_SDK_VERSION) 11endif 12endif # !PDK_JAVA 13endif #PDK 14 15 16# Make sure there's something to build. 17# It's possible to build a package that doesn't contain any classes. 18# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files, 19# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR. 20# You have to set up the dependency in some other way. 21ifeq (,$(strip $(LOCAL_SRC_FILES)$(all_res_assets)$(LOCAL_STATIC_JAVA_LIBRARIES))$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))) 22$(error $(LOCAL_PATH): Target java module does not define any source or resource files) 23endif 24 25LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES)) 26LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION)) 27 28ifneq ($(LOCAL_SDK_VERSION),) 29 ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 30 $(error $(LOCAL_PATH): Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION) 31 else 32 ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),) 33 $(error $(LOCAL_PATH): Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \ 34 Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS)) 35 else 36 ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current) 37 # Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS. 38 LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES) 39 else 40 LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES) 41 endif 42 endif 43 endif 44else 45 ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) 46 LOCAL_JAVA_LIBRARIES := $(TARGET_DEFAULT_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES) 47 endif 48endif 49 50proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES)) 51ifneq ($(proto_sources),) 52ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro) 53 LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-micro 54else 55 ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano) 56 LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-nano 57 else 58 LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-2.3.0-lite 59 endif 60endif 61endif 62 63LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES)) 64 65LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM)) 66ifeq ($(LOCAL_BUILT_MODULE_STEM),) 67$(error $(LOCAL_PATH): Target java template must define LOCAL_BUILT_MODULE_STEM) 68endif 69ifneq ($(filter classes-compiled.jar classes.jar,$(LOCAL_BUILT_MODULE_STEM)),) 70$(error LOCAL_BUILT_MODULE_STEM may not be "$(LOCAL_BUILT_MODULE_STEM)") 71endif 72 73 74############################################################################## 75# Define the intermediate targets before including base_rules so they get 76# the correct environment. 77############################################################################## 78 79intermediates := $(call local-intermediates-dir) 80intermediates.COMMON := $(call local-intermediates-dir,COMMON) 81 82# Choose leaf name for the compiled jar file. 83ifeq ($(LOCAL_EMMA_INSTRUMENT),true) 84full_classes_compiled_jar_leaf := classes-no-debug-var.jar 85built_dex_intermediate_leaf := classes-no-local.dex 86else 87full_classes_compiled_jar_leaf := classes-full-debug.jar 88built_dex_intermediate_leaf := classes-with-local.dex 89endif 90 91ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) 92LOCAL_PROGUARD_ENABLED := 93endif 94 95# By giving different file name, files can be updated correctly when switching 96# between builds with and without Proguard enabled. 97# Note that ANY intermediate targets between the proguard and 98# the final built_dex should be differently named! 99ifdef LOCAL_PROGUARD_ENABLED 100proguard_jar_leaf := proguard.classes.jar 101built_dex_intermediate_leaf := proguard.$(built_dex_intermediate_leaf) 102built_dex_leaf := proguard.classes.dex 103else 104proguard_jar_leaf := noproguard.classes.jar 105built_dex_intermediate_leaf := noproguard.$(built_dex_intermediate_leaf) 106built_dex_leaf := noproguard.classes.dex 107endif 108 109full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_jar_leaf) 110jarjar_leaf := classes-jarjar.jar 111full_classes_jarjar_jar := $(intermediates.COMMON)/$(jarjar_leaf) 112emma_intermediates_dir := $(intermediates.COMMON)/emma_out 113# emma is hardcoded to use the leaf name of its input for the output file -- 114# only the output directory can be changed 115full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf) 116full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf) 117built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf) 118full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar 119 120# full_classes_jar and built_dex are cleared below, and re-set if we really need them. 121full_classes_jar := $(intermediates.COMMON)/classes.jar 122built_dex := $(intermediates.COMMON)/$(built_dex_leaf) 123 124LOCAL_INTERMEDIATE_TARGETS += \ 125 $(full_classes_compiled_jar) \ 126 $(full_classes_jarjar_jar) \ 127 $(full_classes_emma_jar) \ 128 $(full_classes_jar) \ 129 $(full_classes_proguard_jar) \ 130 $(built_dex_intermediate) \ 131 $(built_dex) \ 132 $(full_classes_stubs_jar) 133 134 135LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src 136 137############################################################### 138## .rs files: RenderScript sources to .java files and .bc files 139## .fs files: Filterscript sources to .java files and .bc files 140############################################################### 141renderscript_sources := $(filter %.rs %.fs,$(LOCAL_SRC_FILES)) 142# Because names of the java files from RenderScript are unknown until the 143# .rs file(s) are compiled, we have to depend on a timestamp file. 144RenderScript_file_stamp := 145rs_compatibility_jni_libs := 146ifneq ($(renderscript_sources),) 147renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) 148RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp 149renderscript_intermediate.COMMON := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript 150 151renderscript_target_api := 152 153ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) 154renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) 155else 156ifneq (,$(LOCAL_SDK_VERSION)) 157# Set target-api for LOCAL_SDK_VERSIONs other than current. 158ifneq (,$(filter-out current, $(LOCAL_SDK_VERSION))) 159renderscript_target_api := $(LOCAL_SDK_VERSION) 160endif 161endif # LOCAL_SDK_VERSION is set 162endif # LOCAL_RENDERSCRIPT_TARGET_API is set 163 164ifeq ($(LOCAL_RENDERSCRIPT_CC),) 165LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) 166endif 167 168# Turn on all warnings and warnings as errors for RS compiles. 169# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error 170renderscript_flags := -Wall -Werror 171renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) 172 173# prepend the RenderScript system include path 174ifneq ($(filter-out current,$(LOCAL_SDK_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current,$(LOCAL_SDK_VERSION))),) 175# if a numeric LOCAL_SDK_VERSION, or current LOCAL_SDK_VERSION with TARGET_BUILD_APPS 176LOCAL_RENDERSCRIPT_INCLUDES := \ 177 $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/clang-include \ 178 $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/include \ 179 $(LOCAL_RENDERSCRIPT_INCLUDES) 180else 181LOCAL_RENDERSCRIPT_INCLUDES := \ 182 $(TOPDIR)external/clang/lib/Headers \ 183 $(TOPDIR)frameworks/rs/scriptc \ 184 $(LOCAL_RENDERSCRIPT_INCLUDES) 185endif 186 187ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) 188LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) 189endif 190 191$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES) 192$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) 193$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) 194$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) 195# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be 196# automatically found by the java compiling function transform-java-to-classes.jar. 197$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON) 198$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) 199$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) 200 $(transform-renderscripts-to-java-and-bc) 201 202ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),) 203bc_files := $(patsubst %.fs,%.bc, $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources)))) 204rs_generated_bc := $(addprefix \ 205 $(renderscript_intermediate.COMMON)/res/raw/, $(bc_files)) 206 207renderscript_intermediate := $(intermediates)/renderscript 208 209# We don't need the .so files in bundled branches 210# Prevent these from showing up on the device 211ifneq (,$(TARGET_BUILD_APPS)) 212 213rs_compatibility_jni_libs := $(addprefix \ 214 $(renderscript_intermediate)/librs., \ 215 $(patsubst %.bc,%.so, $(bc_files))) 216 217$(rs_generated_bc) : $(RenderScript_file_stamp) 218 219rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so 220rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so 221LOCAL_JNI_SHARED_LIBRARIES += libRSSupport librsjni 222 223 224 225$(rs_compatibility_jni_libs): $(RenderScript_file_stamp) $(RS_PREBUILT_CLCORE) \ 226 $(rs_support_lib) $(rs_jni_lib) $(rs_compiler_rt) 227$(rs_compatibility_jni_libs): $(BCC_COMPAT) 228$(rs_compatibility_jni_libs): PRIVATE_CXX := $(TARGET_CXX) 229$(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \ 230 $(renderscript_intermediate.COMMON)/res/raw/%.bc 231 $(transform-bc-to-so) 232 233endif 234 235endif 236 237# include the dependency files (.d) generated by llvm-rs-cc. 238renderscript_generated_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/, \ 239 $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) 240-include $(renderscript_generated_dep_files) 241 242LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) 243# Make sure the generated resource will be added to the apk. 244LOCAL_RESOURCE_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript/res $(LOCAL_RESOURCE_DIR) 245endif 246 247# All of the rules after full_classes_compiled_jar are very unlikely 248# to fail except for bugs in their respective tools. If you would 249# like to run these rules, add the "all" modifier goal to the make 250# command line. 251java_alternative_checked_module := $(full_classes_compiled_jar) 252 253# TODO: It looks like the only thing we need from base_rules is 254# all_java_sources. See if we can get that by adding a 255# common_java.mk, and moving the include of base_rules.mk to 256# after all the declarations. 257 258####################################### 259include $(BUILD_SYSTEM)/base_rules.mk 260####################################### 261 262java_alternative_checked_module := 263 264# Install the RS compatibility libraries to /system/lib/ if necessary 265ifdef rs_compatibility_jni_libs 266installed_rs_compatibility_jni_libs := $(addprefix $(TARGET_OUT_SHARED_LIBRARIES)/,\ 267 $(notdir $(rs_compatibility_jni_libs))) 268# Provide a way to skip sources included in multiple projects. 269ifdef LOCAL_RENDERSCRIPT_SKIP_INSTALL 270skip_install_rs_libs := $(patsubst %.rs,%.so, \ 271 $(addprefix $(TARGET_OUT_SHARED_LIBRARIES)/librs., \ 272 $(notdir $(LOCAL_RENDERSCRIPT_SKIP_INSTALL)))) 273installed_rs_compatibility_jni_libs := \ 274 $(filter-out $(skip_install_rs_libs),$(installed_rs_compatibility_jni_libs)) 275endif 276ifneq (,$(strip $(installed_rs_compatibility_jni_libs))) 277$(installed_rs_compatibility_jni_libs) : $(TARGET_OUT_SHARED_LIBRARIES)/lib%.so : \ 278 $(renderscript_intermediate)/lib%.so 279 $(hide) mkdir -p $(dir $@) && cp -f $< $@ 280 281# Install them only if the current module is installed. 282$(LOCAL_INSTALLED_MODULE) : $(installed_rs_compatibility_jni_libs) 283endif 284endif 285 286# We use intermediates.COMMON because the classes.jar/.dex files will be 287# common even if LOCAL_BUILT_MODULE isn't. 288# 289# Override some target variables that base_rules set up for us. 290$(LOCAL_INTERMEDIATE_TARGETS): \ 291 PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes 292$(LOCAL_INTERMEDIATE_TARGETS): \ 293 PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR) 294 295# Since we're using intermediates.COMMON, make sure that it gets cleaned 296# properly. 297$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON) 298 299# If the module includes java code (i.e., it's not framework-res), compile it. 300full_classes_jar := 301built_dex := 302# need_compile_java is set in base_rules.mk 303ifeq ($(need_compile_java),true) 304 305# If LOCAL_BUILT_MODULE_STEM wasn't overridden by our caller, 306# full_classes_jar will be the same module as LOCAL_BUILT_MODULE. 307# Otherwise, the caller will define it as a prerequisite of 308# LOCAL_BUILT_MODULE, so it will inherit the necessary PRIVATE_* 309# variable definitions. 310full_classes_jar := $(intermediates.COMMON)/classes.jar 311built_dex := $(intermediates.COMMON)/$(built_dex_leaf) 312 313# Droiddoc isn't currently able to generate stubs for modules, so we're just 314# allowing it to use the classes.jar as the "stubs" that would be use to link 315# against, for the cases where someone needs the jar to link against. 316# - Use the classes.jar instead of the handful of other intermediates that 317# we have, because it's the most processed, but still hasn't had dex run on 318# it, so it's closest to what's on the device. 319# - This extra copy, with the dependency on LOCAL_BUILT_MODULE allows the 320# PRIVATE_ vars to be preserved. 321$(full_classes_stubs_jar): PRIVATE_SOURCE_FILE := $(full_classes_jar) 322$(full_classes_stubs_jar) : $(LOCAL_BUILT_MODULE) | $(ACP) 323 @echo Copying $(PRIVATE_SOURCE_FILE) 324 $(hide) $(ACP) -fp $(PRIVATE_SOURCE_FILE) $@ 325ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar) 326 327# The layers file allows you to enforce a layering between java packages. 328# Run build/tools/java-layers.py for more details. 329layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE)) 330$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file) 331$(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE) 332 333# Compile the java files to a .jar file. 334# This intentionally depends on java_sources, not all_java_sources. 335# Deps for generated source files must be handled separately, 336# via deps on the target that generates the sources. 337$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(LOCAL_JAVACFLAGS) 338$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES) 339$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES) 340$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF) 341$(full_classes_compiled_jar): $(java_sources) $(java_resource_sources) $(full_java_lib_deps) \ 342 $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) \ 343 $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) 344 $(transform-java-to-classes.jar) 345 346$(full_classes_compiled_jar): PRIVATE_JAVAC_DEBUG_FLAGS := -g 347 348# Run jarjar if necessary, otherwise just copy the file. 349ifneq ($(strip $(LOCAL_JARJAR_RULES)),) 350$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES) 351$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR) 352 @echo JarJar: $@ 353 $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@ 354else 355$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP) 356 @echo Copying: $@ 357 $(hide) $(ACP) -fp $< $@ 358endif 359 360ifeq ($(LOCAL_EMMA_INSTRUMENT),true) 361$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em 362$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir) 363# module level coverage filter can be defined using LOCAL_EMMA_COVERAGE_FILTER 364# in Android.mk 365ifdef LOCAL_EMMA_COVERAGE_FILTER 366$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER) 367else 368# by default, avoid applying emma instrumentation onto emma classes itself, 369# otherwise there will be exceptions thrown 370$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.* 371endif 372# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and 373# $(full_classes_emma_jar) 374$(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(EMMA_JAR) 375 $(transform-classes.jar-to-emma) 376 377else 378$(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(ACP) 379 @echo Copying: $@ 380 $(copy-file-to-target) 381endif 382 383# Keep a copy of the jar just before proguard processing. 384$(full_classes_jar): $(full_classes_emma_jar) | $(ACP) 385 @echo Copying: $@ 386 $(hide) $(ACP) -fp $< $@ 387 388# Run proguard if necessary, otherwise just copy the file. 389ifdef LOCAL_PROGUARD_ENABLED 390ifneq ($(filter-out full custom nosystem obfuscation optimization,$(LOCAL_PROGUARD_ENABLED)),) 391 $(warning while processing: $(LOCAL_MODULE)) 392 $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED)) 393endif 394proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary 395proguard_flags := $(addprefix -libraryjars ,$(full_shared_java_libs)) \ 396 -forceprocessing \ 397 -printmapping $(proguard_dictionary) 398 399ifeq ($(filter nosystem,$(LOCAL_PROGUARD_ENABLED)),) 400proguard_flags += -include $(BUILD_SYSTEM)/proguard.flags 401ifeq ($(LOCAL_EMMA_INSTRUMENT),true) 402proguard_flags += -include $(BUILD_SYSTEM)/proguard.emma.flags 403endif 404# If this is a test package, add proguard keep flags for tests. 405ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),) 406proguard_flags += -include $(BUILD_SYSTEM)/proguard_tests.flags 407endif # test package 408ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) 409# By default no obfuscation 410proguard_flags += -dontobfuscate 411endif # No obfuscation 412ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),) 413# By default no optimization 414proguard_flags += -dontoptimize 415endif # No optimization 416 417ifdef LOCAL_INSTRUMENTATION_FOR 418ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),) 419# If no obfuscation, link in the instrmented package's classes.jar as a library. 420# link_instr_classes_jar is defined in base_rule.mk 421proguard_flags += -libraryjars $(link_instr_classes_jar) 422else # obfuscation 423# If obfuscation is enabled, the main app must be obfuscated too. 424# We need to run obfuscation using the main app's dictionary, 425# and treat the main app's class.jar as injars instead of libraryjars. 426proguard_flags := -injars $(link_instr_classes_jar) \ 427 -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \ 428 -include $(link_instr_intermediates_dir.COMMON)/proguard_options \ 429 -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \ 430 -verbose \ 431 $(proguard_flags) 432 433# Sometimes (test + main app) uses different keep rules from the main app - 434# apply the main app's dictionary anyway. 435proguard_flags += -ignorewarnings 436 437# Make sure we run Proguard on the main app first 438$(full_classes_proguard_jar) : $(link_instr_intermediates_dir.COMMON)/proguard.classes.jar 439 440endif # no obfuscation 441endif # LOCAL_INSTRUMENTATION_FOR 442endif # LOCAL_PROGUARD_ENABLED is not nosystem 443 444proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES)) 445LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files)) 446 447$(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(proguard_flags) $(LOCAL_PROGUARD_FLAGS) 448$(full_classes_proguard_jar) : $(full_classes_jar) $(proguard_flag_files) | $(ACP) $(PROGUARD) 449 $(call transform-jar-to-proguard) 450 451else # LOCAL_PROGUARD_ENABLED not defined 452$(full_classes_proguard_jar) : $(full_classes_jar) 453 @echo Copying: $@ 454 $(hide) $(ACP) -fp $< $@ 455 456endif # LOCAL_PROGUARD_ENABLED defined 457 458 459# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug 460# will work even when intermediates != intermediates.COMMON. 461$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON) 462$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS) 463# If you instrument class files that have local variable debug information in 464# them emma does not correctly maintain the local variable table. 465# This will cause an error when you try to convert the class files for Android. 466# The workaround here is to build different dex file here based on emma switch 467# then later copy into classes.dex. When emma is on, dx is run with --no-locals 468# option to remove local variable information 469ifeq ($(LOCAL_EMMA_INSTRUMENT),true) 470$(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals 471endif 472$(built_dex_intermediate): $(full_classes_proguard_jar) $(DX) 473 $(transform-classes.jar-to-dex) 474$(built_dex): $(built_dex_intermediate) | $(ACP) 475 @echo Copying: $@ 476 $(hide) $(ACP) -fp $< $@ 477ifneq ($(GENERATE_DEX_DEBUG),) 478 $(install-dex-debug) 479endif 480 481findbugs_xml := $(intermediates.COMMON)/findbugs.xml 482$(findbugs_xml) : PRIVATE_JAR_FILE := $(full_classes_jar) 483$(findbugs_xml) : PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \ 484 $(call normalize-path-list,$(filter %.jar,\ 485 $(full_java_libs))))) 486# We can't depend directly on full_classes_jar because the PRIVATE_ 487# vars won't be set up correctly. 488$(findbugs_xml) : $(LOCAL_BUILT_MODULE) 489 @echo Findbugs: $@ 490 $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \ 491 $(PRIVATE_AUXCLASSPATH) \ 492 $(PRIVATE_JAR_FILE) \ 493 > $@ 494 495ALL_FINDBUGS_FILES += $(findbugs_xml) 496 497findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html 498$(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml) 499$(LOCAL_MODULE)-findbugs : $(findbugs_html) 500$(findbugs_html) : $(findbugs_xml) 501 @mkdir -p $(dir $@) 502 @echo ConvertXmlToText: $@ 503 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl $(PRIVATE_XML_FILE) \ 504 > $@ 505 506$(LOCAL_MODULE)-findbugs : $(findbugs_html) 507 508endif 509