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 core_src_files := $(call all-main-java-files-under,dalvik dom json luni support xml) 54 core_resource_dirs := $(call all-core-resource-dirs,main) 55 test_resource_dirs := $(call all-core-resource-dirs,test) 56 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 62 local_javac_flags=-encoding UTF-8 63 #local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked 64 local_javac_flags+=-Xmaxwarns 9999999 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 78 LOCAL_JAVACFLAGS := $(local_javac_flags) 79 LOCAL_DX_FLAGS := --core-library 80 81 LOCAL_NO_EMMA_INSTRUMENT := true 82 LOCAL_NO_EMMA_COMPILE := true 83 LOCAL_MODULE_TAGS := optional 84 LOCAL_MODULE := core 85 86 include $(BUILD_JAVA_LIBRARY) 87 88 core-intermediates := ${intermediates} 89 90 91 # Make the core-tests library. 92 include $(CLEAR_VARS) 93 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml) 94 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 95 LOCAL_NO_STANDARD_LIBRARIES := true 96 LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit 97 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc mockwebserver 98 LOCAL_JAVACFLAGS := $(local_javac_flags) 99 LOCAL_MODULE_TAGS := tests 100 LOCAL_MODULE := core-tests 101 LOCAL_NO_EMMA_INSTRUMENT := true 102 LOCAL_NO_EMMA_COMPILE := true 103 include $(BUILD_STATIC_JAVA_LIBRARY) 104 105 # This one's tricky. One of our tests needs to have a 106 # resource with a "#" in its name, but Perforce doesn't 107 # allow us to submit such a file. So we create it here 108 # on-the-fly. 109 TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/ 110 TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties 111 112 $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE): 113 @mkdir -p $(dir $@) 114 @echo "Hello, world!" > $@ 115 116 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)" 117 $(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE) 118 119 120 # 121 # Build for the host. 122 # 123 124 ifeq ($(WITH_HOST_DALVIK),true) 125 126 # Definitions to make the core library. 127 128 include $(CLEAR_VARS) 129 130 LOCAL_SRC_FILES := $(core_src_files) 131 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) 132 133 LOCAL_NO_STANDARD_LIBRARIES := true 134 LOCAL_JAVACFLAGS := $(local_javac_flags) 135 LOCAL_DX_FLAGS := --core-library 136 137 LOCAL_NO_EMMA_INSTRUMENT := true 138 LOCAL_NO_EMMA_COMPILE := true 139 LOCAL_BUILD_HOST_DEX := true 140 141 LOCAL_MODULE_TAGS := optional 142 LOCAL_MODULE := core-hostdex 143 144 include $(BUILD_HOST_JAVA_LIBRARY) 145 146 # Make the core-tests library. 147 include $(CLEAR_VARS) 148 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml) 149 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 150 LOCAL_NO_STANDARD_LIBRARIES := true 151 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex 152 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-hostdex 153 LOCAL_JAVACFLAGS := $(local_javac_flags) 154 LOCAL_MODULE_TAGS := tests 155 LOCAL_MODULE := core-tests-hostdex 156 LOCAL_NO_EMMA_INSTRUMENT := true 157 LOCAL_NO_EMMA_COMPILE := true 158 LOCAL_BUILD_HOST_DEX := true 159 include $(BUILD_HOST_JAVA_LIBRARY) 160 endif 161 162 # 163 # Local droiddoc for faster libcore testing 164 # 165 # 166 # Run with: 167 # m libcore-docs 168 # 169 # Main output: 170 # out/target/common/docs/libcore/reference/packages.html 171 # 172 # All text for proofreading (or running tools over): 173 # out/target/common/docs/libcore-proofread.txt 174 # 175 # TODO list of missing javadoc, etc: 176 # out/target/common/docs/libcore-docs-todo.html 177 # 178 # Rerun: 179 # rm -rf out/target/common/docs/libcore-timestamp && m libcore-docs 180 # 181 include $(CLEAR_VARS) 182 183 # for shared defintion of libcore_to_document 184 include $(LOCAL_PATH)/Docs.mk 185 186 LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH)) 187 # rerun doc generation without recompiling the java 188 LOCAL_JAVA_LIBRARIES:= 189 LOCAL_JAVACFLAGS := $(local_javac_flags) 190 LOCAL_MODULE_CLASS:=JAVA_LIBRARIES 191 192 LOCAL_MODULE := libcore 193 194 LOCAL_DROIDDOC_OPTIONS:= \ 195 -offlinemode \ 196 -title "libcore" \ 197 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \ 198 -todo ../$(LOCAL_MODULE)-docs-todo.html \ 199 -hdf android.whichdoc offline 200 201 LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk 202 203 include $(BUILD_DROIDDOC) 204