blob: 68f93d2ec7242d21f067928c78ffe0103856e9d4 [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.
Brian Carlstrom12cd1f02010-06-22 23:43:20 -070053core_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
Dan Bornstein6ac43c22009-10-24 15:33:49 -070062
63#
64# Build for the target (device).
65#
66
67# Definitions to make the core library.
68
69include $(CLEAR_VARS)
70
71LOCAL_SRC_FILES := $(core_src_files)
72LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
73
74LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstromd0049c52010-06-18 10:59:14 -070075LOCAL_JAVACFLAGS := -encoding UTF-8
Dan Bornstein6ac43c22009-10-24 15:33:49 -070076LOCAL_DX_FLAGS := --core-library
77
78LOCAL_NO_EMMA_INSTRUMENT := true
79LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070080LOCAL_MODULE_TAGS := optional
Dan Bornstein6ac43c22009-10-24 15:33:49 -070081LOCAL_MODULE := core
82
83include $(BUILD_JAVA_LIBRARY)
84
85core-intermediates := ${intermediates}
86
87
Jesse Wilson32cfe952010-05-04 16:36:03 -070088# Make core-junit
89include $(CLEAR_VARS)
90LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
91LOCAL_NO_STANDARD_LIBRARIES := true
92LOCAL_JAVA_LIBRARIES := core
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070093LOCAL_MODULE_TAGS := optional
Jesse Wilson32cfe952010-05-04 16:36:03 -070094LOCAL_MODULE := core-junit
95include $(BUILD_JAVA_LIBRARY)
96
Jesse Wilson1708c112010-05-13 15:50:15 -070097# Make core-junitrunner
98include $(CLEAR_VARS)
99LOCAL_SRC_FILES := $(call all-test-java-files-under,junit)
100LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
101LOCAL_NO_STANDARD_LIBRARIES := true
102LOCAL_JAVA_LIBRARIES := core core-junit
103LOCAL_DX_FLAGS := --core-library
104LOCAL_MODULE_TAGS := tests
105LOCAL_MODULE := core-junitrunner
106include $(BUILD_JAVA_LIBRARY)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800107
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -0800108# Definitions to make the sqlite JDBC driver.
109
110include $(CLEAR_VARS)
111LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc)
112LOCAL_NO_STANDARD_LIBRARIES := true
113LOCAL_JAVA_LIBRARIES := core
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700114LOCAL_MODULE_TAGS := optional
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -0800115LOCAL_MODULE := sqlite-jdbc
116include $(BUILD_JAVA_LIBRARY)
117
Jesse Wilson32cfe952010-05-04 16:36:03 -0700118
Jesse Wilsond5d35262010-05-12 23:56:14 -0700119# Definitions to make the core-tests libraries.
120#
121# We make a library per module, because otherwise the .jar files get too
122# large, to the point that dx(1) can't cope (and the build is
123# ridiculously slow).
124#
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700125# TODO: vogar will make this nonsense obsolete.
126
127include $(CLEAR_VARS)
128LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik)
129LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
130LOCAL_NO_STANDARD_LIBRARIES := true
131LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
132LOCAL_DX_FLAGS := --core-library
133LOCAL_MODULE_TAGS := tests
134LOCAL_MODULE := core-tests-dalvik
135include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700136
137include $(CLEAR_VARS)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700138LOCAL_SRC_FILES := $(call all-test-java-files-under,dom)
139LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
140LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700141LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700142LOCAL_DX_FLAGS := --core-library
143LOCAL_MODULE_TAGS := tests
144LOCAL_MODULE := core-tests-dom
Jesse Wilsond5d35262010-05-12 23:56:14 -0700145include $(BUILD_JAVA_LIBRARY)
146
147include $(CLEAR_VARS)
148LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
149LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
150LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700151LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700152LOCAL_DX_FLAGS := --core-library
153LOCAL_MODULE_TAGS := tests
154LOCAL_MODULE := core-tests-json
Jesse Wilsond5d35262010-05-12 23:56:14 -0700155include $(BUILD_JAVA_LIBRARY)
156
157include $(CLEAR_VARS)
158LOCAL_SRC_FILES := $(call all-test-java-files-under,luni)
159LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
160LOCAL_NO_STANDARD_LIBRARIES := true
161# This module contains the top-level "tests.AllTests" that ties everything
162# together, so it has compile-time dependencies on all the other test
163# libraries.
164# TODO: we should have a bogus module that just contains tests.AllTests for speed.
165LOCAL_JAVA_LIBRARIES := \
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700166 bouncycastle \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700167 core \
168 core-junit \
Jesse Wilson1708c112010-05-13 15:50:15 -0700169 core-junitrunner \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700170 core-tests-support \
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700171 core-tests-dalvik \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800172 core-tests-dom \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800173 core-tests-json \
Peter Hallamcec4dd42010-04-26 12:53:37 -0700174 core-tests-xml \
175 sqlite-jdbc
Jesse Wilsond5d35262010-05-12 23:56:14 -0700176LOCAL_DX_FLAGS := --core-library
177LOCAL_MODULE_TAGS := tests
Brian Carlstromb094af32010-05-28 17:37:37 -0700178LOCAL_MODULE := core-tests
Guang Zhu83244e52010-06-11 18:48:30 -0700179
180LOCAL_NO_EMMA_INSTRUMENT := true
181LOCAL_NO_EMMA_COMPILE := true
182
Jesse Wilsond5d35262010-05-12 23:56:14 -0700183include $(BUILD_JAVA_LIBRARY)
184
185include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800186LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700187LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
188LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700189LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700190LOCAL_DX_FLAGS := --core-library
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700191LOCAL_MODULE_TAGS := tests
Jesse Wilsond5d35262010-05-12 23:56:14 -0700192LOCAL_MODULE := core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700193include $(BUILD_JAVA_LIBRARY)
194
195include $(CLEAR_VARS)
196LOCAL_SRC_FILES := $(call all-test-java-files-under,xml)
197LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
198LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700199LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700200LOCAL_DX_FLAGS := --core-library
201LOCAL_MODULE_TAGS := tests
202LOCAL_MODULE := core-tests-xml
Jesse Wilsond5d35262010-05-12 23:56:14 -0700203include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700204
Jesse Wilson706d5352010-06-08 17:20:09 -0700205# also build support as a static library for use by frameworks/base HTTPS tests
206include $(CLEAR_VARS)
207LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
208LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
209LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700210LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Jesse Wilson706d5352010-06-08 17:20:09 -0700211LOCAL_DX_FLAGS := --core-library
212LOCAL_MODULE_TAGS := tests
213LOCAL_MODULE := core-tests-supportlib
214include $(BUILD_STATIC_JAVA_LIBRARY)
215
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700216# This one's tricky. One of our tests needs to have a
217# resource with a "#" in its name, but Perforce doesn't
218# allow us to submit such a file. So we create it here
219# on-the-fly.
220TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
221TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
222
223$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
224 @mkdir -p $(dir $@)
225 @echo "Hello, world!" > $@
226
227$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
228$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
229
230# Definitions for building a version of the core-tests.jar
231# that is suitable for execution on the RI. This JAR would
232# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
233# not possible to refer to that from a shell script (the
234# variable is not exported from envsetup.sh). There is also
235# some trickery involved: we need to include some classes
236# that reside in core.jar, but since we cannot incldue the
237# whole core.jar in the RI classpath, we copy those classses
238# over to our new file.
239HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
240
241$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
242$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
243$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
244 @rm -rf $(dir $<)/hostctsclasses
245 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
246 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
247 @cp $< $@
248 @jar uf $@ -C $(dir $<)hostctsclasses .
249
250$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
251
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700252
253#
254# Build for the host.
255#
256
257ifeq ($(WITH_HOST_DALVIK),true)
258
259 # Definitions to make the core library.
260
261 include $(CLEAR_VARS)
262
263 LOCAL_SRC_FILES := $(core_src_files)
264 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
265
266 LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson7898a912010-09-13 15:42:41 -0700267 LOCAL_JAVACFLAGS := -encoding UTF-8
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700268 LOCAL_DX_FLAGS := --core-library
269
270 LOCAL_NO_EMMA_INSTRUMENT := true
271 LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson7898a912010-09-13 15:42:41 -0700272 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700273
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700274 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700275 LOCAL_MODULE := core-hostdex
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700276
277 include $(BUILD_HOST_JAVA_LIBRARY)
278
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800279endif