2009-03-04 04:28:42 +01:00
|
|
|
###########################################################
|
|
|
|
## Standard rules for building a java library.
|
|
|
|
##
|
|
|
|
###########################################################
|
2016-07-26 01:03:53 +02:00
|
|
|
$(call record-module-type,JAVA_LIBRARY)
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
ifdef LOCAL_IS_HOST_MODULE
|
|
|
|
$(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY)
|
|
|
|
endif
|
|
|
|
|
|
|
|
LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
|
|
|
|
LOCAL_MODULE_CLASS := JAVA_LIBRARIES
|
|
|
|
|
|
|
|
ifneq (,$(LOCAL_ASSET_DIR))
|
|
|
|
$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR)
|
|
|
|
endif
|
|
|
|
|
2011-12-14 23:29:28 +01:00
|
|
|
ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY))
|
2009-03-04 04:28:42 +01:00
|
|
|
ifneq (,$(LOCAL_RESOURCE_DIR))
|
|
|
|
$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR)
|
|
|
|
endif
|
2013-08-28 20:16:06 +02:00
|
|
|
# base_rules.mk looks at this
|
2009-03-04 04:28:42 +01:00
|
|
|
all_res_assets :=
|
2013-08-28 20:16:06 +02:00
|
|
|
endif
|
2009-03-04 04:28:42 +01:00
|
|
|
|
|
|
|
LOCAL_BUILT_MODULE_STEM := javalib.jar
|
|
|
|
|
2017-09-27 23:28:41 +02:00
|
|
|
# For java libraries, other modules should depend on
|
|
|
|
# out/target/common/obj/JAVA_LIBRARIES/.../classes.jar.
|
2017-03-29 22:53:29 +02:00
|
|
|
# There are some dependencies outside the build system that assume static
|
|
|
|
# java libraries produce javalib.jar, so we will copy classes.jar there too.
|
2010-09-27 23:53:39 +02:00
|
|
|
intermediates.COMMON := $(call local-intermediates-dir,COMMON)
|
2015-02-05 16:10:58 +01:00
|
|
|
common_javalib.jar := $(intermediates.COMMON)/javalib.jar
|
2017-08-22 16:47:08 +02:00
|
|
|
dex_preopt_profile_src_file := $(common_javalib.jar)
|
2010-09-25 03:09:04 +02:00
|
|
|
LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
|
|
|
|
|
2013-03-26 20:42:32 +01:00
|
|
|
ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
|
|
|
|
LOCAL_PROGUARD_ENABLED :=
|
|
|
|
endif
|
|
|
|
|
2012-08-22 01:59:01 +02:00
|
|
|
ifeq (true,$(EMMA_INSTRUMENT))
|
|
|
|
ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
|
|
|
|
ifeq (true,$(EMMA_INSTRUMENT_STATIC))
|
2015-11-19 17:53:00 +01:00
|
|
|
LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
|
2018-01-03 21:39:11 +01:00
|
|
|
# Exclude jacoco classes from proguard
|
|
|
|
LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
|
2012-08-22 01:59:01 +02:00
|
|
|
endif # LOCAL_EMMA_INSTRUMENT
|
|
|
|
endif # EMMA_INSTRUMENT_STATIC
|
|
|
|
else
|
|
|
|
LOCAL_EMMA_INSTRUMENT := false
|
|
|
|
endif # EMMA_INSTRUMENT
|
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
my_dex_jar := $(common_javalib.jar)
|
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
#################################
|
|
|
|
include $(BUILD_SYSTEM)/java.mk
|
|
|
|
#################################
|
|
|
|
|
|
|
|
ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
|
2017-03-29 22:53:29 +02:00
|
|
|
# There are some dependencies outside the build system that assume classes.jar
|
|
|
|
# is available as javalib.jar so copy it there too.
|
2018-07-25 22:41:42 +02:00
|
|
|
$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(common_javalib.jar)))
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2018-07-25 22:41:42 +02:00
|
|
|
$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(LOCAL_BUILT_MODULE)))
|
2010-09-25 03:09:04 +02:00
|
|
|
|
2009-03-04 04:28:42 +01:00
|
|
|
else # !LOCAL_IS_STATIC_JAVA_LIBRARY
|
|
|
|
|
2010-09-25 03:09:04 +02:00
|
|
|
$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
|
2017-04-06 00:30:42 +02:00
|
|
|
$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
|
2018-09-14 22:39:07 +02:00
|
|
|
$(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP)
|
2019-06-12 23:18:31 +02:00
|
|
|
$(common_javalib.jar) : $(full_classes_pre_proguard_jar) $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN)
|
2010-09-18 01:36:06 +02:00
|
|
|
@echo "target Jar: $(PRIVATE_MODULE) ($@)"
|
2018-09-14 22:39:07 +02:00
|
|
|
rm -rf $@.parts && mkdir -p $@.parts
|
|
|
|
$(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
|
|
|
|
$(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
|
|
|
|
$(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip
|
|
|
|
rm -rf $@.parts
|
2017-08-31 23:43:04 +02:00
|
|
|
$(hide) $(ZIPTIME) $@.tmp
|
|
|
|
$(call commit-change-for-toc,$@)
|
2018-01-09 12:46:30 +01:00
|
|
|
ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
|
2017-09-19 14:10:31 +02:00
|
|
|
$(uncompress-dexs)
|
|
|
|
$(align-package)
|
2018-01-09 12:46:30 +01:00
|
|
|
endif # LOCAL_UNCOMPRESS_DEX
|
2017-08-31 23:43:04 +02:00
|
|
|
|
|
|
|
.KATI_RESTAT: $(common_javalib.jar)
|
2010-09-18 01:36:06 +02:00
|
|
|
|
2011-10-24 21:17:03 +02:00
|
|
|
ifdef LOCAL_DEX_PREOPT
|
2010-09-18 01:36:06 +02:00
|
|
|
|
2018-11-17 06:26:33 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
|
|
|
|
$(LOCAL_BUILT_MODULE): $(intermediates)/strip.sh
|
2019-01-18 01:22:04 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): | $(DEXPREOPT_STRIP_DEPS)
|
2018-11-17 06:26:33 +01:00
|
|
|
$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d
|
|
|
|
$(LOCAL_BUILT_MODULE): $(common_javalib.jar)
|
|
|
|
$(PRIVATE_STRIP_SCRIPT) $< $@
|
2010-09-18 01:36:06 +02:00
|
|
|
|
|
|
|
else # LOCAL_DEX_PREOPT
|
2017-03-29 22:53:29 +02:00
|
|
|
$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
|
2009-03-04 04:28:42 +01:00
|
|
|
|
2010-09-25 03:09:04 +02:00
|
|
|
endif # LOCAL_DEX_PREOPT
|
2009-03-04 04:28:42 +01:00
|
|
|
endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
|