blob: af55897c25a431787f140519b925282882f0787c [file] [log] [blame]
Elliott Hughes7ee3a062010-02-18 17:20:15 -08001# -*- mode: makefile -*-
Dan Bornstein6ac43c22009-10-24 15:33:49 -07002# Copyright (C) 2007 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#
17# Definitions for building the Java library and associated tests.
18#
19
20#
21# Common definitions for host and target.
22#
23
Jesse Wilsond5d35262010-05-12 23:56:14 -070024# libcore is divided into modules.
25#
26# The structure of each module is:
27#
28# src/
29# main/ # To be shipped on every device.
30# java/ # Java source for library code.
31# native/ # C++ source for library code.
32# resources/ # Support files.
33# test/ # Built only on demand, for testing.
34# java/ # Java source for tests.
35# native/ # C++ source for tests (rare).
36# resources/ # Support files.
37#
38# All subdirectories are optional (hence the "2> /dev/null"s below).
Dan Bornstein6ac43c22009-10-24 15:33:49 -070039
Jesse Wilson32cfe952010-05-04 16:36:03 -070040define all-main-java-files-under
41$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/main/java -name "*.java" 2> /dev/null)))
42endef
43
44define all-test-java-files-under
45$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(1)/src/test/java -name "*.java" 2> /dev/null))
Dan Bornstein6ac43c22009-10-24 15:33:49 -070046endef
47
Dan Bornstein6ac43c22009-10-24 15:33:49 -070048define all-core-resource-dirs
49$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
50endef
51
Jesse Wilsond5d35262010-05-12 23:56:14 -070052# The Java files and their associated resources.
Jesse Wilsone590b9c2011-01-13 17:20:50 -080053core_src_files := $(call all-main-java-files-under,dalvik dom json luni support xml)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070054core_resource_dirs := $(call all-core-resource-dirs,main)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070055test_resource_dirs := $(call all-core-resource-dirs,test)
56
Jesse Wilson7898a912010-09-13 15:42:41 -070057ifeq ($(EMMA_INSTRUMENT),true)
58 core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
59 core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res
60endif
61
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080062local_javac_flags=-encoding UTF-8
63#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
64local_javac_flags+=-Xmaxwarns 9999999
Dan Bornstein6ac43c22009-10-24 15:33:49 -070065
66#
67# Build for the target (device).
68#
69
70# Definitions to make the core library.
71
72include $(CLEAR_VARS)
73
74LOCAL_SRC_FILES := $(core_src_files)
75LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
76
77LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080078LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070079LOCAL_DX_FLAGS := --core-library
80
81LOCAL_NO_EMMA_INSTRUMENT := true
82LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070083LOCAL_MODULE_TAGS := optional
Dan Bornstein6ac43c22009-10-24 15:33:49 -070084LOCAL_MODULE := core
85
86include $(BUILD_JAVA_LIBRARY)
87
88core-intermediates := ${intermediates}
89
90
Jesse Wilson32cfe952010-05-04 16:36:03 -070091# Make core-junit
92include $(CLEAR_VARS)
93LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
94LOCAL_NO_STANDARD_LIBRARIES := true
95LOCAL_JAVA_LIBRARIES := core
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070096LOCAL_MODULE_TAGS := optional
Jesse Wilson32cfe952010-05-04 16:36:03 -070097LOCAL_MODULE := core-junit
98include $(BUILD_JAVA_LIBRARY)
99
Jesse Wilson1708c112010-05-13 15:50:15 -0700100# Make core-junitrunner
101include $(CLEAR_VARS)
102LOCAL_SRC_FILES := $(call all-test-java-files-under,junit)
103LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
104LOCAL_NO_STANDARD_LIBRARIES := true
105LOCAL_JAVA_LIBRARIES := core core-junit
106LOCAL_DX_FLAGS := --core-library
107LOCAL_MODULE_TAGS := tests
108LOCAL_MODULE := core-junitrunner
109include $(BUILD_JAVA_LIBRARY)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800110
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -0800111# Definitions to make the sqlite JDBC driver.
112
113include $(CLEAR_VARS)
114LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc)
115LOCAL_NO_STANDARD_LIBRARIES := true
116LOCAL_JAVA_LIBRARIES := core
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700117LOCAL_MODULE_TAGS := optional
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -0800118LOCAL_MODULE := sqlite-jdbc
119include $(BUILD_JAVA_LIBRARY)
120
Jesse Wilson32cfe952010-05-04 16:36:03 -0700121
Jesse Wilsond5d35262010-05-12 23:56:14 -0700122# Definitions to make the core-tests libraries.
123#
124# We make a library per module, because otherwise the .jar files get too
125# large, to the point that dx(1) can't cope (and the build is
126# ridiculously slow).
127#
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700128# TODO: vogar will make this nonsense obsolete.
129
130include $(CLEAR_VARS)
131LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik)
132LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
133LOCAL_NO_STANDARD_LIBRARIES := true
134LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
135LOCAL_DX_FLAGS := --core-library
136LOCAL_MODULE_TAGS := tests
137LOCAL_MODULE := core-tests-dalvik
138include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700139
140include $(CLEAR_VARS)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700141LOCAL_SRC_FILES := $(call all-test-java-files-under,dom)
142LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
143LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700144LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700145LOCAL_DX_FLAGS := --core-library
146LOCAL_MODULE_TAGS := tests
147LOCAL_MODULE := core-tests-dom
Jesse Wilsond5d35262010-05-12 23:56:14 -0700148include $(BUILD_JAVA_LIBRARY)
149
150include $(CLEAR_VARS)
151LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
152LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
153LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700154LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700155LOCAL_DX_FLAGS := --core-library
156LOCAL_MODULE_TAGS := tests
157LOCAL_MODULE := core-tests-json
Jesse Wilsond5d35262010-05-12 23:56:14 -0700158include $(BUILD_JAVA_LIBRARY)
159
160include $(CLEAR_VARS)
161LOCAL_SRC_FILES := $(call all-test-java-files-under,luni)
162LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
163LOCAL_NO_STANDARD_LIBRARIES := true
164# This module contains the top-level "tests.AllTests" that ties everything
165# together, so it has compile-time dependencies on all the other test
166# libraries.
167# TODO: we should have a bogus module that just contains tests.AllTests for speed.
168LOCAL_JAVA_LIBRARIES := \
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700169 bouncycastle \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700170 core \
171 core-junit \
Jesse Wilson1708c112010-05-13 15:50:15 -0700172 core-junitrunner \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700173 core-tests-support \
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700174 core-tests-dalvik \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800175 core-tests-dom \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800176 core-tests-json \
Peter Hallamcec4dd42010-04-26 12:53:37 -0700177 core-tests-xml \
178 sqlite-jdbc
Jesse Wilsond5d35262010-05-12 23:56:14 -0700179LOCAL_DX_FLAGS := --core-library
180LOCAL_MODULE_TAGS := tests
Brian Carlstromb094af32010-05-28 17:37:37 -0700181LOCAL_MODULE := core-tests
Guang Zhu83244e52010-06-11 18:48:30 -0700182
183LOCAL_NO_EMMA_INSTRUMENT := true
184LOCAL_NO_EMMA_COMPILE := true
185
Jesse Wilsond5d35262010-05-12 23:56:14 -0700186include $(BUILD_JAVA_LIBRARY)
187
188include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800189LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700190LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
191LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700192LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700193LOCAL_DX_FLAGS := --core-library
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700194LOCAL_MODULE_TAGS := tests
Jesse Wilsond5d35262010-05-12 23:56:14 -0700195LOCAL_MODULE := core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700196include $(BUILD_JAVA_LIBRARY)
197
198include $(CLEAR_VARS)
199LOCAL_SRC_FILES := $(call all-test-java-files-under,xml)
200LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
201LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700202LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700203LOCAL_DX_FLAGS := --core-library
204LOCAL_MODULE_TAGS := tests
205LOCAL_MODULE := core-tests-xml
Jesse Wilsond5d35262010-05-12 23:56:14 -0700206include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700207
Jesse Wilson706d5352010-06-08 17:20:09 -0700208# also build support as a static library for use by frameworks/base HTTPS tests
209include $(CLEAR_VARS)
210LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
211LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
212LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700213LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Jesse Wilson706d5352010-06-08 17:20:09 -0700214LOCAL_DX_FLAGS := --core-library
215LOCAL_MODULE_TAGS := tests
216LOCAL_MODULE := core-tests-supportlib
217include $(BUILD_STATIC_JAVA_LIBRARY)
218
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700219# This one's tricky. One of our tests needs to have a
220# resource with a "#" in its name, but Perforce doesn't
221# allow us to submit such a file. So we create it here
222# on-the-fly.
223TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
224TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
225
226$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
227 @mkdir -p $(dir $@)
228 @echo "Hello, world!" > $@
229
230$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
231$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
232
233# Definitions for building a version of the core-tests.jar
234# that is suitable for execution on the RI. This JAR would
235# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
236# not possible to refer to that from a shell script (the
237# variable is not exported from envsetup.sh). There is also
238# some trickery involved: we need to include some classes
239# that reside in core.jar, but since we cannot incldue the
240# whole core.jar in the RI classpath, we copy those classses
241# over to our new file.
242HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
243
244$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
245$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
246$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
247 @rm -rf $(dir $<)/hostctsclasses
248 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
249 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
250 @cp $< $@
251 @jar uf $@ -C $(dir $<)hostctsclasses .
252
253$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
254
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700255
256#
257# Build for the host.
258#
259
260ifeq ($(WITH_HOST_DALVIK),true)
261
262 # Definitions to make the core library.
263
264 include $(CLEAR_VARS)
265
266 LOCAL_SRC_FILES := $(core_src_files)
267 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
268
269 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800270 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700271 LOCAL_DX_FLAGS := --core-library
272
273 LOCAL_NO_EMMA_INSTRUMENT := true
274 LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson7898a912010-09-13 15:42:41 -0700275 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700276
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700277 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700278 LOCAL_MODULE := core-hostdex
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700279
280 include $(BUILD_HOST_JAVA_LIBRARY)
281
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800282endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800283
284#
285# Local droiddoc for faster libcore testing
286#
287#
288# Run with:
289# m libcore-docs
290#
291# Main output:
292# out/target/common/docs/libcore/reference/packages.html
293#
294# All text for proofreading (or running tools over):
295# out/target/common/docs/libcore-proofread.txt
296#
297# TODO list of missing javadoc, etc:
298# out/target/common/docs/libcore-docs-todo.html
299#
300# Rerun:
301# rm -rf out/target/common/docs/libcore-timestamp && m libcore-docs
302#
303include $(CLEAR_VARS)
304
305# for shared defintion of libcore_to_document
306include $(LOCAL_PATH)/Docs.mk
307
308LOCAL_SRC_FILES:=$(call find-other-java-files, $(libcore_to_document))
309# rerun doc generation without recompiling the java
310LOCAL_JAVA_LIBRARIES:=
311LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
312
313LOCAL_MODULE := libcore
314
315LOCAL_DROIDDOC_OPTIONS:= \
316 -offlinemode \
317 -title "libcore" \
318 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
319 -todo ../$(LOCAL_MODULE)-docs-todo.html \
320 -hdf android.whichdoc offline
321
322LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
323
324include $(BUILD_DROIDDOC)