• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
27#################################
28include $(BUILD_SYSTEM)/configure_local_jack.mk
29#################################
30
31ifdef LOCAL_JACK_ENABLED
32ifdef LOCAL_IS_STATIC_JAVA_LIBRARY
33LOCAL_BUILT_MODULE_STEM := classes.jack
34endif
35endif
36
37intermediates.COMMON := $(call local-intermediates-dir,COMMON)
38
39# This file will be the one that other modules should depend on.
40common_javalib.jar := $(intermediates.COMMON)/javalib.jar
41LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
42
43ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
44  LOCAL_PROGUARD_ENABLED :=
45endif
46
47ifeq (true,$(EMMA_INSTRUMENT))
48ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
49ifeq (true,$(EMMA_INSTRUMENT_STATIC))
50LOCAL_STATIC_JAVA_LIBRARIES += emma
51endif # LOCAL_EMMA_INSTRUMENT
52endif # EMMA_INSTRUMENT_STATIC
53else
54LOCAL_EMMA_INSTRUMENT := false
55endif # EMMA_INSTRUMENT
56
57#################################
58include $(BUILD_SYSTEM)/java.mk
59#################################
60
61ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
62# No dex; all we want are the .class files with resources.
63$(common_javalib.jar) : $(java_resource_sources)
64ifdef LOCAL_PROGUARD_ENABLED
65$(common_javalib.jar) : $(full_classes_proguard_jar)
66else
67$(common_javalib.jar) : $(full_classes_jar)
68endif
69	@echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
70	$(copy-file-to-target)
71
72ifdef LOCAL_JACK_ENABLED
73$(LOCAL_BUILT_MODULE) : $(full_classes_jack)
74else
75$(LOCAL_BUILT_MODULE) : $(common_javalib.jar)
76endif
77	$(copy-file-to-target)
78
79else # !LOCAL_IS_STATIC_JAVA_LIBRARY
80
81$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
82$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
83$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
84$(common_javalib.jar) : $(built_dex) $(java_resource_sources)
85	@echo "target Jar: $(PRIVATE_MODULE) ($@)"
86ifdef LOCAL_JACK_ENABLED
87	$(create-empty-package)
88else
89	$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
90endif
91	$(add-dex-to-package)
92ifdef LOCAL_JACK_ENABLED
93	$(add-carried-jack-resources)
94endif
95
96ifdef LOCAL_DEX_PREOPT
97ifneq ($(dexpreopt_boot_jar_module),) # boot jar
98# boot jar's rules are defined in dex_preopt.mk
99dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
100$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP)
101	$(call copy-file-to-target)
102
103# For libart boot jars, we don't have .odex files.
104else # ! boot jar
105$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
106# Use pattern rule - we may have multiple built odex files.
107$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar)
108	@echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
109	$(call dexpreopt-one-file,$<,$@)
110
111$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
112	$(call copy-file-to-target)
113ifneq (nostripping,$(LOCAL_DEX_PREOPT))
114	$(call dexpreopt-remove-classes.dex,$@)
115endif
116
117endif # ! boot jar
118
119else # LOCAL_DEX_PREOPT
120$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
121	$(call copy-file-to-target)
122
123endif # LOCAL_DEX_PREOPT
124endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
125