java_library.mk revision 7bbea4b5c1f053cbe428025e9f9dec0e50bcc551
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 32ifeq (true,$(WITH_DEXPREOPT)) 33ifeq (,$(TARGET_BUILD_APPS)) 34ifndef LOCAL_DEX_PREOPT 35LOCAL_DEX_PREOPT := true 36endif 37endif 38endif 39 40################################# 41include $(BUILD_SYSTEM)/java.mk 42################################# 43 44ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) 45# No dex or resources; all we want are the .class files. 46$(common_javalib.jar) : $(full_classes_jar) 47 @echo "target Static Jar: $(PRIVATE_MODULE) ($@)" 48 $(copy-file-to-target) 49 50$(LOCAL_BUILT_MODULE): $(common_javalib.jar) 51 $(copy-file-to-target) 52 53else # !LOCAL_IS_STATIC_JAVA_LIBRARY 54 55$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) 56$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(AAPT) 57 @echo "target Jar: $(PRIVATE_MODULE) ($@)" 58 $(create-empty-package) 59 $(add-dex-to-package) 60ifneq ($(extra_jar_args),) 61 $(add-java-resources-to-package) 62endif 63 64ifeq ($(LOCAL_DEX_PREOPT),true) 65dexpreopt_boot_jar_module := $(filter $(LOCAL_MODULE),$(DEXPREOPT_BOOT_JARS_MODULES)) 66ifneq ($(dexpreopt_boot_jar_module),) 67# boot jar's rules are defined in dex_preopt.mk 68dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar 69$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP) 70 $(call copy-file-to-target) 71 72dexpreopted_boot_odex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module).odex 73built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex 74$(built_odex) : $(dexpreopted_boot_odex) | $(ACP) 75 $(call copy-file-to-target) 76 77else # dexpreopt_boot_jar_module 78built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex 79$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE) 80# Make sure the boot jars get dex-preopt-ed first 81$(built_odex) : $(DEXPREOPT_BOOT_ODEXS) 82$(built_odex) : $(common_javalib.jar) | $(DEXPREOPT) $(DEXOPT) 83 @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)" 84 $(hide) rm -f $@ 85 $(call dexpreopt-one-file,$<,$@) 86 87$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) $(AAPT) 88 $(call copy-file-to-target) 89 $(call dexpreopt-remove-classes.dex,$@) 90 91endif # dexpreopt_boot_jar_module 92 93else # LOCAL_DEX_PREOPT 94$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) 95 $(call copy-file-to-target) 96 97endif # LOCAL_DEX_PREOPT 98endif # !LOCAL_IS_STATIC_JAVA_LIBRARY 99