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