blob: a51f2332ed2e2f84c06748412fdaffdb5f93ff65 [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 Wilson1708c112010-05-13 15:50:15 -070053core_src_files := $(call all-main-java-files-under,dalvik dom json luni openssl 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)
70LOCAL_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
72endif
73
Dan Bornstein6ac43c22009-10-24 15:33:49 -070074LOCAL_NO_STANDARD_LIBRARIES := true
75LOCAL_DX_FLAGS := --core-library
76
77LOCAL_NO_EMMA_INSTRUMENT := true
78LOCAL_NO_EMMA_COMPILE := true
79
80LOCAL_MODULE := core
81
82include $(BUILD_JAVA_LIBRARY)
83
84core-intermediates := ${intermediates}
85
86
Jesse Wilson32cfe952010-05-04 16:36:03 -070087# Make core-junit
88include $(CLEAR_VARS)
89LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
90LOCAL_NO_STANDARD_LIBRARIES := true
91LOCAL_JAVA_LIBRARIES := core
92LOCAL_MODULE := core-junit
93include $(BUILD_JAVA_LIBRARY)
94
Jesse Wilson1708c112010-05-13 15:50:15 -070095# Make core-junitrunner
96include $(CLEAR_VARS)
97LOCAL_SRC_FILES := $(call all-test-java-files-under,junit)
98LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
99LOCAL_NO_STANDARD_LIBRARIES := true
100LOCAL_JAVA_LIBRARIES := core core-junit
101LOCAL_DX_FLAGS := --core-library
102LOCAL_MODULE_TAGS := tests
103LOCAL_MODULE := core-junitrunner
104include $(BUILD_JAVA_LIBRARY)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800105
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -0800106# Definitions to make the sqlite JDBC driver.
107
108include $(CLEAR_VARS)
109LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc)
110LOCAL_NO_STANDARD_LIBRARIES := true
111LOCAL_JAVA_LIBRARIES := core
112LOCAL_MODULE := sqlite-jdbc
113include $(BUILD_JAVA_LIBRARY)
114
Jesse Wilson32cfe952010-05-04 16:36:03 -0700115
Jesse Wilsond5d35262010-05-12 23:56:14 -0700116# Definitions to make the core-tests libraries.
117#
118# We make a library per module, because otherwise the .jar files get too
119# large, to the point that dx(1) can't cope (and the build is
120# ridiculously slow).
121#
122# TODO: DalvikRunner will make this nonsense obsolete.
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700123
124include $(CLEAR_VARS)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700125LOCAL_SRC_FILES := $(call all-test-java-files-under,dom)
126LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
127LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700128LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700129LOCAL_DX_FLAGS := --core-library
130LOCAL_MODULE_TAGS := tests
131LOCAL_MODULE := core-tests-dom
Jesse Wilsond5d35262010-05-12 23:56:14 -0700132include $(BUILD_JAVA_LIBRARY)
133
134include $(CLEAR_VARS)
135LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
136LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
137LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700138LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700139LOCAL_DX_FLAGS := --core-library
140LOCAL_MODULE_TAGS := tests
141LOCAL_MODULE := core-tests-json
Jesse Wilsond5d35262010-05-12 23:56:14 -0700142include $(BUILD_JAVA_LIBRARY)
143
144include $(CLEAR_VARS)
145LOCAL_SRC_FILES := $(call all-test-java-files-under,luni)
146LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
147LOCAL_NO_STANDARD_LIBRARIES := true
148# This module contains the top-level "tests.AllTests" that ties everything
149# together, so it has compile-time dependencies on all the other test
150# libraries.
151# TODO: we should have a bogus module that just contains tests.AllTests for speed.
152LOCAL_JAVA_LIBRARIES := \
153 core \
154 core-junit \
Jesse Wilson1708c112010-05-13 15:50:15 -0700155 core-junitrunner \
Jesse Wilsond5d35262010-05-12 23:56:14 -0700156 core-tests-support \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800157 core-tests-dom \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800158 core-tests-json \
Peter Hallamcec4dd42010-04-26 12:53:37 -0700159 core-tests-xml \
160 sqlite-jdbc
Jesse Wilsond5d35262010-05-12 23:56:14 -0700161LOCAL_DX_FLAGS := --core-library
162LOCAL_MODULE_TAGS := tests
Brian Carlstromb094af32010-05-28 17:37:37 -0700163LOCAL_MODULE := core-tests
Jesse Wilsond5d35262010-05-12 23:56:14 -0700164include $(BUILD_JAVA_LIBRARY)
165
166include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800167LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700168LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
169LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700170LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700171LOCAL_DX_FLAGS := --core-library
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700172LOCAL_MODULE_TAGS := tests
Jesse Wilsond5d35262010-05-12 23:56:14 -0700173LOCAL_MODULE := core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700174include $(BUILD_JAVA_LIBRARY)
175
176include $(CLEAR_VARS)
177LOCAL_SRC_FILES := $(call all-test-java-files-under,xml)
178LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
179LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson1708c112010-05-13 15:50:15 -0700180LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner core-tests-support
Jesse Wilsond5d35262010-05-12 23:56:14 -0700181LOCAL_DX_FLAGS := --core-library
182LOCAL_MODULE_TAGS := tests
183LOCAL_MODULE := core-tests-xml
Jesse Wilsond5d35262010-05-12 23:56:14 -0700184include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700185
Jesse Wilson706d5352010-06-08 17:20:09 -0700186# also build support as a static library for use by frameworks/base HTTPS tests
187include $(CLEAR_VARS)
188LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
189LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
190LOCAL_NO_STANDARD_LIBRARIES := true
191LOCAL_JAVA_LIBRARIES := core core-junit core-junitrunner
192LOCAL_DX_FLAGS := --core-library
193LOCAL_MODULE_TAGS := tests
194LOCAL_MODULE := core-tests-supportlib
195include $(BUILD_STATIC_JAVA_LIBRARY)
196
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700197# This one's tricky. One of our tests needs to have a
198# resource with a "#" in its name, but Perforce doesn't
199# allow us to submit such a file. So we create it here
200# on-the-fly.
201TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
202TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
203
204$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
205 @mkdir -p $(dir $@)
206 @echo "Hello, world!" > $@
207
208$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
209$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
210
211# Definitions for building a version of the core-tests.jar
212# that is suitable for execution on the RI. This JAR would
213# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
214# not possible to refer to that from a shell script (the
215# variable is not exported from envsetup.sh). There is also
216# some trickery involved: we need to include some classes
217# that reside in core.jar, but since we cannot incldue the
218# whole core.jar in the RI classpath, we copy those classses
219# over to our new file.
220HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
221
222$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
223$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
224$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
225 @rm -rf $(dir $<)/hostctsclasses
226 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
227 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
228 @cp $< $@
229 @jar uf $@ -C $(dir $<)hostctsclasses .
230
231$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
232
233$(LOCAL_INSTALLED_MODULE): run-core-tests
234
235# Definitions to copy the core-tests runner script.
236
237include $(CLEAR_VARS)
238LOCAL_SRC_FILES := run-core-tests
239LOCAL_MODULE_CLASS := EXECUTABLES
240LOCAL_MODULE_TAGS := tests
241LOCAL_MODULE := run-core-tests
242include $(BUILD_PREBUILT)
243
244include $(CLEAR_VARS)
245LOCAL_SRC_FILES := run-core-tests-on-ri
246LOCAL_IS_HOST_MODULE := true
247LOCAL_MODULE_CLASS := EXECUTABLES
248LOCAL_MODULE_TAGS := tests
249LOCAL_MODULE := run-core-tests-on-ri
250include $(BUILD_PREBUILT)
251
252
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
267 LOCAL_DX_FLAGS := --core-library
268
269 LOCAL_NO_EMMA_INSTRUMENT := true
270 LOCAL_NO_EMMA_COMPILE := true
271
272 LOCAL_MODULE := core
273
274 include $(BUILD_HOST_JAVA_LIBRARY)
275
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800276endif