1 # Copyright (C) 2007 The Android Open Source Project
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # Definitions for building the Java library and associated tests.
20 # Common definitions for host and target.
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.
27 define all-core-java-files
28 $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find */src/$(1)/java -name "*.java"))
31 # Redirect ls stderr to /dev/null because the corresponding resources
32 # directories don't always exist.
33 define all-core-resource-dirs
34 $(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
37 # The core Java files and associated resources.
38 core_src_files := $(call all-core-java-files,main)
39 core_resource_dirs := $(call all-core-resource-dirs,main)
41 # The test Java files and associated resources.
42 test_src_files := $(call all-core-java-files,test)
43 test_resource_dirs := $(call all-core-resource-dirs,test)
47 # Build for the target (device).
50 # Definitions to make the core library.
54 LOCAL_SRC_FILES := $(core_src_files)
55 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
57 LOCAL_NO_STANDARD_LIBRARIES := true
58 LOCAL_DX_FLAGS := --core-library
60 LOCAL_NO_EMMA_INSTRUMENT := true
61 LOCAL_NO_EMMA_COMPILE := true
65 include $(BUILD_JAVA_LIBRARY)
67 core-intermediates := ${intermediates}
70 # Definitions to make the core-tests library.
74 LOCAL_SRC_FILES := $(test_src_files)
75 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
77 LOCAL_NO_STANDARD_LIBRARIES := true
78 LOCAL_JAVA_LIBRARIES := core
79 LOCAL_DX_FLAGS := --core-library
81 LOCAL_MODULE_TAGS := tests
82 LOCAL_MODULE := core-tests
84 include $(BUILD_JAVA_LIBRARY)
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
92 TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/
93 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
95 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
97 @echo "Hello, world!" > $@
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)
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.
111 HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar
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
120 @jar uf $@ -C $(dir $<)hostctsclasses .
122 $(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR)
124 $(LOCAL_INSTALLED_MODULE): run-core-tests
126 # Definitions to copy the core-tests runner script.
128 include $(CLEAR_VARS)
129 LOCAL_SRC_FILES := run-core-tests
130 LOCAL_MODULE_CLASS := EXECUTABLES
131 LOCAL_MODULE_TAGS := tests
132 LOCAL_MODULE := run-core-tests
133 include $(BUILD_PREBUILT)
135 include $(CLEAR_VARS)
136 LOCAL_SRC_FILES := run-core-tests-on-ri
137 LOCAL_IS_HOST_MODULE := true
138 LOCAL_MODULE_CLASS := EXECUTABLES
139 LOCAL_MODULE_TAGS := tests
140 LOCAL_MODULE := run-core-tests-on-ri
141 include $(BUILD_PREBUILT)
145 # Build for the host.
148 ifeq ($(WITH_HOST_DALVIK),true)
150 # Definitions to make the core library.
152 include $(CLEAR_VARS)
154 LOCAL_SRC_FILES := $(core_src_files)
155 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
157 LOCAL_NO_STANDARD_LIBRARIES := true
158 LOCAL_DX_FLAGS := --core-library
160 LOCAL_NO_EMMA_INSTRUMENT := true
161 LOCAL_NO_EMMA_COMPILE := true
165 include $(BUILD_HOST_JAVA_LIBRARY)
168 # Definitions to make the core-tests library.
170 include $(CLEAR_VARS)
172 LOCAL_SRC_FILES := $(test_src_files)
173 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
175 LOCAL_NO_STANDARD_LIBRARIES := true
176 LOCAL_JAVA_LIBRARIES := core
177 LOCAL_DX_FLAGS := --core-library
179 LOCAL_MODULE_TAGS := tests
180 LOCAL_MODULE := core-tests
182 include $(BUILD_HOST_JAVA_LIBRARY)