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 40define all-main-java-files-under 41$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/main/java -name "*.java" 2> /dev/null))) 42endef 43 44define all-test-java-files-under 45$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/test/java -name "*.java" 2> /dev/null))) 46endef 47 48define all-core-resource-dirs 49$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null) 50endef 51 52# The Java files and their associated resources. 53common_core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni xml) 54core_resource_dirs := $(call all-core-resource-dirs,main) 55test_resource_dirs := $(call all-core-resource-dirs,test) 56test_src_files := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml) 57 58ifeq ($(EMMA_INSTRUMENT),true) 59ifneq ($(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 62endif 63endif 64 65libart_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libart) 66 67local_javac_flags=-encoding UTF-8 68#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked 69local_javac_flags+=-Xmaxwarns 9999999 70 71# 72# Build for the target (device). 73# 74 75# Definitions to make the core library. 76 77include $(CLEAR_VARS) 78LOCAL_SRC_FILES := $(libart_core_src_files) 79LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) 80LOCAL_NO_STANDARD_LIBRARIES := true 81LOCAL_JAVACFLAGS := $(local_javac_flags) 82LOCAL_DX_FLAGS := --core-library 83LOCAL_MODULE_TAGS := optional 84LOCAL_MODULE := core-libart 85LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 86LOCAL_REQUIRED_MODULES := tzdata 87include $(BUILD_JAVA_LIBRARY) 88 89ifeq ($(LIBCORE_SKIP_TESTS),) 90# Make the core-tests library. 91include $(CLEAR_VARS) 92LOCAL_SRC_FILES := $(test_src_files) 93LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 94LOCAL_NO_STANDARD_LIBRARIES := true 95LOCAL_JAVA_LIBRARIES := core-libart okhttp core-junit bouncycastle 96LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests 97LOCAL_JAVACFLAGS := $(local_javac_flags) 98LOCAL_MODULE := core-tests 99LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 100include $(BUILD_STATIC_JAVA_LIBRARY) 101endif 102 103ifeq ($(LIBCORE_SKIP_TESTS),) 104# Make the core-tests-support library. 105include $(CLEAR_VARS) 106LOCAL_SRC_FILES := $(call all-test-java-files-under,support) 107LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 108LOCAL_NO_STANDARD_LIBRARIES := true 109LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle 110LOCAL_JAVACFLAGS := $(local_javac_flags) 111LOCAL_MODULE := core-tests-support 112LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 113include $(BUILD_STATIC_JAVA_LIBRARY) 114endif 115 116ifeq ($(LIBCORE_SKIP_TESTS),) 117# Make the jsr166-tests library. 118include $(CLEAR_VARS) 119LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests) 120LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs) 121LOCAL_NO_STANDARD_LIBRARIES := true 122LOCAL_JAVA_LIBRARIES := core-libart core-junit 123LOCAL_JAVACFLAGS := $(local_javac_flags) 124LOCAL_MODULE := jsr166-tests 125LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 126include $(BUILD_STATIC_JAVA_LIBRARY) 127endif 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. 133TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/ 134TMP_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 148include $(CLEAR_VARS) 149LOCAL_SRC_FILES := $(call all-main-java-files-under, dex) 150LOCAL_MODULE_TAGS := optional 151LOCAL_MODULE := dex-host 152include $(BUILD_HOST_JAVA_LIBRARY) 153 154# Definitions to make the core library. 155include $(CLEAR_VARS) 156LOCAL_SRC_FILES := $(libart_core_src_files) 157LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) 158LOCAL_NO_STANDARD_LIBRARIES := true 159LOCAL_JAVACFLAGS := $(local_javac_flags) 160LOCAL_DX_FLAGS := --core-library 161LOCAL_MODULE_TAGS := optional 162LOCAL_MODULE := core-libart-hostdex 163LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 164LOCAL_REQUIRED_MODULES := tzdata-host 165include $(BUILD_HOST_DALVIK_JAVA_LIBRARY) 166 167# Make the core-tests library. 168ifeq ($(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) 180endif 181 182# Make the core-tests-support library. 183ifeq ($(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) 194endif 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# 215include $(CLEAR_VARS) 216 217# for shared defintion of libcore_to_document 218include $(LOCAL_PATH)/Docs.mk 219 220LOCAL_SRC_FILES := $(libcore_to_document) 221# rerun doc generation without recompiling the java 222LOCAL_JAVA_LIBRARIES:= 223LOCAL_JAVACFLAGS := $(local_javac_flags) 224LOCAL_MODULE_CLASS:=JAVA_LIBRARIES 225 226LOCAL_MODULE := libcore 227LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk 228 229LOCAL_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 236LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk 237 238include $(BUILD_DROIDDOC) 239