1 # -*- mode: makefile -*- 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 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). 39 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 $(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/test/java -name "*.java" 2> /dev/null))) 46 endef 47 48 define all-core-resource-dirs 49 $(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null) 50 endef 51 52 # The Java files and their associated resources. 53 common_core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni xml) 54 core_resource_dirs := $(call all-core-resource-dirs,main) 55 test_resource_dirs := $(call all-core-resource-dirs,test) 56 test_src_files := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml) 57 58 ifeq ($(EMMA_INSTRUMENT),true) 59 ifneq ($(EMMA_INSTRUMENT_STATIC),true) 60 common_core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated) 61 core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res 62 endif 63 endif 64 65 libart_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libart) 66 67 local_javac_flags=-encoding UTF-8 68 #local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked 69 local_javac_flags+=-Xmaxwarns 9999999 70 71 # 72 # Build for the target (device). 73 # 74 75 # Definitions to make the core library. 76 77 include $(CLEAR_VARS) 78 LOCAL_SRC_FILES := $(libart_core_src_files) 79 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) 80 LOCAL_NO_STANDARD_LIBRARIES := true 81 LOCAL_JAVACFLAGS := $(local_javac_flags) 82 LOCAL_DX_FLAGS := --core-library 83 LOCAL_MODULE_TAGS := optional 84 LOCAL_MODULE := core-libart 85 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 86 LOCAL_REQUIRED_MODULES := tzdata 87 include $(BUILD_JAVA_LIBRARY) 88 89 ifeq ($(LIBCORE_SKIP_TESTS),) 90 # Make the core-tests library. 91 include $(CLEAR_VARS) 92 LOCAL_SRC_FILES := $(test_src_files) 93 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 94 LOCAL_NO_STANDARD_LIBRARIES := true 95 LOCAL_JAVA_LIBRARIES := core-libart okhttp core-junit bouncycastle 96 LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests 97 LOCAL_JAVACFLAGS := $(local_javac_flags) 98 LOCAL_MODULE := core-tests 99 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 100 include $(BUILD_STATIC_JAVA_LIBRARY) 101 endif 102 103 ifeq ($(LIBCORE_SKIP_TESTS),) 104 # Make the core-tests-support library. 105 include $(CLEAR_VARS) 106 LOCAL_SRC_FILES := $(call all-test-java-files-under,support) 107 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 108 LOCAL_NO_STANDARD_LIBRARIES := true 109 LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle 110 LOCAL_JAVACFLAGS := $(local_javac_flags) 111 LOCAL_MODULE := core-tests-support 112 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 113 include $(BUILD_STATIC_JAVA_LIBRARY) 114 endif 115 116 ifeq ($(LIBCORE_SKIP_TESTS),) 117 # Make the jsr166-tests library. 118 include $(CLEAR_VARS) 119 LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests) 120 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 121 LOCAL_NO_STANDARD_LIBRARIES := true 122 LOCAL_JAVA_LIBRARIES := core-libart core-junit 123 LOCAL_JAVACFLAGS := $(local_javac_flags) 124 LOCAL_MODULE := jsr166-tests 125 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 126 include $(BUILD_STATIC_JAVA_LIBRARY) 127 endif 128 129 # This one's tricky. One of our tests needs to have a 130 # resource with a "#" in its name, but Perforce doesn't 131 # allow us to submit such a file. So we create it here 132 # on-the-fly. 133 TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/ 134 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties 135 136 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE): 137 @mkdir -p $(dir $@) 138 @echo "Hello, world!" > $@ 139 140 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)" 141 $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE) 142 143 144 # 145 # Build for the host. 146 # 147 148 include $(CLEAR_VARS) 149 LOCAL_SRC_FILES := $(call all-main-java-files-under, dex) 150 LOCAL_MODULE_TAGS := optional 151 LOCAL_MODULE := dex-host 152 include $(BUILD_HOST_JAVA_LIBRARY) 153 154 # Definitions to make the core library. 155 include $(CLEAR_VARS) 156 LOCAL_SRC_FILES := $(libart_core_src_files) 157 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) 158 LOCAL_NO_STANDARD_LIBRARIES := true 159 LOCAL_JAVACFLAGS := $(local_javac_flags) 160 LOCAL_DX_FLAGS := --core-library 161 LOCAL_MODULE_TAGS := optional 162 LOCAL_MODULE := core-libart-hostdex 163 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 164 LOCAL_REQUIRED_MODULES := tzdata-host 165 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 166 167 # Make the core-tests library. 168 ifeq ($(LIBCORE_SKIP_TESTS),) 169 include $(CLEAR_VARS) 170 LOCAL_SRC_FILES := $(test_src_files) 171 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 172 LOCAL_NO_STANDARD_LIBRARIES := true 173 LOCAL_JAVA_LIBRARIES := core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex 174 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host 175 LOCAL_JAVACFLAGS := $(local_javac_flags) 176 LOCAL_MODULE_TAGS := optional 177 LOCAL_MODULE := core-tests-hostdex 178 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 179 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 180 endif 181 182 # Make the core-tests-support library. 183 ifeq ($(LIBCORE_SKIP_TESTS),) 184 include $(CLEAR_VARS) 185 LOCAL_SRC_FILES := $(call all-test-java-files-under,support) 186 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 187 LOCAL_NO_STANDARD_LIBRARIES := true 188 LOCAL_JAVA_LIBRARIES := core-libart-hostdex core-junit-hostdex bouncycastle-hostdex 189 LOCAL_JAVACFLAGS := $(local_javac_flags) 190 LOCAL_MODULE_TAGS := optional 191 LOCAL_MODULE := core-tests-support-hostdex 192 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 193 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 194 endif 195 196 # 197 # Local droiddoc for faster libcore testing 198 # 199 # 200 # Run with: 201 # mm -j32 libcore-docs 202 # 203 # Main output: 204 # ../out/target/common/docs/libcore/reference/packages.html 205 # 206 # All text for proofreading (or running tools over): 207 # ../out/target/common/docs/libcore-proofread.txt 208 # 209 # TODO list of missing javadoc, etc: 210 # ../out/target/common/docs/libcore-docs-todo.html 211 # 212 # Rerun: 213 # rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs 214 # 215 include $(CLEAR_VARS) 216 217 # for shared defintion of libcore_to_document 218 include $(LOCAL_PATH)/Docs.mk 219 220 LOCAL_SRC_FILES := $(libcore_to_document) 221 # rerun doc generation without recompiling the java 222 LOCAL_JAVA_LIBRARIES:= 223 LOCAL_JAVACFLAGS := $(local_javac_flags) 224 LOCAL_MODULE_CLASS:=JAVA_LIBRARIES 225 226 LOCAL_MODULE := libcore 227 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 228 229 LOCAL_DROIDDOC_OPTIONS := \ 230 -offlinemode \ 231 -title "libcore" \ 232 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \ 233 -todo ../$(LOCAL_MODULE)-docs-todo.html \ 234 -hdf android.whichdoc offline 235 236 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk 237 238 include $(BUILD_DROIDDOC) 239