| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 1 | # -*- mode: makefile -*- |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 2 | # 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 | |
| Elliott Hughes | b9cf9cb | 2010-02-26 14:46:53 -0800 | [diff] [blame] | 24 | # dalvik/libcore is divided into modules. |
| 25 | # |
| 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 Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 39 | |
| Elliott Hughes | b9cf9cb | 2010-02-26 14:46:53 -0800 | [diff] [blame] | 40 | define 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 Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 42 | endef |
| 43 | |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 44 | define all-test-java-files-under |
| Elliott Hughes | b9cf9cb | 2010-02-26 14:46:53 -0800 | [diff] [blame] | 45 | $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(1)/src/test/java -name "*.java" 2> /dev/null)) |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 46 | endef |
| 47 | |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 48 | define all-core-resource-dirs |
| Elliott Hughes | 3e951a5 | 2010-02-22 15:01:55 -0800 | [diff] [blame] | 49 | $(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null) |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 50 | endef |
| 51 | |
| Elliott Hughes | 3e951a5 | 2010-02-22 15:01:55 -0800 | [diff] [blame] | 52 | # The Java files and their associated resources. |
| Peter Hallam | cec4dd4 | 2010-04-26 12:53:37 -0700 | [diff] [blame^] | 53 | core_src_files := $(call all-main-java-files-under,awt-kernel dalvik dom icu json junit luni luni-kernel openssl prefs security-kernel support x-net xml) |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 54 | core_resource_dirs := $(call all-core-resource-dirs,main) |
| Elliott Hughes | 3e951a5 | 2010-02-22 15:01:55 -0800 | [diff] [blame] | 55 | test_resource_dirs := $(call all-core-resource-dirs,test) |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 56 | |
| 57 | |
| 58 | # |
| 59 | # Build for the target (device). |
| 60 | # |
| 61 | |
| 62 | # Definitions to make the core library. |
| 63 | |
| 64 | include $(CLEAR_VARS) |
| 65 | |
| 66 | LOCAL_SRC_FILES := $(core_src_files) |
| 67 | LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) |
| 68 | |
| Guang Zhu | 709c24d | 2010-03-10 15:51:58 -0800 | [diff] [blame] | 69 | ifeq ($(EMMA_INSTRUMENT),true) |
| 70 | LOCAL_SRC_FILES += $(call all-java-files-under, ../../external/emma/core ../../external/emma/pregenerated) |
| 71 | LOCAL_JAVA_RESOURCE_DIRS += ../../external/emma/core/res ../../external/emma/pregenerated/res |
| 72 | endif |
| 73 | |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 74 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 75 | LOCAL_DX_FLAGS := --core-library |
| 76 | |
| 77 | LOCAL_NO_EMMA_INSTRUMENT := true |
| 78 | LOCAL_NO_EMMA_COMPILE := true |
| 79 | |
| 80 | LOCAL_MODULE := core |
| 81 | |
| 82 | include $(BUILD_JAVA_LIBRARY) |
| 83 | |
| 84 | core-intermediates := ${intermediates} |
| 85 | |
| 86 | |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 87 | |
| Elliott Hughes | b9cf9cb | 2010-02-26 14:46:53 -0800 | [diff] [blame] | 88 | # Definitions to make the sqlite JDBC driver. |
| 89 | |
| 90 | include $(CLEAR_VARS) |
| 91 | LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc) |
| 92 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 93 | LOCAL_JAVA_LIBRARIES := core |
| 94 | LOCAL_MODULE := sqlite-jdbc |
| 95 | include $(BUILD_JAVA_LIBRARY) |
| 96 | |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 97 | |
| 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 Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 105 | |
| 106 | include $(CLEAR_VARS) |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 107 | LOCAL_SRC_FILES := $(call all-test-java-files-under,dom) |
| 108 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 109 | LOCAL_NO_STANDARD_LIBRARIES := true |
| Elliott Hughes | e2a6f77 | 2010-02-22 12:09:51 -0800 | [diff] [blame] | 110 | LOCAL_JAVA_LIBRARIES := core core-tests-support |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 111 | LOCAL_DX_FLAGS := --core-library |
| 112 | LOCAL_MODULE_TAGS := tests |
| 113 | LOCAL_MODULE := core-tests-dom |
| 114 | include $(BUILD_JAVA_LIBRARY) |
| 115 | |
| 116 | include $(CLEAR_VARS) |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 117 | LOCAL_SRC_FILES := $(call all-test-java-files-under,json) |
| 118 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 119 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 120 | LOCAL_JAVA_LIBRARIES := core core-tests-support |
| 121 | LOCAL_DX_FLAGS := --core-library |
| 122 | LOCAL_MODULE_TAGS := tests |
| 123 | LOCAL_MODULE := core-tests-json |
| 124 | include $(BUILD_JAVA_LIBRARY) |
| 125 | |
| 126 | include $(CLEAR_VARS) |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 127 | LOCAL_SRC_FILES := $(call all-test-java-files-under,luni-kernel) |
| 128 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 129 | LOCAL_NO_STANDARD_LIBRARIES := true |
| Elliott Hughes | e2a6f77 | 2010-02-22 12:09:51 -0800 | [diff] [blame] | 130 | LOCAL_JAVA_LIBRARIES := core core-tests-support |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 131 | LOCAL_DX_FLAGS := --core-library |
| 132 | LOCAL_MODULE_TAGS := tests |
| 133 | LOCAL_MODULE := core-tests-luni-kernel |
| 134 | include $(BUILD_JAVA_LIBRARY) |
| 135 | |
| 136 | include $(CLEAR_VARS) |
| 137 | LOCAL_SRC_FILES := $(call all-test-java-files-under,luni) |
| 138 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 139 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 140 | # This module contains the top-level "tests.AllTests" that ties everything |
| 141 | # together, so it has compile-time dependencies on all the other test |
| 142 | # libraries. |
| 143 | # TODO: we should have a bogus module that just contains tests.AllTests for speed. |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 144 | LOCAL_JAVA_LIBRARIES := \ |
| 145 | core \ |
| 146 | core-tests-support \ |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 147 | core-tests-dom \ |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 148 | core-tests-json \ |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 149 | core-tests-luni-kernel \ |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 150 | core-tests-prefs \ |
| Elliott Hughes | bf1ecf2 | 2010-02-22 12:45:26 -0800 | [diff] [blame] | 151 | core-tests-x-net \ |
| Peter Hallam | cec4dd4 | 2010-04-26 12:53:37 -0700 | [diff] [blame^] | 152 | core-tests-xml \ |
| 153 | sqlite-jdbc |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 154 | LOCAL_DX_FLAGS := --core-library |
| 155 | LOCAL_MODULE_TAGS := tests |
| 156 | LOCAL_MODULE := core-tests-luni |
| 157 | include $(BUILD_JAVA_LIBRARY) |
| 158 | |
| 159 | include $(CLEAR_VARS) |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 160 | LOCAL_SRC_FILES := $(call all-test-java-files-under,prefs) |
| 161 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 162 | LOCAL_NO_STANDARD_LIBRARIES := true |
| Elliott Hughes | e2a6f77 | 2010-02-22 12:09:51 -0800 | [diff] [blame] | 163 | LOCAL_JAVA_LIBRARIES := core core-tests-support |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 164 | LOCAL_DX_FLAGS := --core-library |
| 165 | LOCAL_MODULE_TAGS := tests |
| 166 | LOCAL_MODULE := core-tests-prefs |
| 167 | include $(BUILD_JAVA_LIBRARY) |
| 168 | |
| 169 | include $(CLEAR_VARS) |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 170 | LOCAL_SRC_FILES := $(call all-test-java-files-under,support) |
| 171 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 172 | LOCAL_NO_STANDARD_LIBRARIES := true |
| Elliott Hughes | 67cc34b | 2010-02-19 22:14:19 -0800 | [diff] [blame] | 173 | LOCAL_JAVA_LIBRARIES := core |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 174 | LOCAL_DX_FLAGS := --core-library |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 175 | LOCAL_MODULE_TAGS := tests |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 176 | LOCAL_MODULE := core-tests-support |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 177 | include $(BUILD_JAVA_LIBRARY) |
| 178 | |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 179 | include $(CLEAR_VARS) |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 180 | LOCAL_SRC_FILES := $(call all-test-java-files-under,x-net) |
| 181 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 182 | LOCAL_NO_STANDARD_LIBRARIES := true |
| Elliott Hughes | e2a6f77 | 2010-02-22 12:09:51 -0800 | [diff] [blame] | 183 | LOCAL_JAVA_LIBRARIES := core core-tests-support |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 184 | LOCAL_DX_FLAGS := --core-library |
| 185 | LOCAL_MODULE_TAGS := tests |
| 186 | LOCAL_MODULE := core-tests-x-net |
| 187 | include $(BUILD_JAVA_LIBRARY) |
| 188 | |
| 189 | include $(CLEAR_VARS) |
| 190 | LOCAL_SRC_FILES := $(call all-test-java-files-under,xml) |
| 191 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 192 | LOCAL_NO_STANDARD_LIBRARIES := true |
| Elliott Hughes | e2a6f77 | 2010-02-22 12:09:51 -0800 | [diff] [blame] | 193 | LOCAL_JAVA_LIBRARIES := core core-tests-support |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 194 | LOCAL_DX_FLAGS := --core-library |
| 195 | LOCAL_MODULE_TAGS := tests |
| 196 | LOCAL_MODULE := core-tests-xml |
| 197 | include $(BUILD_JAVA_LIBRARY) |
| 198 | |
| 199 | |
| Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 200 | |
| 201 | |
| 202 | # This one's tricky. One of our tests needs to have a |
| 203 | # resource with a "#" in its name, but Perforce doesn't |
| 204 | # allow us to submit such a file. So we create it here |
| 205 | # on-the-fly. |
| 206 | TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/ |
| 207 | TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties |
| 208 | |
| 209 | $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE): |
| 210 | @mkdir -p $(dir $@) |
| 211 | @echo "Hello, world!" > $@ |
| 212 | |
| 213 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE) |
| 214 | $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE) |
| 215 | |
| 216 | # Definitions for building a version of the core-tests.jar |
| 217 | # that is suitable for execution on the RI. This JAR would |
| 218 | # be better located in $HOST_OUT_JAVA_LIBRARIES, but it is |
| 219 | # not possible to refer to that from a shell script (the |
| 220 | # variable is not exported from envsetup.sh). There is also |
| 221 | # some trickery involved: we need to include some classes |
| 222 | # that reside in core.jar, but since we cannot incldue the |
| 223 | # whole core.jar in the RI classpath, we copy those classses |
| 224 | # over to our new file. |
| 225 | HOST_CORE_JAR := $(HOST_COMMON_OUT_ROOT)/core-tests.jar |
| 226 | |
| 227 | $(HOST_CORE_JAR): PRIVATE_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE) |
| 228 | $(HOST_CORE_JAR): PRIVATE_CORE_INTERMEDIATES := $(core-intermediates) |
| 229 | $(HOST_CORE_JAR): $(LOCAL_BUILT_MODULE) |
| 230 | @rm -rf $(dir $<)/hostctsclasses |
| 231 | $(call unzip-jar-files,$(dir $<)classes.jar,$(dir $<)hostctsclasses) |
| 232 | @unzip -qx -o $(PRIVATE_CORE_INTERMEDIATES)/classes.jar dalvik/annotation/* -d $(dir $<)hostctsclasses |
| 233 | @cp $< $@ |
| 234 | @jar uf $@ -C $(dir $<)hostctsclasses . |
| 235 | |
| 236 | $(LOCAL_INSTALLED_MODULE): $(HOST_CORE_JAR) |
| 237 | |
| 238 | $(LOCAL_INSTALLED_MODULE): run-core-tests |
| 239 | |
| 240 | # Definitions to copy the core-tests runner script. |
| 241 | |
| 242 | include $(CLEAR_VARS) |
| 243 | LOCAL_SRC_FILES := run-core-tests |
| 244 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 245 | LOCAL_MODULE_TAGS := tests |
| 246 | LOCAL_MODULE := run-core-tests |
| 247 | include $(BUILD_PREBUILT) |
| 248 | |
| 249 | include $(CLEAR_VARS) |
| 250 | LOCAL_SRC_FILES := run-core-tests-on-ri |
| 251 | LOCAL_IS_HOST_MODULE := true |
| 252 | LOCAL_MODULE_CLASS := EXECUTABLES |
| 253 | LOCAL_MODULE_TAGS := tests |
| 254 | LOCAL_MODULE := run-core-tests-on-ri |
| 255 | include $(BUILD_PREBUILT) |
| 256 | |
| 257 | |
| 258 | # |
| 259 | # Build for the host. |
| 260 | # |
| 261 | |
| 262 | ifeq ($(WITH_HOST_DALVIK),true) |
| 263 | |
| 264 | # Definitions to make the core library. |
| 265 | |
| 266 | include $(CLEAR_VARS) |
| 267 | |
| 268 | LOCAL_SRC_FILES := $(core_src_files) |
| 269 | LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) |
| 270 | |
| 271 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 272 | LOCAL_DX_FLAGS := --core-library |
| 273 | |
| 274 | LOCAL_NO_EMMA_INSTRUMENT := true |
| 275 | LOCAL_NO_EMMA_COMPILE := true |
| 276 | |
| 277 | LOCAL_MODULE := core |
| 278 | |
| 279 | include $(BUILD_HOST_JAVA_LIBRARY) |
| 280 | |
| Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 281 | endif |