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