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 |
Brian Carlstrom | 302e330 | 2011-03-01 23:59:06 -0800 | [diff] [blame^] | 45 | $(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/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. |
Jesse Wilson | e590b9c | 2011-01-13 17:20:50 -0800 | [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 | |
Jesse Wilson | 7898a91 | 2010-09-13 15:42:41 -0700 | [diff] [blame] | 57 | ifeq ($(EMMA_INSTRUMENT),true) |
| 58 | core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated) |
| 59 | core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res |
| 60 | endif |
| 61 | |
Elliott Hughes | 48d0b3f | 2010-12-14 09:48:52 -0800 | [diff] [blame] | 62 | local_javac_flags=-encoding UTF-8 |
| 63 | #local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked |
| 64 | local_javac_flags+=-Xmaxwarns 9999999 |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 65 | |
| 66 | # |
| 67 | # Build for the target (device). |
| 68 | # |
| 69 | |
| 70 | # Definitions to make the core library. |
| 71 | |
| 72 | include $(CLEAR_VARS) |
| 73 | |
| 74 | LOCAL_SRC_FILES := $(core_src_files) |
| 75 | LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) |
| 76 | |
| 77 | LOCAL_NO_STANDARD_LIBRARIES := true |
Elliott Hughes | 48d0b3f | 2010-12-14 09:48:52 -0800 | [diff] [blame] | 78 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 79 | LOCAL_DX_FLAGS := --core-library |
| 80 | |
| 81 | LOCAL_NO_EMMA_INSTRUMENT := true |
| 82 | LOCAL_NO_EMMA_COMPILE := true |
Jesse Wilson | 53fbc0a | 2010-09-16 15:46:05 -0700 | [diff] [blame] | 83 | LOCAL_MODULE_TAGS := optional |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 84 | LOCAL_MODULE := core |
| 85 | |
| 86 | include $(BUILD_JAVA_LIBRARY) |
| 87 | |
| 88 | core-intermediates := ${intermediates} |
| 89 | |
| 90 | |
Jesse Wilson | 32cfe95 | 2010-05-04 16:36:03 -0700 | [diff] [blame] | 91 | # Make core-junit |
| 92 | include $(CLEAR_VARS) |
| 93 | LOCAL_SRC_FILES := $(call all-main-java-files-under,junit) |
| 94 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 95 | LOCAL_JAVA_LIBRARIES := core |
Elliott Hughes | d610834 | 2011-02-22 10:13:54 -0800 | [diff] [blame] | 96 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Jesse Wilson | 53fbc0a | 2010-09-16 15:46:05 -0700 | [diff] [blame] | 97 | LOCAL_MODULE_TAGS := optional |
Jesse Wilson | 32cfe95 | 2010-05-04 16:36:03 -0700 | [diff] [blame] | 98 | LOCAL_MODULE := core-junit |
| 99 | include $(BUILD_JAVA_LIBRARY) |
| 100 | |
Jesse Wilson | 1708c11 | 2010-05-13 15:50:15 -0700 | [diff] [blame] | 101 | # Make core-junitrunner |
| 102 | include $(CLEAR_VARS) |
| 103 | LOCAL_SRC_FILES := $(call all-test-java-files-under,junit) |
| 104 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 105 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 106 | LOCAL_JAVA_LIBRARIES := core core-junit |
| 107 | LOCAL_DX_FLAGS := --core-library |
Elliott Hughes | d610834 | 2011-02-22 10:13:54 -0800 | [diff] [blame] | 108 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Jesse Wilson | 1708c11 | 2010-05-13 15:50:15 -0700 | [diff] [blame] | 109 | LOCAL_MODULE_TAGS := tests |
| 110 | LOCAL_MODULE := core-junitrunner |
| 111 | include $(BUILD_JAVA_LIBRARY) |
Elliott Hughes | 7ee3a06 | 2010-02-18 17:20:15 -0800 | [diff] [blame] | 112 | |
Brian Carlstrom | 302e330 | 2011-03-01 23:59:06 -0800 | [diff] [blame^] | 113 | # Make the sqlite JDBC driver. |
Elliott Hughes | b9cf9cb | 2010-02-26 14:46:53 -0800 | [diff] [blame] | 114 | include $(CLEAR_VARS) |
| 115 | LOCAL_SRC_FILES := $(call all-main-java-files-under,sqlite-jdbc) |
| 116 | LOCAL_NO_STANDARD_LIBRARIES := true |
| 117 | LOCAL_JAVA_LIBRARIES := core |
Elliott Hughes | d610834 | 2011-02-22 10:13:54 -0800 | [diff] [blame] | 118 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Jesse Wilson | 53fbc0a | 2010-09-16 15:46:05 -0700 | [diff] [blame] | 119 | LOCAL_MODULE_TAGS := optional |
Elliott Hughes | b9cf9cb | 2010-02-26 14:46:53 -0800 | [diff] [blame] | 120 | LOCAL_MODULE := sqlite-jdbc |
| 121 | include $(BUILD_JAVA_LIBRARY) |
| 122 | |
Brian Carlstrom | 302e330 | 2011-03-01 23:59:06 -0800 | [diff] [blame^] | 123 | # Make the core-tests library. |
Brian Carlstrom | 51ee38b | 2010-07-23 15:57:52 -0700 | [diff] [blame] | 124 | include $(CLEAR_VARS) |
Brian Carlstrom | 302e330 | 2011-03-01 23:59:06 -0800 | [diff] [blame^] | 125 | LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml) |
Brian Carlstrom | 51ee38b | 2010-07-23 15:57:52 -0700 | [diff] [blame] | 126 | LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) |
| 127 | LOCAL_NO_STANDARD_LIBRARIES := true |
Brian Carlstrom | 302e330 | 2011-03-01 23:59:06 -0800 | [diff] [blame^] | 128 | LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit core-junitrunner sqlite-jdbc |
Jesse Wilson | d5d3526 | 2010-05-12 23:56:14 -0700 | [diff] [blame] | 129 | LOCAL_DX_FLAGS := --core-library |
Elliott Hughes | d610834 | 2011-02-22 10:13:54 -0800 | [diff] [blame] | 130 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Jesse Wilson | d5d3526 | 2010-05-12 23:56:14 -0700 | [diff] [blame] | 131 | LOCAL_MODULE_TAGS := tests |
Brian Carlstrom | b094af3 | 2010-05-28 17:37:37 -0700 | [diff] [blame] | 132 | LOCAL_MODULE := core-tests |
Guang Zhu | 83244e5 | 2010-06-11 18:48:30 -0700 | [diff] [blame] | 133 | LOCAL_NO_EMMA_INSTRUMENT := true |
| 134 | LOCAL_NO_EMMA_COMPILE := true |
Jesse Wilson | 706d535 | 2010-06-08 17:20:09 -0700 | [diff] [blame] | 135 | include $(BUILD_STATIC_JAVA_LIBRARY) |
| 136 | |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 137 | # This one's tricky. One of our tests needs to have a |
| 138 | # resource with a "#" in its name, but Perforce doesn't |
| 139 | # allow us to submit such a file. So we create it here |
| 140 | # on-the-fly. |
| 141 | TMP_RESOURCE_DIR := $(OUT_DIR)/tmp/ |
| 142 | TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties |
| 143 | |
| 144 | $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE): |
| 145 | @mkdir -p $(dir $@) |
| 146 | @echo "Hello, world!" > $@ |
| 147 | |
| 148 | $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C $(TMP_RESOURCE_DIR) $(TMP_RESOURCE_FILE) |
| 149 | $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE) |
| 150 | |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 151 | |
| 152 | # |
| 153 | # Build for the host. |
| 154 | # |
| 155 | |
| 156 | ifeq ($(WITH_HOST_DALVIK),true) |
| 157 | |
| 158 | # Definitions to make the core library. |
| 159 | |
| 160 | include $(CLEAR_VARS) |
| 161 | |
| 162 | LOCAL_SRC_FILES := $(core_src_files) |
| 163 | LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) |
| 164 | |
| 165 | LOCAL_NO_STANDARD_LIBRARIES := true |
Elliott Hughes | 48d0b3f | 2010-12-14 09:48:52 -0800 | [diff] [blame] | 166 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 167 | LOCAL_DX_FLAGS := --core-library |
| 168 | |
| 169 | LOCAL_NO_EMMA_INSTRUMENT := true |
| 170 | LOCAL_NO_EMMA_COMPILE := true |
Jesse Wilson | 7898a91 | 2010-09-13 15:42:41 -0700 | [diff] [blame] | 171 | LOCAL_BUILD_HOST_DEX := true |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 172 | |
Jean-Baptiste Queru | f267896 | 2010-09-14 13:50:14 -0700 | [diff] [blame] | 173 | LOCAL_MODULE_TAGS := optional |
Jesse Wilson | 53fbc0a | 2010-09-16 15:46:05 -0700 | [diff] [blame] | 174 | LOCAL_MODULE := core-hostdex |
Dan Bornstein | 6ac43c2 | 2009-10-24 15:33:49 -0700 | [diff] [blame] | 175 | |
| 176 | include $(BUILD_HOST_JAVA_LIBRARY) |
| 177 | |
Elliott Hughes | 67cc34b | 2010-02-19 22:14:19 -0800 | [diff] [blame] | 178 | endif |
Brian Carlstrom | dc3c152 | 2011-01-05 17:48:05 -0800 | [diff] [blame] | 179 | |
| 180 | # |
| 181 | # Local droiddoc for faster libcore testing |
| 182 | # |
| 183 | # |
| 184 | # Run with: |
| 185 | # m libcore-docs |
| 186 | # |
| 187 | # Main output: |
| 188 | # out/target/common/docs/libcore/reference/packages.html |
| 189 | # |
| 190 | # All text for proofreading (or running tools over): |
| 191 | # out/target/common/docs/libcore-proofread.txt |
| 192 | # |
| 193 | # TODO list of missing javadoc, etc: |
| 194 | # out/target/common/docs/libcore-docs-todo.html |
| 195 | # |
| 196 | # Rerun: |
| 197 | # rm -rf out/target/common/docs/libcore-timestamp && m libcore-docs |
| 198 | # |
| 199 | include $(CLEAR_VARS) |
| 200 | |
| 201 | # for shared defintion of libcore_to_document |
| 202 | include $(LOCAL_PATH)/Docs.mk |
| 203 | |
| 204 | LOCAL_SRC_FILES:=$(call find-other-java-files, $(libcore_to_document)) |
| 205 | # rerun doc generation without recompiling the java |
| 206 | LOCAL_JAVA_LIBRARIES:= |
Elliott Hughes | d610834 | 2011-02-22 10:13:54 -0800 | [diff] [blame] | 207 | LOCAL_JAVACFLAGS := $(local_javac_flags) |
Brian Carlstrom | dc3c152 | 2011-01-05 17:48:05 -0800 | [diff] [blame] | 208 | LOCAL_MODULE_CLASS:=JAVA_LIBRARIES |
| 209 | |
| 210 | LOCAL_MODULE := libcore |
| 211 | |
| 212 | LOCAL_DROIDDOC_OPTIONS:= \ |
| 213 | -offlinemode \ |
| 214 | -title "libcore" \ |
| 215 | -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \ |
| 216 | -todo ../$(LOCAL_MODULE)-docs-todo.html \ |
| 217 | -hdf android.whichdoc offline |
| 218 | |
| 219 | LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk |
| 220 | |
| 221 | include $(BUILD_DROIDDOC) |