• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2013 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16$(call record-module-type,HOST_DALVIK_JAVA_LIBRARY)
17
18#
19# Rules for building a host dalvik java library. These libraries
20# are meant to be used by a dalvik VM instance running on the host.
21# They will be compiled against libcore and not the host JRE.
22#
23
24ifeq ($(HOST_OS),linux)
25USE_CORE_LIB_BOOTCLASSPATH := true
26
27#################################
28include $(BUILD_SYSTEM)/configure_local_jack.mk
29#################################
30
31#######################################
32include $(BUILD_SYSTEM)/host_java_library_common.mk
33#######################################
34ifdef LOCAL_JACK_ENABLED
35ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
36  # For static library, $(LOCAL_BUILT_MODULE) is $(full_classes_jack).
37  LOCAL_BUILT_MODULE_STEM := classes.jack
38endif
39endif
40
41ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
42  LOCAL_JAVA_LIBRARIES :=  core-oj-hostdex core-libart-hostdex $(LOCAL_JAVA_LIBRARIES)
43endif
44
45full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
46full_classes_desugar_jar := $(intermediates.COMMON)/desugar.classes.jar
47full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
48full_classes_jar := $(intermediates.COMMON)/classes.jar
49full_classes_jack := $(intermediates.COMMON)/classes.jack
50jack_check_timestamp := $(intermediates.COMMON)/jack.check.timestamp
51built_dex := $(intermediates.COMMON)/classes.dex
52
53LOCAL_INTERMEDIATE_TARGETS += \
54    $(full_classes_compiled_jar) \
55    $(full_classes_desugar_jar) \
56    $(full_classes_jarjar_jar) \
57    $(full_classes_jack) \
58    $(full_classes_jar) \
59    $(jack_check_timestamp) \
60    $(built_dex)
61
62# See comment in java.mk
63ifndef LOCAL_CHECKED_MODULE
64ifdef LOCAL_JACK_ENABLED
65LOCAL_CHECKED_MODULE := $(jack_check_timestamp)
66else
67ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
68LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
69else
70LOCAL_CHECKED_MODULE := $(built_dex)
71endif
72endif
73endif
74
75#######################################
76include $(BUILD_SYSTEM)/base_rules.mk
77#######################################
78java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \
79                $(filter %.java,$(LOCAL_GENERATED_SOURCES))
80all_java_sources := $(java_sources)
81
82include $(BUILD_SYSTEM)/java_common.mk
83
84$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
85
86ifndef LOCAL_JACK_ENABLED
87
88$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
89$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
90$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
91$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
92$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
93$(full_classes_compiled_jar): \
94        $(java_sources) \
95        $(java_resource_sources) \
96        $(full_java_lib_deps) \
97        $(jar_manifest_file) \
98        $(proto_java_sources_file_stamp) \
99        $(LOCAL_ADDITIONAL_DEPENDENCIES)
100	$(transform-host-java-to-package)
101
102my_desugaring :=
103ifeq ($(LOCAL_JAVA_LANGUAGE_VERSION),1.8)
104my_desugaring := true
105$(full_classes_desugar_jar): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
106$(full_classes_desugar_jar): $(full_classes_compiled_jar) $(DESUGAR)
107	$(desugar-classes-jar)
108endif
109
110ifndef my_desugaring
111full_classes_desugar_jar := $(full_classes_compiled_jar)
112endif
113
114# Run jarjar if necessary, otherwise just copy the file.
115ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
116$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
117$(full_classes_jarjar_jar): $(full_classes_desugar_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
118	@echo JarJar: $@
119	$(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
120else
121full_classes_jarjar_jar := $(full_classes_desugar_jar)
122endif
123
124$(eval $(call copy-one-file,$(full_classes_jarjar_jar),$(full_classes_jar)))
125
126ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
127# No dex; all we want are the .class files with resources.
128$(LOCAL_BUILT_MODULE) : $(java_resource_sources)
129$(LOCAL_BUILT_MODULE) : $(full_classes_jar)
130	@echo "host Static Jar: $(PRIVATE_MODULE) ($@)"
131	$(copy-file-to-target)
132
133else # !LOCAL_IS_STATIC_JAVA_LIBRARY
134$(built_dex): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
135$(built_dex): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
136$(built_dex): $(full_classes_jar) $(DX)
137	$(transform-classes.jar-to-dex)
138
139$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
140$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
141$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
142$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
143	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
144	$(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
145	$(add-dex-to-package)
146
147endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
148
149ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
150$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
151$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(LOCAL_SDK_VERSION)
152else
153$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
154$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SDK_VERSION := $(PLATFORM_SDK_VERSION)
155endif
156
157else # LOCAL_JACK_ENABLED
158$(LOCAL_INTERMEDIATE_TARGETS): \
159  PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
160
161ifeq ($(LOCAL_JACK_ENABLED),incremental)
162$(LOCAL_INTERMEDIATE_TARGETS): \
163  PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
164else
165$(LOCAL_INTERMEDIATE_TARGETS): \
166  PRIVATE_JACK_INCREMENTAL_DIR :=
167endif
168$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
169$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
170$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_MIN_SDK_VERSION := $(PLATFORM_JACK_MIN_SDK_VERSION)
171
172jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
173        $(jar_manifest_file) $(proto_java_sources_file_stamp) \
174        $(LOCAL_ADDITIONAL_DEPENDENCIES) $(NORMALIZE_PATH) $(JACK_DEFAULT_ARGS) $(JACK)
175
176ifneq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
177$(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack)
178$(built_dex): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
179$(built_dex): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
180$(built_dex): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
181	@echo Building with Jack: $@
182	$(jack-java-to-dex)
183
184# $(full_classes_jack) is just by-product of $(built_dex).
185# The dummy command was added because, without it, make misses the fact the $(built_dex) also
186# change $(full_classes_jack).
187$(full_classes_jack): $(built_dex)
188	$(hide) touch $@
189
190$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
191$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
192	@echo "Host Jar: $(PRIVATE_MODULE) ($@)"
193	$(create-empty-package)
194	$(add-dex-to-package)
195	$(add-carried-jack-resources)
196
197else  # LOCAL_IS_STATIC_JAVA_LIBRARY
198$(full_classes_jack): PRIVATE_JACK_PLUGIN_PATH := $(LOCAL_JACK_PLUGIN_PATH)
199$(full_classes_jack): PRIVATE_JACK_PLUGIN := $(LOCAL_JACK_PLUGIN)
200$(full_classes_jack): $(jack_all_deps) $(LOCAL_JACK_PLUGIN_PATH) | setup-jack-server
201	@echo Building with Jack: $@
202	$(java-to-jack)
203
204endif  # LOCAL_IS_STATIC_JAVA_LIBRARY
205
206$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
207	@echo Checking build with Jack: $@
208	$(jack-check-java)
209endif # LOCAL_JACK_ENABLED
210
211USE_CORE_LIB_BOOTCLASSPATH :=
212
213endif
214