1########################################################### 2## Standard rules for building a java library. 3## 4########################################################### 5$(call record-module-type,JAVA_LIBRARY) 6 7ifdef LOCAL_IS_HOST_MODULE 8$(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY) 9endif 10 11LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX) 12LOCAL_MODULE_CLASS := JAVA_LIBRARIES 13 14ifneq (,$(LOCAL_ASSET_DIR)) 15$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR) 16endif 17 18ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY)) 19ifneq (,$(LOCAL_RESOURCE_DIR)) 20$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR) 21endif 22# base_rules.mk looks at this 23all_res_assets := 24endif 25 26LOCAL_BUILT_MODULE_STEM := javalib.jar 27 28# For java libraries, other modules should depend on 29# out/target/common/obj/JAVA_LIBRARIES/.../classes.jar. 30# There are some dependencies outside the build system that assume static 31# java libraries produce javalib.jar, so we will copy classes.jar there too. 32intermediates.COMMON := $(call local-intermediates-dir,COMMON) 33common_javalib.jar := $(intermediates.COMMON)/javalib.jar 34dex_preopt_profile_src_file := $(common_javalib.jar) 35LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar) 36 37ifeq ($(LOCAL_PROGUARD_ENABLED),disabled) 38 LOCAL_PROGUARD_ENABLED := 39endif 40 41ifeq (true,$(EMMA_INSTRUMENT)) 42ifeq (true,$(LOCAL_EMMA_INSTRUMENT)) 43ifeq (true,$(EMMA_INSTRUMENT_STATIC)) 44LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent 45# Exclude jacoco classes from proguard 46LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags 47LOCAL_PROGUARD_FLAGS_DEPS += $(BUILD_SYSTEM)/proguard.jacoco.flags 48endif # LOCAL_EMMA_INSTRUMENT 49endif # EMMA_INSTRUMENT_STATIC 50else 51LOCAL_EMMA_INSTRUMENT := false 52endif # EMMA_INSTRUMENT 53 54my_dex_jar := $(common_javalib.jar) 55 56################################# 57include $(BUILD_SYSTEM)/java.mk 58################################# 59 60ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true) 61# There are some dependencies outside the build system that assume classes.jar 62# is available as javalib.jar so copy it there too. 63$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(common_javalib.jar))) 64 65$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(LOCAL_BUILT_MODULE))) 66 67else # !LOCAL_IS_STATIC_JAVA_LIBRARY 68 69$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex) 70$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar) 71$(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP) 72$(common_javalib.jar) : $(full_classes_pre_proguard_jar) $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN) 73 @echo "target Jar: $(PRIVATE_MODULE) ($@)" 74 rm -rf $@.parts && mkdir -p $@.parts 75 $(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE)) 76 $(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE)) 77 $(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip 78 rm -rf $@.parts 79 $(hide) $(ZIPTIME) $@.tmp 80 $(call commit-change-for-toc,$@) 81ifeq (true, $(LOCAL_UNCOMPRESS_DEX)) 82 $(uncompress-dexs) 83 $(align-package) 84endif # LOCAL_UNCOMPRESS_DEX 85 86.KATI_RESTAT: $(common_javalib.jar) 87 88$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE))) 89 90endif # !LOCAL_IS_STATIC_JAVA_LIBRARY 91