blob: c49d5298d04d8c658f268a57af86e0c38f737571 [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
Jesse Wilsond5d35262010-05-12 23:56:14 -0700111# Definitions to make the core-tests libraries.
112#
113# We make a library per module, because otherwise the .jar files get too
114# large, to the point that dx(1) can't cope (and the build is
115# ridiculously slow).
116#
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700117# TODO: vogar will make this nonsense obsolete.
118
119include $(CLEAR_VARS)
120LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik)
121LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
122LOCAL_NO_STANDARD_LIBRARIES := true
123LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
124LOCAL_DX_FLAGS := --core-library
125LOCAL_MODULE_TAGS := tests
126LOCAL_MODULE := core-tests-dalvik
127include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700128
129include $(CLEAR_VARS)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700130LOCAL_SRC_FILES := $(call all-test-java-files-under,dom)
131LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
132LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700133LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700134LOCAL_DX_FLAGS := --core-library
135LOCAL_MODULE_TAGS := tests
136LOCAL_MODULE := core-tests-dom
Jesse Wilsond5d35262010-05-12 23:56:14 -0700137include $(BUILD_JAVA_LIBRARY)
138
139include $(CLEAR_VARS)
140LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
141LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
142LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700143LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700144LOCAL_DX_FLAGS := --core-library
145LOCAL_MODULE_TAGS := tests
146LOCAL_MODULE := core-tests-json
Jesse Wilsond5d35262010-05-12 23:56:14 -0700147include $(BUILD_JAVA_LIBRARY)
148
149include $(CLEAR_VARS)
150LOCAL_SRC_FILES := $(call all-test-java-files-under,luni)
151LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
152LOCAL_NO_STANDARD_LIBRARIES := true
153# This module contains the top-level "tests.AllTests" that ties everything
154# together, so it has compile-time dependencies on all the other test
155# libraries.
156# TODO: we should have a bogus module that just contains tests.AllTests for speed.
157LOCAL_JAVA_LIBRARIES := \
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700158 bouncycastle \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700159 core \
160 core-junit \
Jesse Wilson1708c112010-05-13 15:50:15 -0700161 core-junitrunner \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700162 core-tests-support \
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700163 core-tests-dalvik \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800164 core-tests-dom \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800165 core-tests-json \
Peter Hallamcec4dd42010-04-26 12:53:37 -0700166 core-tests-xml \
167 sqlite-jdbc
Jesse Wilsond5d35262010-05-12 23:56:14 -0700168LOCAL_DX_FLAGS := --core-library
169LOCAL_MODULE_TAGS := tests
Brian Carlstromb094af32010-05-28 17:37:37 -0700170LOCAL_MODULE := core-tests
Guang Zhu83244e52010-06-11 18:48:30 -0700171
172LOCAL_NO_EMMA_INSTRUMENT := true
173LOCAL_NO_EMMA_COMPILE := true
174
Jesse Wilsond5d35262010-05-12 23:56:14 -0700175include $(BUILD_JAVA_LIBRARY)
176
177include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800178LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700179LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
180LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700181LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700182LOCAL_DX_FLAGS := --core-library
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700183LOCAL_MODULE_TAGS := tests
Jesse Wilsond5d35262010-05-12 23:56:14 -0700184LOCAL_MODULE := core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700185include $(BUILD_JAVA_LIBRARY)
186
187include $(CLEAR_VARS)
188LOCAL_SRC_FILES := $(call all-test-java-files-under,xml)
189LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
190LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700191LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700192LOCAL_DX_FLAGS := --core-library
193LOCAL_MODULE_TAGS := tests
194LOCAL_MODULE := core-tests-xml
Jesse Wilsond5d35262010-05-12 23:56:14 -0700195include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700196
Jesse Wilson706d5352010-06-08 17:20:09 -0700197# also build support as a static library for use by frameworks/base HTTPS tests
198include $(CLEAR_VARS)
199LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
200LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
201LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700202LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Jesse Wilson706d5352010-06-08 17:20:09 -0700203LOCAL_DX_FLAGS := --core-library
204LOCAL_MODULE_TAGS := tests
205LOCAL_MODULE := core-tests-supportlib
206include $(BUILD_STATIC_JAVA_LIBRARY)
207
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700208# This one's tricky. One of our tests needs to have a
209# resource with a "#" in its name, but Perforce doesn't
210# allow us to submit such a file. So we create it here
211# on-the-fly.
212TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
213TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
214
215$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
216 @mkdir -p $(dir $@)
217 @echo "Hello, world!" > $@
218
219$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
220$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
221
222# Definitions for building a version of the core-tests.jar
223# that is suitable for execution on the RI. This JAR would
224# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
225# not possible to refer to that from a shell script (the
226# variable is not exported from envsetup.sh). There is also
227# some trickery involved: we need to include some classes
228# that reside in core.jar, but since we cannot incldue the
229# whole core.jar in the RI classpath, we copy those classses
230# over to our new file.
231HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
232
233$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
234$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
235$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
236 @rm -rf $(dir $<)/hostctsclasses
237 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
238 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
239 @cp $< $@
240 @jar uf $@ -C $(dir $<)hostctsclasses .
241
242$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
243
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700244
245#
246# Build for the host.
247#
248
249ifeq ($(WITH_HOST_DALVIK),true)
250
251 # Definitions to make the core library.
252
253 include $(CLEAR_VARS)
254
255 LOCAL_SRC_FILES := $(core_src_files)
256 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
257
258 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800259 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700260 LOCAL_DX_FLAGS := --core-library
261
262 LOCAL_NO_EMMA_INSTRUMENT := true
263 LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson7898a912010-09-13 15:42:41 -0700264 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700265
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700266 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700267 LOCAL_MODULE := core-hostdex
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700268
269 include $(BUILD_HOST_JAVA_LIBRARY)
270
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800271endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800272
273#
274# Local droiddoc for faster libcore testing
275#
276#
277# Run with:
278# m libcore-docs
279#
280# Main output:
281# out/target/common/docs/libcore/reference/packages.html
282#
283# All text for proofreading (or running tools over):
284# out/target/common/docs/libcore-proofread.txt
285#
286# TODO list of missing javadoc, etc:
287# out/target/common/docs/libcore-docs-todo.html
288#
289# Rerun:
290# rm -rf out/target/common/docs/libcore-timestamp && m libcore-docs
291#
292include $(CLEAR_VARS)
293
294# for shared defintion of libcore_to_document
295include $(LOCAL_PATH)/Docs.mk
296
297LOCAL_SRC_FILES:=$(call find-other-java-files, $(libcore_to_document))
298# rerun doc generation without recompiling the java
299LOCAL_JAVA_LIBRARIES:=
300LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
301
302LOCAL_MODULE := libcore
303
304LOCAL_DROIDDOC_OPTIONS:= \
305 -offlinemode \
306 -title "libcore" \
307 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
308 -todo ../$(LOCAL_MODULE)-docs-todo.html \
309 -hdf android.whichdoc offline
310
311LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
312
313include $(BUILD_DROIDDOC)