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 (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY)) 18ifneq (,$(LOCAL_RESOURCE_DIR)) 19$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR) 20endif 21# base_rules.mk looks at this 22all_res_assets := 23endif 24 25LOCAL_BUILT_MODULE_STEM := javalib.jar 26 27intermediates.COMMON := $(call local-intermediates-dir,COMMON) 28 29# This file will be the one that other modules should depend on. 30common_javalib.jar := $(intermediates.COMMON)/$(LOCAL_BUILT_MODULE_STEM) 31LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) 32 33ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) 34 LOCAL_PROGUARD_ENABLED := 35endif 36 37ifeq (true,$(EMMA_INSTRUMENT)) 38ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) 39ifeq (true,$(EMMA_INSTRUMENT_STATIC)) 40LOCAL_STATIC_JAVA_LIBRARIES += emma 41endif # LOCAL_EMMA_INSTRUMENT 42endif # EMMA_INSTRUMENT_STATIC 43else 44LOCAL_EMMA_INSTRUMENT := false 45endif # EMMA_INSTRUMENT 46 47################################# 48include $(BUILD_SYSTEM)/java.mk 49################################# 50 51ifeq ($(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) 54ifdef LOCAL_PROGUARD_ENABLED 55$(common_javalib.jar) : $(full_classes_proguard_jar) 56else 57$(common_javalib.jar) : $(full_classes_jar) 58endif 59 @echo "target Static Jar: $(PRIVATE_MODULE) ($@)" 60 $(copy-file-to-target) 61ifneq ($(extra_jar_args),) 62 $(add-java-resources-to-package) 63endif 64 65$(LOCAL_BUILT_MODULE): $(common_javalib.jar) 66 $(copy-file-to-target) 67 68else # !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) 76ifneq ($(extra_jar_args),) 77 $(add-java-resources-to-package) 78endif 79 80ifdef LOCAL_DEX_PREOPT 81ifneq ($(dexpreopt_boot_jar_module),) # boot jar 82# boot jar's rules are defined in dex_preopt.mk 83dexpreopted_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. 88ifeq ($(DALVIK_VM_LIB),libdvm.so) 89dexpreopted_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) 92endif 93 94else # ! 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) 103ifneq (nostripping,$(LOCAL_DEX_PREOPT)) 104 $(call dexpreopt-remove-classes.dex,$@) 105endif 106 107endif # ! boot jar 108 109else # LOCAL_DEX_PREOPT 110$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP) 111 $(call copy-file-to-target) 112 113endif # LOCAL_DEX_PREOPT 114endif # !LOCAL_IS_STATIC_JAVA_LIBRARY 115