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