blob: 69aa4208d80f98db887fa7913c5808073f38ab07 [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
Guang Zhu709c24d2010-03-10 15:51:58 -080057ifeq ($(EMMA_INSTRUMENT),true)
58LOCAL_SRC_FILES += $(call all-java-files-under, ../../external/emma/core ../../external/emma/pregenerated)
59LOCAL_JAVA_RESOURCE_DIRS += ../../external/emma/core/res ../../external/emma/pregenerated/res
60endif
61
Dan Bornstein6ac43c22009-10-24 15:33:49 -070062LOCAL_NO_STANDARD_LIBRARIES := true
63LOCAL_DX_FLAGS := --core-library
64
65LOCAL_NO_EMMA_INSTRUMENT := true
66LOCAL_NO_EMMA_COMPILE := true
67
68LOCAL_MODULE := core
69
70include $(BUILD_JAVA_LIBRARY)
71
72core-intermediates := ${intermediates}
73
74
75# Definitions to make the core-tests library.
76
77include $(CLEAR_VARS)
78
79LOCAL_SRC_FILES := $(test_src_files)
80LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
81
82LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes67cc34b2010-02-19 22:14:19 -080083LOCAL_JAVA_LIBRARIES := core
Dan Bornstein6ac43c22009-10-24 15:33:49 -070084LOCAL_DX_FLAGS := --core-library
85
86LOCAL_MODULE_TAGS := tests
87LOCAL_MODULE := core-tests
88
89include $(BUILD_JAVA_LIBRARY)
90
91
92
93# This one's tricky. One of our tests needs to have a
94# resource with a "#" in its name, but Perforce doesn't
95# allow us to submit such a file. So we create it here
96# on-the-fly.
97TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
98TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
99
100$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
101 @mkdir -p $(dir $@)
102 @echo "Hello, world!" > $@
103
104$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE)
105$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
106
107# Definitions for building a version of the core-tests.jar
108# that is suitable for execution on the RI. This JAR would
109# be better located in $HOST_OUT_JAVA_LIBRARIES, but it is
110# not possible to refer to that from a shell script (the
111# variable is not exported from envsetup.sh). There is also
112# some trickery involved: we need to include some classes
113# that reside in core.jar, but since we cannot incldue the
114# whole core.jar in the RI classpath, we copy those classses
115# over to our new file.
116HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
117
118$(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
119$(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates)
120$(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE)
121 @rm -rf $(dir $<)/hostctsclasses
122 $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses)
123 @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses
124 @cp $< $@
125 @jar uf $@ -C $(dir $<)hostctsclasses .
126
127$(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
128
129$(LOCAL_INSTALLED_MODULE): run-core-tests
130
131# Definitions to copy the core-tests runner script.
132
133include $(CLEAR_VARS)
134LOCAL_SRC_FILES := run-core-tests
135LOCAL_MODULE_CLASS := EXECUTABLES
136LOCAL_MODULE_TAGS := tests
137LOCAL_MODULE := run-core-tests
138include $(BUILD_PREBUILT)
139
140include $(CLEAR_VARS)
141LOCAL_SRC_FILES := run-core-tests-on-ri
142LOCAL_IS_HOST_MODULE := true
143LOCAL_MODULE_CLASS := EXECUTABLES
144LOCAL_MODULE_TAGS := tests
145LOCAL_MODULE := run-core-tests-on-ri
146include $(BUILD_PREBUILT)
147
148
149#
150# Build for the host.
151#
152
153ifeq ($(WITH_HOST_DALVIK),true)
154
155 # Definitions to make the core library.
156
157 include $(CLEAR_VARS)
158
159 LOCAL_SRC_FILES := $(core_src_files)
160 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
161
162 LOCAL_NO_STANDARD_LIBRARIES := true
163 LOCAL_DX_FLAGS := --core-library
164
165 LOCAL_NO_EMMA_INSTRUMENT := true
166 LOCAL_NO_EMMA_COMPILE := true
167
168 LOCAL_MODULE := core
169
170 include $(BUILD_HOST_JAVA_LIBRARY)
171
172
173 # Definitions to make the core-tests library.
174
175 include $(CLEAR_VARS)
176
177 LOCAL_SRC_FILES := $(test_src_files)
178 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
179
180 LOCAL_NO_STANDARD_LIBRARIES := true
181 LOCAL_JAVA_LIBRARIES := core
182 LOCAL_DX_FLAGS := --core-library
183
184 LOCAL_MODULE_TAGS := tests
185 LOCAL_MODULE := core-tests
186
187 include $(BUILD_HOST_JAVA_LIBRARY)
188
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800189endif