• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
47endif # LOCAL_EMMA_INSTRUMENT
48endif # EMMA_INSTRUMENT_STATIC
49else
50LOCAL_EMMA_INSTRUMENT := false
51endif # EMMA_INSTRUMENT
52
53my_dex_jar := $(common_javalib.jar)
54
55#################################
56include $(BUILD_SYSTEM)/java.mk
57#################################
58
59ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
60# There are some dependencies outside the build system that assume classes.jar
61# is available as javalib.jar so copy it there too.
62$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(common_javalib.jar)))
63
64$(eval $(call copy-one-file,$(full_classes_pre_proguard_jar),$(LOCAL_BUILT_MODULE)))
65
66else # !LOCAL_IS_STATIC_JAVA_LIBRARY
67
68$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
69$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_pre_proguard_jar)
70$(common_javalib.jar): $(MERGE_ZIPS) $(SOONG_ZIP) $(ZIP2ZIP)
71$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME) $(ZIPALIGN)
72	@echo "target Jar: $(PRIVATE_MODULE) ($@)"
73	rm -rf $@.parts && mkdir -p $@.parts
74	$(call create-dex-jar,$@.parts/dex.zip,$(PRIVATE_DEX_FILE))
75	$(call extract-resources-jar,$@.parts/res.zip,$(PRIVATE_SOURCE_ARCHIVE))
76	$(MERGE_ZIPS) -j $@.tmp $@.parts/dex.zip $@.parts/res.zip
77	rm -rf $@.parts
78	$(hide) $(ZIPTIME) $@.tmp
79	$(call commit-change-for-toc,$@)
80ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
81	$(uncompress-dexs)
82	$(align-package)
83endif  # LOCAL_UNCOMPRESS_DEX
84
85.KATI_RESTAT: $(common_javalib.jar)
86
87ifdef LOCAL_DEX_PREOPT
88
89$(LOCAL_BUILT_MODULE): PRIVATE_STRIP_SCRIPT := $(intermediates)/strip.sh
90$(LOCAL_BUILT_MODULE): $(intermediates)/strip.sh
91$(LOCAL_BUILT_MODULE): | $(DEXPREOPT_STRIP_DEPS)
92$(LOCAL_BUILT_MODULE): .KATI_DEPFILE := $(LOCAL_BUILT_MODULE).d
93$(LOCAL_BUILT_MODULE): $(common_javalib.jar)
94	$(PRIVATE_STRIP_SCRIPT) $< $@
95
96else # LOCAL_DEX_PREOPT
97$(eval $(call copy-one-file,$(common_javalib.jar),$(LOCAL_BUILT_MODULE)))
98
99endif # LOCAL_DEX_PREOPT
100endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
101