blob: d3d435525a698ddd55520b0d804a6b8237fee5bc [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
Jean-Baptiste Queru6e1c2a92010-04-30 10:13:35 -070024# libcore is divided into modules.
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -080025#
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
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -080040define all-main-java-files-under
41$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/main/java -name "*.java" 2> /dev/null)))
Dan Bornstein6ac43c22009-10-24 15:33:49 -070042endef
43
Elliott Hughes7ee3a062010-02-18 17:20:15 -080044define all-test-java-files-under
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -080045$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(1)/src/test/java -name "*.java" 2> /dev/null))
Elliott Hughes7ee3a062010-02-18 17:20:15 -080046endef
47
Dan Bornstein6ac43c22009-10-24 15:33:49 -070048define all-core-resource-dirs
Elliott Hughes3e951a52010-02-22 15:01:55 -080049$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070050endef
51
Elliott Hughes3e951a52010-02-22 15:01:55 -080052# The Java files and their associated resources.
Peter Hallam6b811c52010-05-03 12:57:15 -070053core_src_files := $(call all-main-java-files-under,dalvik dom json junit luni openssl support xml)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070054core_resource_dirs := $(call all-core-resource-dirs,main)
Elliott Hughes3e951a52010-02-22 15:01:55 -080055test_resource_dirs := $(call all-core-resource-dirs,test)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070056
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
Elliott Hughes7ee3a062010-02-18 17:20:15 -080087
Elliott Hughesb9cf9cb2010-02-26 14:46:53 -080088# Definitions to make the sqlite JDBC driver.
89
90include $(CLEAR_VARS)
91LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc)
92LOCAL_NO_STANDARD_LIBRARIES := true
93LOCAL_JAVA_LIBRARIES := core
94LOCAL_MODULE := sqlite-jdbc
95include $(BUILD_JAVA_LIBRARY)
96
Elliott Hughes7ee3a062010-02-18 17:20:15 -080097
98# Definitions to make the core-tests libraries.
99#
100# We make a library per module, because otherwise the .jar files get too
101# large, to the point that dx(1) can't cope (and the build is
102# ridiculously slow).
103#
104# TODO: DalvikRunner will make this nonsense obsolete.
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700105
106include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800107LOCAL_SRC_FILES := $(call all-test-java-files-under,dom)
108LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
109LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughese2a6f772010-02-22 12:09:51 -0800110LOCAL_JAVA_LIBRARIES := core core-tests-support
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800111LOCAL_DX_FLAGS := --core-library
112LOCAL_MODULE_TAGS := tests
113LOCAL_MODULE := core-tests-dom
114include $(BUILD_JAVA_LIBRARY)
115
116include $(CLEAR_VARS)
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800117LOCAL_SRC_FILES := $(call all-test-java-files-under,json)
118LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
119LOCAL_NO_STANDARD_LIBRARIES := true
120LOCAL_JAVA_LIBRARIES := core core-tests-support
121LOCAL_DX_FLAGS := --core-library
122LOCAL_MODULE_TAGS := tests
123LOCAL_MODULE := core-tests-json
124include $(BUILD_JAVA_LIBRARY)
125
126include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800127LOCAL_SRC_FILES := $(call all-test-java-files-under,luni)
128LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
129LOCAL_NO_STANDARD_LIBRARIES := true
130# This module contains the top-level "tests.AllTests" that ties everything
131# together, so it has compile-time dependencies on all the other test
132# libraries.
133# TODO: we should have a bogus module that just contains tests.AllTests for speed.
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800134LOCAL_JAVA_LIBRARIES := \
135 core \
136 core-tests-support \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800137 core-tests-dom \
Elliott Hughesbf1ecf22010-02-22 12:45:26 -0800138 core-tests-json \
Peter Hallamcec4dd42010-04-26 12:53:37 -0700139 core-tests-xml \
140 sqlite-jdbc
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800141LOCAL_DX_FLAGS := --core-library
142LOCAL_MODULE_TAGS := tests
143LOCAL_MODULE := core-tests-luni
144include $(BUILD_JAVA_LIBRARY)
145
146include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800147LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
148LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700149LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800150LOCAL_JAVA_LIBRARIES := core
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700151LOCAL_DX_FLAGS := --core-library
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700152LOCAL_MODULE_TAGS := tests
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800153LOCAL_MODULE := core-tests-support
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700154include $(BUILD_JAVA_LIBRARY)
155
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800156include $(CLEAR_VARS)
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800157LOCAL_SRC_FILES := $(call all-test-java-files-under,xml)
158LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
159LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughese2a6f772010-02-22 12:09:51 -0800160LOCAL_JAVA_LIBRARIES := core core-tests-support
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800161LOCAL_DX_FLAGS := --core-library
162LOCAL_MODULE_TAGS := tests
163LOCAL_MODULE := core-tests-xml
164include $(BUILD_JAVA_LIBRARY)
165
166
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700167
168
169# This one's tricky. One of our tests needs to have a
170# resource with a "#" in its name, but Perforce doesn't
171# allow us to submit such a file. So we create it here
172# on-the-fly.
173TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
174TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
175
176$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
177 @mkdir -p $(dir $@)
178 @echo "Hello, world!" > $@
179
180$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
181$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
182
183# Definitions for building a version of the core-tests.jar
184# that is suitable for execution on the RI. This JAR would
185# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
186# not possible to refer to that from a shell script (the
187# variable is not exported from envsetup.sh). There is also
188# some trickery involved: we need to include some classes
189# that reside in core.jar, but since we cannot incldue the
190# whole core.jar in the RI classpath, we copy those classses
191# over to our new file.
192HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
193
194$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
195$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
196$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
197 @rm -rf $(dir $<)/hostctsclasses
198 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
199 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
200 @cp $< $@
201 @jar uf $@ -C $(dir $<)hostctsclasses .
202
203$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
204
205$(LOCAL_INSTALLED_MODULE): run-core-tests
206
207# Definitions to copy the core-tests runner script.
208
209include $(CLEAR_VARS)
210LOCAL_SRC_FILES := run-core-tests
211LOCAL_MODULE_CLASS := EXECUTABLES
212LOCAL_MODULE_TAGS := tests
213LOCAL_MODULE := run-core-tests
214include $(BUILD_PREBUILT)
215
216include $(CLEAR_VARS)
217LOCAL_SRC_FILES := run-core-tests-on-ri
218LOCAL_IS_HOST_MODULE := true
219LOCAL_MODULE_CLASS := EXECUTABLES
220LOCAL_MODULE_TAGS := tests
221LOCAL_MODULE := run-core-tests-on-ri
222include $(BUILD_PREBUILT)
223
224
225#
226# Build for the host.
227#
228
229ifeq ($(WITH_HOST_DALVIK),true)
230
231 # Definitions to make the core library.
232
233 include $(CLEAR_VARS)
234
235 LOCAL_SRC_FILES := $(core_src_files)
236 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
237
238 LOCAL_NO_STANDARD_LIBRARIES := true
239 LOCAL_DX_FLAGS := --core-library
240
241 LOCAL_NO_EMMA_INSTRUMENT := true
242 LOCAL_NO_EMMA_COMPILE := true
243
244 LOCAL_MODULE := core
245
246 include $(BUILD_HOST_JAVA_LIBRARY)
247
Elliott Hughes7ee3a062010-02-18 17:20:15 -0800248endif