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