blob: bbe51a7b97c879aa905e08235b14141c2a1ab9df [file] [log] [blame]
Dan Bornstein6ac43c22009-10-24 15:33:49 -07001# Copyright (C) 2007 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# Definitions for building the Java library and associated tests.
17#
18
19#
20# Common definitions for host and target.
21#
22
23# The core library is divided into modules. Each module has a separate
24# Java source directory, and some (hopefully eventually all) also have
25# a directory for tests.
26
Jesse Wilson32cfe952010-05-04 16:36:03 -070027define all-main-java-files-under
28$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/main/java -name "*.java" 2> /dev/null)))
29endef
30
31define all-test-java-files-under
32$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(1)/src/test/java -name "*.java" 2> /dev/null))
Dan Bornstein6ac43c22009-10-24 15:33:49 -070033endef
34
35# Redirect ls stderr to /dev/null because the corresponding resources
36# directories don't always exist.
37define all-core-resource-dirs
38$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
39endef
40
41# The core Java files and associated resources.
Jesse Wilson32cfe952010-05-04 16:36:03 -070042core_src_files := $(call all-main-java-files-under,annotation archive auth awt-kernel concurrent crypto dalvik dom icu json logging luni luni-kernel math nio nio_char openssl prefs regex security security-kernel sql suncompat support text x-net xml)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070043core_resource_dirs := $(call all-core-resource-dirs,main)
44
45# The test Java files and associated resources.
Jesse Wilson32cfe952010-05-04 16:36:03 -070046test_src_files := $(call all-test-java-files-under,annotation archive auth awt-kernel concurrent crypto dalvik dom icu json junit logging luni luni-kernel math nio nio_char openssl prefs regex security security-kernel sql suncompat support text x-net xml)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070047test_resource_dirs := $(call all-core-resource-dirs,test)
48
49
50#
51# Build for the target (device).
52#
53
54# Definitions to make the core library.
55
56include $(CLEAR_VARS)
57
58LOCAL_SRC_FILES := $(core_src_files)
59LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
60
Guang Zhu709c24d2010-03-10 15:51:58 -080061ifeq ($(EMMA_INSTRUMENT),true)
62LOCAL_SRC_FILES += $(call all-java-files-under, ../../external/emma/core ../../external/emma/pregenerated)
63LOCAL_JAVA_RESOURCE_DIRS += ../../external/emma/core/res ../../external/emma/pregenerated/res
64endif
65
Dan Bornstein6ac43c22009-10-24 15:33:49 -070066LOCAL_NO_STANDARD_LIBRARIES := true
67LOCAL_DX_FLAGS := --core-library
68
69LOCAL_NO_EMMA_INSTRUMENT := true
70LOCAL_NO_EMMA_COMPILE := true
71
72LOCAL_MODULE := core
73
74include $(BUILD_JAVA_LIBRARY)
75
76core-intermediates := ${intermediates}
77
78
Jesse Wilson32cfe952010-05-04 16:36:03 -070079# Make core-junit
80include $(CLEAR_VARS)
81LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
82LOCAL_NO_STANDARD_LIBRARIES := true
83LOCAL_JAVA_LIBRARIES := core
84LOCAL_MODULE := core-junit
85include $(BUILD_JAVA_LIBRARY)
86
87
Dan Bornstein6ac43c22009-10-24 15:33:49 -070088# Definitions to make the core-tests library.
89
90include $(CLEAR_VARS)
91
92LOCAL_SRC_FILES := $(test_src_files)
93LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
94
95LOCAL_NO_STANDARD_LIBRARIES := true
Jesse Wilson32cfe952010-05-04 16:36:03 -070096LOCAL_JAVA_LIBRARIES := core core-junit
Dan Bornstein6ac43c22009-10-24 15:33:49 -070097LOCAL_DX_FLAGS := --core-library
98
99LOCAL_MODULE_TAGS := tests
100LOCAL_MODULE := core-tests
101
Guang Zhuf69aac32010-04-28 11:33:48 -0700102LOCAL_NO_EMMA_INSTRUMENT := true
103LOCAL_NO_EMMA_COMPILE := true
104
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700105include $(BUILD_JAVA_LIBRARY)
106
107
108
109# This one's tricky. One of our tests needs to have a
110# resource with a "#" in its name, but Perforce doesn't
111# allow us to submit such a file. So we create it here
112# on-the-fly.
113TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
114TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
115
116$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
117 @mkdir -p $(dir $@)
118 @echo "Hello, world!" > $@
119
120$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
121$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
122
123# Definitions for building a version of the core-tests.jar
124# that is suitable for execution on the RI. This JAR would
125# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
126# not possible to refer to that from a shell script (the
127# variable is not exported from envsetup.sh). There is also
128# some trickery involved: we need to include some classes
129# that reside in core.jar, but since we cannot incldue the
130# whole core.jar in the RI classpath, we copy those classses
131# over to our new file.
132HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
133
134$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
135$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
136$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
137 @rm -rf $(dir $<)/hostctsclasses
138 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
139 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
140 @cp $< $@
141 @jar uf $@ -C $(dir $<)hostctsclasses .
142
143$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
144
145$(LOCAL_INSTALLED_MODULE): run-core-tests
146
147# Definitions to copy the core-tests runner script.
148
149include $(CLEAR_VARS)
150LOCAL_SRC_FILES := run-core-tests
151LOCAL_MODULE_CLASS := EXECUTABLES
152LOCAL_MODULE_TAGS := tests
153LOCAL_MODULE := run-core-tests
154include $(BUILD_PREBUILT)
155
156include $(CLEAR_VARS)
157LOCAL_SRC_FILES := run-core-tests-on-ri
158LOCAL_IS_HOST_MODULE := true
159LOCAL_MODULE_CLASS := EXECUTABLES
160LOCAL_MODULE_TAGS := tests
161LOCAL_MODULE := run-core-tests-on-ri
162include $(BUILD_PREBUILT)
163
164
165#
166# Build for the host.
167#
168
169ifeq ($(WITH_HOST_DALVIK),true)
170
171 # Definitions to make the core library.
172
173 include $(CLEAR_VARS)
174
175 LOCAL_SRC_FILES := $(core_src_files)
176 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
177
178 LOCAL_NO_STANDARD_LIBRARIES := true
179 LOCAL_DX_FLAGS := --core-library
180
181 LOCAL_NO_EMMA_INSTRUMENT := true
182 LOCAL_NO_EMMA_COMPILE := true
183
184 LOCAL_MODULE := core
185
186 include $(BUILD_HOST_JAVA_LIBRARY)
187
188
189 # Definitions to make the core-tests library.
190
191 include $(CLEAR_VARS)
192
193 LOCAL_SRC_FILES := $(test_src_files)
194 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
195
196 LOCAL_NO_STANDARD_LIBRARIES := true
197 LOCAL_JAVA_LIBRARIES := core
198 LOCAL_DX_FLAGS := --core-library
199
200 LOCAL_MODULE_TAGS := tests
201 LOCAL_MODULE := core-tests
202
203 include $(BUILD_HOST_JAVA_LIBRARY)
204
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800205endif