blob: 8337ab293d10882765c900f07fe26b7e67a3ecb3 [file] [log] [blame]
Elliott Hughes7ee3a062010-02-18 17:20:15 -08001# -*- mode: makefile -*-
Dan Bornstein6ac43c22009-10-24 15:33:49 -07002# 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 Wilsond5d35262010-05-12 23:56:14 -070024# 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 Bornstein6ac43c22009-10-24 15:33:49 -070039
Jesse Wilson32cfe952010-05-04 16:36:03 -070040define 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
Brian Carlstrom302e3302011-03-01 23:59:06 -080045$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/test/java -name "*.java" 2> /dev/null)))
Dan Bornstein6ac43c22009-10-24 15:33:49 -070046endef
47
Dan Bornstein6ac43c22009-10-24 15:33:49 -070048define all-core-resource-dirs
49$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
50endef
51
Jesse Wilsond5d35262010-05-12 23:56:14 -070052# The Java files and their associated resources.
Brian Carlstrom8ff94c72013-08-29 15:08:41 -070053common_core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni xml)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070054core_resource_dirs := $(call all-core-resource-dirs,main)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070055test_resource_dirs := $(call all-core-resource-dirs,test)
Narayan Kamath51525b52013-11-15 18:02:54 +000056test_src_files := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070057
Jesse Wilson7898a912010-09-13 15:42:41 -070058ifeq ($(EMMA_INSTRUMENT),true)
Ying Wangff053c32012-08-21 17:20:51 -070059ifneq ($(EMMA_INSTRUMENT_STATIC),true)
Brian Carlstrom3711c212013-06-25 15:59:29 -070060 common_core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
Jesse Wilson7898a912010-09-13 15:42:41 -070061 core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res
62endif
Ying Wangff053c32012-08-21 17:20:51 -070063endif
Jesse Wilson7898a912010-09-13 15:42:41 -070064
Brian Carlstrom3711c212013-06-25 15:59:29 -070065libdvm_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libdvm)
66libart_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libart)
67
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080068local_javac_flags=-encoding UTF-8
69#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
70local_javac_flags+=-Xmaxwarns 9999999
Dan Bornstein6ac43c22009-10-24 15:33:49 -070071
72#
73# Build for the target (device).
74#
75
76# Definitions to make the core library.
77
78include $(CLEAR_VARS)
Brian Carlstrom3711c212013-06-25 15:59:29 -070079LOCAL_SRC_FILES := $(libdvm_core_src_files)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070080LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070081LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080082LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070083LOCAL_DX_FLAGS := --core-library
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070084LOCAL_MODULE_TAGS := optional
Dan Bornstein6ac43c22009-10-24 15:33:49 -070085LOCAL_MODULE := core
Elliott Hughes73d3e262012-08-28 17:56:09 -070086LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Elliott Hughes055fe872012-10-18 11:26:48 -070087LOCAL_REQUIRED_MODULES := tzdata
Dan Bornstein6ac43c22009-10-24 15:33:49 -070088include $(BUILD_JAVA_LIBRARY)
89
Brian Carlstrom3711c212013-06-25 15:59:29 -070090include $(CLEAR_VARS)
91LOCAL_SRC_FILES := $(libart_core_src_files)
92LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
93LOCAL_NO_STANDARD_LIBRARIES := true
94LOCAL_JAVACFLAGS := $(local_javac_flags)
95LOCAL_DX_FLAGS := --core-library
96LOCAL_MODULE_TAGS := optional
97LOCAL_MODULE := core-libart
98LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
99LOCAL_REQUIRED_MODULES := tzdata
Brian Carlstrom7aaf90e2013-12-11 11:01:55 -0800100# Should not be dex-preopted as it isn't really a Dalvik boot jar or a
101# regular java library, but part of the image for ART.
102LOCAL_DEX_PREOPT := false
Brian Carlstrom3711c212013-06-25 15:59:29 -0700103include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700104
Kenny Root38375a42013-04-23 15:50:31 -0700105ifeq ($(LIBCORE_SKIP_TESTS),)
106# Make the core-tests library.
107include $(CLEAR_VARS)
Narayan Kamath51525b52013-11-15 18:02:54 +0000108LOCAL_SRC_FILES := $(test_src_files)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700109LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
110LOCAL_NO_STANDARD_LIBRARIES := true
Kenny Root55dcd972013-08-29 14:31:12 -0700111LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit okhttp
Kenny Rootba07db52013-08-29 13:40:35 -0700112LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests okhttp-tests
Elliott Hughesd6108342011-02-22 10:13:54 -0800113LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromb094af32010-05-28 17:37:37 -0700114LOCAL_MODULE := core-tests
Elliott Hughes73d3e262012-08-28 17:56:09 -0700115LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Jesse Wilson706d5352010-06-08 17:20:09 -0700116include $(BUILD_STATIC_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700117endif
Jesse Wilson706d5352010-06-08 17:20:09 -0700118
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700119ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Rootb397b192013-08-29 14:24:47 -0700120# Make the core-tests-support library.
121include $(CLEAR_VARS)
122LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
123LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
124LOCAL_NO_STANDARD_LIBRARIES := true
125LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
Kenny Rootb397b192013-08-29 14:24:47 -0700126LOCAL_JAVACFLAGS := $(local_javac_flags)
Kenny Rootb397b192013-08-29 14:24:47 -0700127LOCAL_MODULE := core-tests-support
128LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
129include $(BUILD_STATIC_JAVA_LIBRARY)
130endif
131
132ifeq ($(LIBCORE_SKIP_TESTS),)
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700133# Make the jsr166-tests library.
134include $(CLEAR_VARS)
135LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests)
136LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
137LOCAL_NO_STANDARD_LIBRARIES := true
138LOCAL_JAVA_LIBRARIES := core core-junit
139LOCAL_JAVACFLAGS := $(local_javac_flags)
140LOCAL_MODULE := jsr166-tests
141LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
142include $(BUILD_STATIC_JAVA_LIBRARY)
143endif
144
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700145# This one's tricky. One of our tests needs to have a
146# resource with a "#" in its name, but Perforce doesn't
147# allow us to submit such a file. So we create it here
148# on-the-fly.
Ying Wang43624e72011-06-06 15:34:59 -0700149TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700150TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
151
152$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
153 @mkdir -p $(dir $@)
154 @echo "Hello, world!" > $@
155
Ying Wang43624e72011-06-06 15:34:59 -0700156$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700157$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
158
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700159
160#
161# Build for the host.
162#
163
Tsu Chiang Chuang25963ae2013-07-23 16:39:20 -0700164include $(CLEAR_VARS)
165LOCAL_SRC_FILES := $(call all-main-java-files-under, dex)
166LOCAL_MODULE_TAGS := optional
167LOCAL_MODULE := dex-host
168include $(BUILD_HOST_JAVA_LIBRARY)
169
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700170ifeq ($(WITH_HOST_DALVIK),true)
171
172 # Definitions to make the core library.
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700173 include $(CLEAR_VARS)
Brian Carlstrom3711c212013-06-25 15:59:29 -0700174 LOCAL_SRC_FILES := $(libdvm_core_src_files)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700175 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700176 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800177 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700178 LOCAL_DX_FLAGS := --core-library
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700179 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700180 LOCAL_MODULE := core-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700181 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Elliott Hughes055fe872012-10-18 11:26:48 -0700182 LOCAL_REQUIRED_MODULES := tzdata-host
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000183 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700184
Brian Carlstrom3711c212013-06-25 15:59:29 -0700185 include $(CLEAR_VARS)
186 LOCAL_SRC_FILES := $(libart_core_src_files)
187 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
188 LOCAL_NO_STANDARD_LIBRARIES := true
189 LOCAL_JAVACFLAGS := $(local_javac_flags)
190 LOCAL_DX_FLAGS := --core-library
Brian Carlstrom3711c212013-06-25 15:59:29 -0700191 LOCAL_MODULE_TAGS := optional
192 LOCAL_MODULE := core-libart-hostdex
193 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
194 LOCAL_REQUIRED_MODULES := tzdata-host
Brian Carlstrom7aaf90e2013-12-11 11:01:55 -0800195 # Should not be dex-preopted as it isn't really a Dalvik boot jar or a
196 # regular java library, but part of the image for ART.
197 LOCAL_DEX_PREOPT := false
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000198 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700199
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800200 # Make the core-tests library.
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700201 ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800202 include $(CLEAR_VARS)
Narayan Kamath51525b52013-11-15 18:02:54 +0000203 LOCAL_SRC_FILES := $(test_src_files)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800204 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000205 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex okhttp-hostdex
Brian Carlstrom22a12c92013-01-17 16:18:31 -0800206 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800207 LOCAL_JAVACFLAGS := $(local_javac_flags)
Ying Wange79ac582012-08-23 11:25:27 -0700208 LOCAL_MODULE_TAGS := optional
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800209 LOCAL_MODULE := core-tests-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700210 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000211 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700212 endif
Kenny Rootba07db52013-08-29 13:40:35 -0700213
214 # Make the core-tests-support library.
215 ifeq ($(LIBCORE_SKIP_TESTS),)
216 include $(CLEAR_VARS)
217 LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
218 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000219 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-junit-hostdex
Kenny Rootba07db52013-08-29 13:40:35 -0700220 LOCAL_JAVACFLAGS := $(local_javac_flags)
221 LOCAL_MODULE_TAGS := optional
222 LOCAL_MODULE := core-tests-support-hostdex
223 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000224 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Kenny Rootba07db52013-08-29 13:40:35 -0700225 endif
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800226endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800227
228#
229# Local droiddoc for faster libcore testing
230#
231#
232# Run with:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800233# mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800234#
235# Main output:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800236# ../out/target/common/docs/libcore/reference/packages.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800237#
238# All text for proofreading (or running tools over):
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800239# ../out/target/common/docs/libcore-proofread.txt
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800240#
241# TODO list of missing javadoc, etc:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800242# ../out/target/common/docs/libcore-docs-todo.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800243#
244# Rerun:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800245# rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800246#
247include $(CLEAR_VARS)
248
249# for shared defintion of libcore_to_document
250include $(LOCAL_PATH)/Docs.mk
251
Ying Wang21ac42d2013-12-04 15:54:36 -0800252LOCAL_SRC_FILES := $(libcore_to_document)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800253# rerun doc generation without recompiling the java
254LOCAL_JAVA_LIBRARIES:=
Elliott Hughesd6108342011-02-22 10:13:54 -0800255LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800256LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
257
258LOCAL_MODULE := libcore
Elliott Hughes73d3e262012-08-28 17:56:09 -0700259LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800260
Elliott Hughesb9863272012-11-08 14:28:29 -0800261LOCAL_DROIDDOC_OPTIONS := \
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800262 -offlinemode \
263 -title "libcore" \
264 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
265 -todo ../$(LOCAL_MODULE)-docs-todo.html \
266 -hdf android.whichdoc offline
267
268LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
269
270include $(BUILD_DROIDDOC)