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