1 ########################################################### 2 ## Standard rules for building a java library. 3 ## 4 ########################################################### 5 6 ifdef LOCAL_IS_HOST_MODULE 7 $(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY) 8 endif 9 10 LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX) 11 LOCAL_MODULE_CLASS := JAVA_LIBRARIES 12 13 ifneq (,$(LOCAL_ASSET_DIR)) 14 $(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR) 15 endif 16 17 ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY)) 18 ifneq (,$(LOCAL_RESOURCE_DIR)) 19 $(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR) 20 endif 21 # base_rules.mk looks at this 22 all_res_assets := 23 endif 24 25 LOCAL_BUILT_MODULE_STEM := javalib.jar 26 27 intermediates.COMMON := $(call local-intermediates-dir,COMMON) 28 29 # This file will be the one that other modules should depend on. 30 common_javalib.jar := $(intermediates.COMMON)/$(LOCAL_BUILT_MODULE_STEM) 31 LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) 32 33 ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) 34 LOCAL_PROGUARD_ENABLED := 35 endif 36 37 ifeq (true,$(EMMA_INSTRUMENT)) 38 ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) 39 ifeq (true,$(EMMA_INSTRUMENT_STATIC)) 40 LOCAL_STATIC_JAVA_LIBRARIES += emma 41 endif # LOCAL_EMMA_INSTRUMENT 42 endif # EMMA_INSTRUMENT_STATIC 43 else 44 LOCAL_EMMA_INSTRUMENT := false 45 endif # EMMA_INSTRUMENT 46 47 ################################# 48 include $(BUILD_SYSTEM)/java.mk 49 ################################# 50 51 ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) 52 # No dex; all we want are the .class files with resources. 53 $(common_javalib.jar) : $(java_resource_sources) 54 ifdef LOCAL_PROGUARD_ENABLED 55 $(common_javalib.jar) : $(full_classes_proguard_jar) 56 else 57 $(common_javalib.jar) : $(full_classes_jar) 58 endif 59 @echo "target Static Jar: $(PRIVATE_MODULE) ($@)" 60 $(copy-file-to-target) 61 ifneq ($(extra_jar_args),) 62 $(add-java-resources-to-package) 63 endif 64 65 $(LOCAL_BUILT_MODULE): $(common_javalib.jar) 66 $(copy-file-to-target) 67 68 else # !LOCAL_IS_STATIC_JAVA_LIBRARY 69 70 $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) 71 $(common_javalib.jar) : $(built_dex) $(java_resource_sources) 72 @echo "target Jar: $(PRIVATE_MODULE) ($@)" 73 $(create-empty-package) 74 $(add-dex-to-package) 75 $(add-carried-java-resources) 76 ifneq ($(extra_jar_args),) 77 $(add-java-resources-to-package) 78 endif 79 80 ifdef LOCAL_DEX_PREOPT 81 ifneq ($(dexpreopt_boot_jar_module),) # boot jar 82 # boot jar's rules are defined in dex_preopt.mk 83 dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar 84 $(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP) 85 $(call copy-file-to-target) 86 87 # For libart boot jars, we don't have .odex files. 88 ifeq ($(DALVIK_VM_LIB),libdvm.so) 89 dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex 90 $(built_odex) : $(dexpreopted_boot_odex) | $(ACP) 91 $(call copy-file-to-target) 92 endif 93 94 else # ! boot jar 95 $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) 96 # Use pattern rule - we may have multiple built odex files. 97 $(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar) 98 @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" 99 $(call dexpreopt-one-file,$<,$@) 100 101 $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) 102 $(call copy-file-to-target) 103 ifneq (nostripping,$(LOCAL_DEX_PREOPT)) 104 $(call dexpreopt-remove-classes.dex,$@) 105 endif 106 107 endif # ! boot jar 108 109 else # LOCAL_DEX_PREOPT 110 $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) 111 $(call copy-file-to-target) 112 113 endif # LOCAL_DEX_PREOPT 114 endif # !LOCAL_IS_STATIC_JAVA_LIBRARY 115