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 ifneq (true,$(WITH_DEXPREOPT)) 38 LOCAL_DEX_PREOPT := 39 else 40 ifeq (,$(TARGET_BUILD_APPS)) 41 ifeq (,$(LOCAL_APK_LIBRARIES)) 42 ifndef LOCAL_DEX_PREOPT 43 LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT) 44 endif 45 endif 46 endif 47 endif 48 ifeq (false,$(LOCAL_DEX_PREOPT)) 49 LOCAL_DEX_PREOPT := 50 endif 51 52 ifeq (true,$(EMMA_INSTRUMENT)) 53 ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) 54 ifeq (true,$(EMMA_INSTRUMENT_STATIC)) 55 LOCAL_STATIC_JAVA_LIBRARIES += emma 56 endif # LOCAL_EMMA_INSTRUMENT 57 endif # EMMA_INSTRUMENT_STATIC 58 else 59 LOCAL_EMMA_INSTRUMENT := false 60 endif # EMMA_INSTRUMENT 61 62 ################################# 63 include $(BUILD_SYSTEM)/java.mk 64 ################################# 65 66 ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) 67 # No dex; all we want are the .class files with resources. 68 $(common_javalib.jar) : $(java_resource_sources) 69 ifdef LOCAL_PROGUARD_ENABLED 70 $(common_javalib.jar) : $(full_classes_proguard_jar) 71 else 72 $(common_javalib.jar) : $(full_classes_jar) 73 endif 74 @echo "target Static Jar: $(PRIVATE_MODULE) ($@)" 75 $(copy-file-to-target) 76 ifneq ($(extra_jar_args),) 77 $(add-java-resources-to-package) 78 endif 79 80 $(LOCAL_BUILT_MODULE): $(common_javalib.jar) 81 $(copy-file-to-target) 82 83 else # !LOCAL_IS_STATIC_JAVA_LIBRARY 84 85 $(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) 86 $(common_javalib.jar) : $(built_dex) $(java_resource_sources) 87 @echo "target Jar: $(PRIVATE_MODULE) ($@)" 88 $(create-empty-package) 89 $(add-dex-to-package) 90 $(add-carried-java-resources) 91 ifneq ($(extra_jar_args),) 92 $(add-java-resources-to-package) 93 endif 94 95 ifdef LOCAL_DEX_PREOPT 96 dexpreopt_boot_jar_module := $(filter $(LOCAL_MODULE),$(DEXPREOPT_BOOT_JARS_MODULES)) 97 ifneq ($(dexpreopt_boot_jar_module),) 98 # boot jar's rules are defined in dex_preopt.mk 99 dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar 100 $(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP) 101 $(call copy-file-to-target) 102 103 dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex 104 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex 105 $(built_odex) : $(dexpreopted_boot_odex) | $(ACP) 106 $(call copy-file-to-target) 107 108 else # dexpreopt_boot_jar_module 109 built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex 110 $(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) 111 # Make sure the boot jars get dex-preopt-ed first 112 $(built_odex) : $(DEXPREOPT_BOOT_ODEXS) 113 $(built_odex) : $(common_javalib.jar) | $(DEXPREOPT) $(DEXOPT) 114 @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" 115 $(hide) rm -f $@ 116 @mkdir -p $(dir $@) 117 $(call dexpreopt-one-file,$<,$@) 118 119 $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) 120 $(call copy-file-to-target) 121 ifneq (nostripping,$(LOCAL_DEX_PREOPT)) 122 $(call dexpreopt-remove-classes.dex,$@) 123 endif 124 125 endif # dexpreopt_boot_jar_module 126 127 else # LOCAL_DEX_PREOPT 128 $(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) 129 $(call copy-file-to-target) 130 131 endif # LOCAL_DEX_PREOPT 132 endif # !LOCAL_IS_STATIC_JAVA_LIBRARY 133