blob: a731aee2d9281303f6769f95d29cc1355d5b1a44 [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
57
58#
59# Build for the target (device).
60#
61
62# Definitions to make the core library.
63
64include $(CLEAR_VARS)
65
66LOCAL_SRC_FILES := $(core_src_files)
67LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
68
Guang Zhu709c24d2010-03-10 15:51:58 -080069ifeq ($(EMMA_INSTRUMENT),true)
Guang Zhu83244e52010-06-11 18:48:30 -070070LOCAL_SRC_FILES += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
71LOCAL_JAVA_RESOURCE_DIRS += ../external/emma/core/res ../external/emma/pregenerated/res
Guang Zhu709c24d2010-03-10 15:51:58 -080072endif
73
Dan Bornstein6ac43c22009-10-24 15:33:49 -070074LOCAL_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
80
81LOCAL_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
93LOCAL_MODULE := core-junit
94include $(BUILD_JAVA_LIBRARY)
95
Jesse Wilson1708c112010-05-13 15:50:15 -070096# Make core-junitrunner
97include $(CLEAR_VARS)
98LOCAL_SRC_FILES := $(call all-test-java-files-under,junit)
99LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
100LOCAL_NO_STANDARD_LIBRARIES := true
101LOCAL_JAVA_LIBRARIES := core core-junit
102LOCAL_DX_FLAGS := --core-library
103LOCAL_MODULE_TAGS := tests
104LOCAL_MODULE := core-junitrunner
105include $(BUILD_JAVA_LIBRARY)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800106
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -0800107# Definitions to make the sqlite JDBC driver.
108
109include $(CLEAR_VARS)
110LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc)
111LOCAL_NO_STANDARD_LIBRARIES := true
112LOCAL_JAVA_LIBRARIES := core
113LOCAL_MODULE := sqlite-jdbc
114include $(BUILD_JAVA_LIBRARY)
115
Jesse Wilson32cfe952010-05-04 16:36:03 -0700116
Jesse Wilsond5d35262010-05-12 23:56:14 -0700117# Definitions to make the core-tests libraries.
118#
119# We make a library per module, because otherwise the .jar files get too
120# large, to the point that dx(1) can't cope (and the build is
121# ridiculously slow).
122#
123# TODO: DalvikRunner will make this nonsense obsolete.
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700124
125include $(CLEAR_VARS)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700126LOCAL_SRC_FILES := $(call all-test-java-files-under,dom)
127LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
128LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700129LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700130LOCAL_DX_FLAGS := --core-library
131LOCAL_MODULE_TAGS := tests
132LOCAL_MODULE := core-tests-dom
Jesse Wilsond5d35262010-05-12 23:56:14 -0700133include $(BUILD_JAVA_LIBRARY)
134
135include $(CLEAR_VARS)
136LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
137LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
138LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700139LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700140LOCAL_DX_FLAGS := --core-library
141LOCAL_MODULE_TAGS := tests
142LOCAL_MODULE := core-tests-json
Jesse Wilsond5d35262010-05-12 23:56:14 -0700143include $(BUILD_JAVA_LIBRARY)
144
145include $(CLEAR_VARS)
146LOCAL_SRC_FILES := $(call all-test-java-files-under,luni)
147LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
148LOCAL_NO_STANDARD_LIBRARIES := true
149# This module contains the top-level "tests.AllTests" that ties everything
150# together, so it has compile-time dependencies on all the other test
151# libraries.
152# TODO: we should have a bogus module that just contains tests.AllTests for speed.
153LOCAL_JAVA_LIBRARIES := \
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700154 bouncycastle \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700155 core \
156 core-junit \
Jesse Wilson1708c112010-05-13 15:50:15 -0700157 core-junitrunner \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700158 core-tests-support \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800159 core-tests-dom \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800160 core-tests-json \
Peter Hallamcec4dd42010-04-26 12:53:37 -0700161 core-tests-xml \
162 sqlite-jdbc
Jesse Wilsond5d35262010-05-12 23:56:14 -0700163LOCAL_DX_FLAGS := --core-library
164LOCAL_MODULE_TAGS := tests
Brian Carlstromb094af32010-05-28 17:37:37 -0700165LOCAL_MODULE := core-tests
Guang Zhu83244e52010-06-11 18:48:30 -0700166
167LOCAL_NO_EMMA_INSTRUMENT := true
168LOCAL_NO_EMMA_COMPILE := true
169
Jesse Wilsond5d35262010-05-12 23:56:14 -0700170include $(BUILD_JAVA_LIBRARY)
171
172include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800173LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700174LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
175LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700176LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700177LOCAL_DX_FLAGS := --core-library
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700178LOCAL_MODULE_TAGS := tests
Jesse Wilsond5d35262010-05-12 23:56:14 -0700179LOCAL_MODULE := core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700180include $(BUILD_JAVA_LIBRARY)
181
182include $(CLEAR_VARS)
183LOCAL_SRC_FILES := $(call all-test-java-files-under,xml)
184LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
185LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700186LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700187LOCAL_DX_FLAGS := --core-library
188LOCAL_MODULE_TAGS := tests
189LOCAL_MODULE := core-tests-xml
Jesse Wilsond5d35262010-05-12 23:56:14 -0700190include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700191
Jesse Wilson706d5352010-06-08 17:20:09 -0700192# also build support as a static library for use by frameworks/base HTTPS tests
193include $(CLEAR_VARS)
194LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
195LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
196LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom12cd1f02010-06-22 23:43:20 -0700197LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner
Jesse Wilson706d5352010-06-08 17:20:09 -0700198LOCAL_DX_FLAGS := --core-library
199LOCAL_MODULE_TAGS := tests
200LOCAL_MODULE := core-tests-supportlib
201include $(BUILD_STATIC_JAVA_LIBRARY)
202
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700203# This one's tricky. One of our tests needs to have a
204# resource with a "#" in its name, but Perforce doesn't
205# allow us to submit such a file. So we create it here
206# on-the-fly.
207TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
208TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
209
210$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
211 @mkdir -p $(dir $@)
212 @echo "Hello, world!" > $@
213
214$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
215$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
216
217# Definitions for building a version of the core-tests.jar
218# that is suitable for execution on the RI. This JAR would
219# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
220# not possible to refer to that from a shell script (the
221# variable is not exported from envsetup.sh). There is also
222# some trickery involved: we need to include some classes
223# that reside in core.jar, but since we cannot incldue the
224# whole core.jar in the RI classpath, we copy those classses
225# over to our new file.
226HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
227
228$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
229$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
230$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
231 @rm -rf $(dir $<)/hostctsclasses
232 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
233 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
234 @cp $< $@
235 @jar uf $@ -C $(dir $<)hostctsclasses .
236
237$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
238
239$(LOCAL_INSTALLED_MODULE): run-core-tests
240
241# Definitions to copy the core-tests runner script.
242
243include $(CLEAR_VARS)
244LOCAL_SRC_FILES := run-core-tests
245LOCAL_MODULE_CLASS := EXECUTABLES
246LOCAL_MODULE_TAGS := tests
247LOCAL_MODULE := run-core-tests
248include $(BUILD_PREBUILT)
249
250include $(CLEAR_VARS)
251LOCAL_SRC_FILES := run-core-tests-on-ri
252LOCAL_IS_HOST_MODULE := true
253LOCAL_MODULE_CLASS := EXECUTABLES
254LOCAL_MODULE_TAGS := tests
255LOCAL_MODULE := run-core-tests-on-ri
256include $(BUILD_PREBUILT)
257
258
259#
260# Build for the host.
261#
262
263ifeq ($(WITH_HOST_DALVIK),true)
264
265 # Definitions to make the core library.
266
267 include $(CLEAR_VARS)
268
269 LOCAL_SRC_FILES := $(core_src_files)
270 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
271
272 LOCAL_NO_STANDARD_LIBRARIES := true
273 LOCAL_DX_FLAGS := --core-library
274
275 LOCAL_NO_EMMA_INSTRUMENT := true
276 LOCAL_NO_EMMA_COMPILE := true
277
278 LOCAL_MODULE := core
279
280 include $(BUILD_HOST_JAVA_LIBRARY)
281
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800282endif