blob: d1015f549e5ac2567f8347ad251d38aeb7aa8194 [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
27define all-core-java-files
28$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find */src/$(1)/java -name "*.java"))
29endef
30
31# Redirect ls stderr to /dev/null because the corresponding resources
32# directories don't always exist.
33define all-core-resource-dirs
34$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
35endef
36
37# The core Java files and associated resources.
38core_src_files := $(call all-core-java-files,main)
39core_resource_dirs := $(call all-core-resource-dirs,main)
40
41# The test Java files and associated resources.
42test_src_files := $(call all-core-java-files,test)
43test_resource_dirs := $(call all-core-resource-dirs,test)
44
45
46#
47# Build for the target (device).
48#
49
50# Definitions to make the core library.
51
52include $(CLEAR_VARS)
53
54LOCAL_SRC_FILES := $(core_src_files)
55LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
56
57LOCAL_NO_STANDARD_LIBRARIES := true
58LOCAL_DX_FLAGS := --core-library
59
60LOCAL_NO_EMMA_INSTRUMENT := true
61LOCAL_NO_EMMA_COMPILE := true
62
63LOCAL_MODULE := core
64
65include $(BUILD_JAVA_LIBRARY)
66
67core-intermediates := ${intermediates}
68
69
70# Definitions to make the core-tests library.
71
72include $(CLEAR_VARS)
73
74LOCAL_SRC_FILES := $(test_src_files)
75LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
76
77LOCAL_NO_STANDARD_LIBRARIES := true
78LOCAL_JAVA_LIBRARIES := core
79LOCAL_DX_FLAGS := --core-library
80
81LOCAL_MODULE_TAGS := tests
82LOCAL_MODULE := core-tests
83
84include $(BUILD_JAVA_LIBRARY)
85
86
87
88# This one's tricky. One of our tests needs to have a
89# resource with a "#" in its name, but Perforce doesn't
90# allow us to submit such a file. So we create it here
91# on-the-fly.
92TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
93TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
94
95$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
96 @mkdir -p $(dir $@)
97 @echo "Hello, world!" > $@
98
99$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
100$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
101
102# Definitions for building a version of the core-tests.jar
103# that is suitable for execution on the RI. This JAR would
104# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
105# not possible to refer to that from a shell script (the
106# variable is not exported from envsetup.sh). There is also
107# some trickery involved: we need to include some classes
108# that reside in core.jar, but since we cannot incldue the
109# whole core.jar in the RI classpath, we copy those classses
110# over to our new file.
111HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
112
113$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
114$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
115$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
116 @rm -rf $(dir $<)/hostctsclasses
117 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
118 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
119 @cp $< $@
120 @jar uf $@ -C $(dir $<)hostctsclasses .
121
122$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
123
124$(LOCAL_INSTALLED_MODULE): run-core-tests
125
126# Definitions to copy the core-tests runner script.
127
128include $(CLEAR_VARS)
129LOCAL_SRC_FILES := run-core-tests
130LOCAL_MODULE_CLASS := EXECUTABLES
131LOCAL_MODULE_TAGS := tests
132LOCAL_MODULE := run-core-tests
133include $(BUILD_PREBUILT)
134
135include $(CLEAR_VARS)
136LOCAL_SRC_FILES := run-core-tests-on-ri
137LOCAL_IS_HOST_MODULE := true
138LOCAL_MODULE_CLASS := EXECUTABLES
139LOCAL_MODULE_TAGS := tests
140LOCAL_MODULE := run-core-tests-on-ri
141include $(BUILD_PREBUILT)
142
143
144#
145# Build for the host.
146#
147
148ifeq ($(WITH_HOST_DALVIK),true)
149
150 # Definitions to make the core library.
151
152 include $(CLEAR_VARS)
153
154 LOCAL_SRC_FILES := $(core_src_files)
155 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
156
157 LOCAL_NO_STANDARD_LIBRARIES := true
158 LOCAL_DX_FLAGS := --core-library
159
160 LOCAL_NO_EMMA_INSTRUMENT := true
161 LOCAL_NO_EMMA_COMPILE := true
162
163 LOCAL_MODULE := core
164
165 include $(BUILD_HOST_JAVA_LIBRARY)
166
167
168 # Definitions to make the core-tests library.
169
170 include $(CLEAR_VARS)
171
172 LOCAL_SRC_FILES := $(test_src_files)
173 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
174
175 LOCAL_NO_STANDARD_LIBRARIES := true
176 LOCAL_JAVA_LIBRARIES := core
177 LOCAL_DX_FLAGS := --core-library
178
179 LOCAL_MODULE_TAGS := tests
180 LOCAL_MODULE := core-tests
181
182 include $(BUILD_HOST_JAVA_LIBRARY)
183
184endif