blob: 906916de388a9824080f9cb4bbee1987b83b151c [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
Narayan Kamath0a57ec22015-07-24 14:34:02 +010040include $(LOCAL_PATH)/openjdk_java_files.mk
41include $(LOCAL_PATH)/non_openjdk_java_files.mk
Jesse Wilson32cfe952010-05-04 16:36:03 -070042
43define all-test-java-files-under
Przemyslaw Szczepaniakebe4f192015-07-09 13:19:15 +010044$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && (find $(dir)/src/test/java -name "*.java" 2> /dev/null) | grep -v -f java_tests_blacklist)))
Dan Bornstein6ac43c22009-10-24 15:33:49 -070045endef
46
Dan Bornstein6ac43c22009-10-24 15:33:49 -070047define all-core-resource-dirs
48$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
49endef
50
Jesse Wilsond5d35262010-05-12 23:56:14 -070051# The Java files and their associated resources.
Narayan Kamath29c564f2015-07-30 12:05:42 +010052core_resource_dirs := \
53 luni/src/main/java \
54 ojluni/src/main/resources/
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)
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +000060 nojcore_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
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080065local_javac_flags=-encoding UTF-8
66#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
67local_javac_flags+=-Xmaxwarns 9999999
Dan Bornstein6ac43c22009-10-24 15:33:49 -070068
Narayan Kamath1a0f1842015-09-07 12:59:53 +010069
Dan Bornstein6ac43c22009-10-24 15:33:49 -070070#
Narayan Kamathf37f7812015-04-01 09:34:24 +010071# ICU4J related rules.
72#
Neil Fuller72802992015-10-05 15:39:53 +010073# We compile android_icu4j along with core-libart because we're implementing parts of core-libart
74# in terms of android_icu4j.
75android_icu4j_root := ../external/icu/android_icu4j/
Neil Fullera3156912015-10-30 15:52:28 +000076android_icu4j_src_files := $(call all-java-files-under,$(android_icu4j_root)/src/main)
Neil Fuller72802992015-10-05 15:39:53 +010077android_icu4j_resource_dirs := $(android_icu4j_root)/resources
Narayan Kamathf37f7812015-04-01 09:34:24 +010078
79#
Dan Bornstein6ac43c22009-10-24 15:33:49 -070080# Build for the target (device).
81#
82
Dan Bornstein6ac43c22009-10-24 15:33:49 -070083include $(CLEAR_VARS)
Przemyslaw Szczepaniak70b617f2015-11-20 12:01:45 +000084LOCAL_SRC_FILES := $(openjdk_java_files) $(non_openjdk_java_files) $(android_icu4j_src_files)
Neil Fuller72802992015-10-05 15:39:53 +010085LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) $(android_icu4j_resource_dirs)
Brian Carlstrom3711c212013-06-25 15:59:29 -070086LOCAL_NO_STANDARD_LIBRARIES := true
87LOCAL_JAVACFLAGS := $(local_javac_flags)
88LOCAL_DX_FLAGS := --core-library
89LOCAL_MODULE_TAGS := optional
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +000090LOCAL_MODULE := core-all
Brian Carlstrom3711c212013-06-25 15:59:29 -070091LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
92LOCAL_REQUIRED_MODULES := tzdata
Piotr Jastrzebski5c3c9df2015-04-20 10:56:00 +010093LOCAL_CORE_LIBRARY := true
Narayan Kamath0ebbfbd2015-07-30 15:01:19 +010094LOCAL_UNINSTALLABLE_MODULE := true
Brian Carlstrom3711c212013-06-25 15:59:29 -070095include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070096
Narayan Kamathf41eec82015-11-20 12:39:23 +000097include $(CLEAR_VARS)
Narayan Kamath0a57ec22015-07-24 14:34:02 +010098LOCAL_SRC_FILES := $(openjdk_java_files)
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +000099LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
Narayan Kamathf41eec82015-11-20 12:39:23 +0000100LOCAL_NO_STANDARD_LIBRARIES := true
101LOCAL_JAVACFLAGS := $(local_javac_flags)
102LOCAL_DX_FLAGS := --core-library
103LOCAL_MODULE_TAGS := optional
104LOCAL_MODULE := core-oj
Narayan Kamathf41eec82015-11-20 12:39:23 +0000105LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Narayan Kamath09f993b2015-11-18 09:28:42 +0000106LOCAL_JAVA_LIBRARIES := core-all
Narayan Kamathf41eec82015-11-20 12:39:23 +0000107LOCAL_REQUIRED_MODULES := tzdata
108LOCAL_CORE_LIBRARY := true
Piotr Jastrzebski983b2c62015-04-24 09:13:00 +0100109LOCAL_REQUIRED_MODULES := currency.data-target
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000110include $(BUILD_JAVA_LIBRARY)
111
112# Definitions to make the core library.
113include $(CLEAR_VARS)
Przemyslaw Szczepaniak70b617f2015-11-20 12:01:45 +0000114LOCAL_SRC_FILES := $(non_openjdk_java_files) $(android_icu4j_src_files)
Narayan Kamatha61daf42015-11-24 13:31:36 +0000115LOCAL_JAVA_RESOURCE_DIRS := $(android_icu4j_resource_dirs)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700116LOCAL_NO_STANDARD_LIBRARIES := true
117LOCAL_JAVACFLAGS := $(local_javac_flags)
118LOCAL_DX_FLAGS := --core-library
119LOCAL_MODULE_TAGS := optional
120LOCAL_MODULE := core-libart
Narayan Kamath647e4a62015-10-02 10:22:16 +0100121LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/JavaLibrary.mk
Narayan Kamath09f993b2015-11-18 09:28:42 +0000122LOCAL_JAVA_LIBRARIES := core-all
Narayan Kamathb9853192015-09-02 13:38:48 +0100123LOCAL_CORE_LIBRARY := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700124LOCAL_REQUIRED_MODULES := tzdata
Narayan Kamathf41eec82015-11-20 12:39:23 +0000125include $(BUILD_JAVA_LIBRARY)
126
Kenny Root38375a42013-04-23 15:50:31 -0700127ifeq ($(LIBCORE_SKIP_TESTS),)
128# Make the core-tests library.
129include $(CLEAR_VARS)
Narayan Kamath51525b52013-11-15 18:02:54 +0000130LOCAL_SRC_FILES := $(test_src_files)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700131LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
132LOCAL_NO_STANDARD_LIBRARIES := true
Przemyslaw Szczepaniak70b617f2015-11-20 12:01:45 +0000133LOCAL_JAVA_LIBRARIES := core-oj core-libart okhttp core-junit bouncycastle mockito-target
Neil Fuller62fba1e2014-05-29 11:52:06 +0100134LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests
Elliott Hughesd6108342011-02-22 10:13:54 -0800135LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromb094af32010-05-28 17:37:37 -0700136LOCAL_MODULE := core-tests
Elliott Hughes73d3e262012-08-28 17:56:09 -0700137LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Jesse Wilson706d5352010-06-08 17:20:09 -0700138include $(BUILD_STATIC_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700139endif
Jesse Wilson706d5352010-06-08 17:20:09 -0700140
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700141ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Rootb397b192013-08-29 14:24:47 -0700142# Make the core-tests-support library.
143include $(CLEAR_VARS)
144LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
145LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
146LOCAL_NO_STANDARD_LIBRARIES := true
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000147LOCAL_JAVA_LIBRARIES := core-oj core-libart core-junit bouncycastle
Kenny Rootb397b192013-08-29 14:24:47 -0700148LOCAL_JAVACFLAGS := $(local_javac_flags)
Kenny Rootb397b192013-08-29 14:24:47 -0700149LOCAL_MODULE := core-tests-support
150LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
151include $(BUILD_STATIC_JAVA_LIBRARY)
152endif
153
154ifeq ($(LIBCORE_SKIP_TESTS),)
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700155# Make the jsr166-tests library.
156include $(CLEAR_VARS)
157LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests)
158LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
159LOCAL_NO_STANDARD_LIBRARIES := true
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000160LOCAL_JAVA_LIBRARIES := core-oj core-libart core-junit
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700161LOCAL_JAVACFLAGS := $(local_javac_flags)
162LOCAL_MODULE := jsr166-tests
163LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
164include $(BUILD_STATIC_JAVA_LIBRARY)
165endif
166
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700167#
168# Build for the host.
169#
170
Elliott Hughese983a0b2015-01-16 10:47:17 -0800171ifeq ($(HOST_OS),linux)
172
Ian Rogers3deabd22014-05-23 15:12:42 -0700173include $(CLEAR_VARS)
Narayan Kamath0a57ec22015-07-24 14:34:02 +0100174LOCAL_SRC_FILES := $(call all-java-files-under, dex/src/main)
Tsu Chiang Chuang25963ae2013-07-23 16:39:20 -0700175LOCAL_MODULE_TAGS := optional
176LOCAL_MODULE := dex-host
177include $(BUILD_HOST_JAVA_LIBRARY)
178
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000179include $(CLEAR_VARS)
Przemyslaw Szczepaniak70b617f2015-11-20 12:01:45 +0000180LOCAL_SRC_FILES := $(non_openjdk_java_files) $(openjdk_java_files) $(android_icu4j_src_files)
Przemyslaw Szczepaniake3b37c22015-09-28 16:24:00 +0100181LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
Ian Rogers3deabd22014-05-23 15:12:42 -0700182LOCAL_NO_STANDARD_LIBRARIES := true
183LOCAL_JAVACFLAGS := $(local_javac_flags)
184LOCAL_DX_FLAGS := --core-library
185LOCAL_MODULE_TAGS := optional
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000186LOCAL_MODULE := core-all-hostdex
Ian Rogers3deabd22014-05-23 15:12:42 -0700187LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
188LOCAL_REQUIRED_MODULES := tzdata-host
Piotr Jastrzebski5c3c9df2015-04-20 10:56:00 +0100189LOCAL_CORE_LIBRARY := true
Narayan Kamath0ebbfbd2015-07-30 15:01:19 +0100190LOCAL_UNINSTALLABLE_MODULE := true
Ian Rogers3deabd22014-05-23 15:12:42 -0700191include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700192
Narayan Kamathf41eec82015-11-20 12:39:23 +0000193include $(CLEAR_VARS)
Narayan Kamath0a57ec22015-07-24 14:34:02 +0100194LOCAL_SRC_FILES := $(openjdk_java_files)
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000195LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
Narayan Kamathf41eec82015-11-20 12:39:23 +0000196LOCAL_NO_STANDARD_LIBRARIES := true
197LOCAL_JAVACFLAGS := $(local_javac_flags)
198LOCAL_DX_FLAGS := --core-library
199LOCAL_MODULE_TAGS := optional
200LOCAL_MODULE := core-oj-hostdex
201LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000202LOCAL_JAVA_LIBRARIES := core-all-hostdex
Narayan Kamathf41eec82015-11-20 12:39:23 +0000203LOCAL_REQUIRED_MODULES := tzdata-host
Narayan Kamathf41eec82015-11-20 12:39:23 +0000204LOCAL_CORE_LIBRARY := true
205LOCAL_REQUIRED_MODULES := currency.data-host
206include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
207
Kenny Rootba07db52013-08-29 13:40:35 -0700208# Definitions to make the core library.
209include $(CLEAR_VARS)
Przemyslaw Szczepaniak70b617f2015-11-20 12:01:45 +0000210LOCAL_SRC_FILES := $(non_openjdk_java_files) $(android_icu4j_src_files)
Narayan Kamatha61daf42015-11-24 13:31:36 +0000211LOCAL_JAVA_RESOURCE_DIRS := $(android_icu4j_resource_dirs)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800212LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughese983a0b2015-01-16 10:47:17 -0800213LOCAL_JAVACFLAGS := $(local_javac_flags)
214LOCAL_DX_FLAGS := --core-library
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800215LOCAL_MODULE_TAGS := optional
216LOCAL_MODULE := core-libart-hostdex
217LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000218LOCAL_JAVA_LIBRARIES := core-oj-hostdex
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800219LOCAL_REQUIRED_MODULES := tzdata-host
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800220include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
221
222# Make the core-tests library.
Elliott Hughesd6108342011-02-22 10:13:54 -0800223ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800224 include $(CLEAR_VARS)
225 LOCAL_SRC_FILES := $(test_src_files)
226 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
227 LOCAL_NO_STANDARD_LIBRARIES := true
Przemyslaw Szczepaniak70b617f2015-11-20 12:01:45 +0000228 LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex mockito-api-hostdex
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800229 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
230 LOCAL_JAVACFLAGS := $(local_javac_flags)
231 LOCAL_MODULE_TAGS := optional
232 LOCAL_MODULE := core-tests-hostdex
233 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
234 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
235endif
236
237# Make the core-tests-support library.
238ifeq ($(LIBCORE_SKIP_TESTS),)
239 include $(CLEAR_VARS)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700240 LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
241 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
242 LOCAL_NO_STANDARD_LIBRARIES := true
Piotr Jastrzebski51b1b692015-02-16 15:01:09 +0000243 LOCAL_JAVA_LIBRARIES := core-oj-hostdex core-libart-hostdex core-junit-hostdex bouncycastle-hostdex
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700244 LOCAL_JAVACFLAGS := $(local_javac_flags)
245 LOCAL_MODULE_TAGS := optional
246 LOCAL_MODULE := core-tests-support-hostdex
247 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
248 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800249endif
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700250
251endif # HOST_OS == linux
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800252
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700253#
254# Local droiddoc for faster libcore testing
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800255#
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700256#
257# Run with:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800258# mm -j32 libcore-docs
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700259#
260# Main output:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800261# ../out/target/common/docs/libcore/reference/packages.html
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700262#
263# All text for proofreading (or running tools over):
264# ../out/target/common/docs/libcore-proofread.txt
265#
266# TODO list of missing javadoc, etc:
267# ../out/target/common/docs/libcore-docs-todo.html
Brian Carlstromcfa84a22011-03-24 13:55:02 -0700268#
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700269# Rerun:
270# rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
271#
272include $(CLEAR_VARS)
273
274# for shared defintion of libcore_to_document
Elliott Hughes73d3e262012-08-28 17:56:09 -0700275include $(LOCAL_PATH)/Docs.mk
Ying Wang21ac42d2013-12-04 15:54:36 -0800276
Neil Fuller42597382015-10-07 11:00:01 +0100277# The libcore_to_document paths are relative to $(TOPDIR). We are in libcore so we must prepend
278# ../ to make LOCAL_SRC_FILES relative to $(LOCAL_PATH).
279LOCAL_SRC_FILES := $(addprefix ../, $(libcore_to_document))
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700280# rerun doc generation without recompiling the java
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700281LOCAL_JAVACFLAGS := $(local_javac_flags)
282LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
283
284LOCAL_MODULE := libcore
285LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
286
Elliott Hughesb9863272012-11-08 14:28:29 -0800287LOCAL_DROIDDOC_OPTIONS := \
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700288 -offlinemode \
289 -title "libcore" \
290 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
291 -todo ../$(LOCAL_MODULE)-docs-todo.html \
292 -hdf android.whichdoc offline
293
294LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
295
296include $(BUILD_DROIDDOC)
Narayan Kamath0a57ec22015-07-24 14:34:02 +0100297
298openjdk_java_files :=
299non_openjdk_java_files :=