blob: fb0b207154e5d9a733b057797b89d0b71a8d41b7 [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 -070065libart_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libart)
66
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080067local_javac_flags=-encoding UTF-8
68#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
69local_javac_flags+=-Xmaxwarns 9999999
Dan Bornstein6ac43c22009-10-24 15:33:49 -070070
71#
Narayan Kamathf37f7812015-04-01 09:34:24 +010072# ICU4J related rules.
73#
74# We compile icu4j along with core-libart because we're implementing parts of core-libart
75# in terms of icu4j.
76icu4j_root := ../external/icu/icu4j/
77icu4j_src_files := $(call all-java-files-under,$(icu4j_root)/main/classes)
78
79# Filter out bits of ICU4J we don't use yet : the SPIs (which we have limited support for),
80# the charset encoders and the transliterators.
81icu4j_src_files := $(filter-out $(icu4j_root)/main/classes/localespi/%, $(icu4j_src_files))
82icu4j_src_files := $(filter-out $(icu4j_root)/main/classes/charset/%, $(icu4j_src_files))
83icu4j_src_files := $(filter-out $(icu4j_root)/main/classes/translit/%, $(icu4j_src_files))
84
85# Not all src dirs contain resources, some instead contain other random files
86# that should not be included as resources. The ones that should be included
87# can be identifed by the fact that they contain particular subdir trees.
88#
89define all-icu-subdir-with-subdir
90$(patsubst $(LOCAL_PATH)/%/$(2),%,$(wildcard $(LOCAL_PATH)/$(1)/$(2)))
91endef
92
Narayan Kamath3142d9382015-04-01 11:32:12 +010093icu4j_resource_dirs := $(call all-icu-subdir-with-subdir,$(icu4j_root)/main/classes/*/src,com/ibm/icu)
94icu4j_resource_dirs := $(filter-out $(icu4j_root)/main/classes/localespi/%, $(icu4j_resource_dirs))
95icu4j_resource_dirs := $(filter-out $(icu4j_root)/main/classes/charset/%, $(icu4j_resource_dirs))
96icu4j_resource_dirs := $(filter-out $(icu4j_root)/main/classes/translit/%, $(icu4j_resource_dirs))
97
98
Narayan Kamathf37f7812015-04-01 09:34:24 +010099
100#
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700101# Build for the target (device).
102#
103
104# Definitions to make the core library.
105
106include $(CLEAR_VARS)
Narayan Kamathf37f7812015-04-01 09:34:24 +0100107LOCAL_SRC_FILES := $(libart_core_src_files) $(icu4j_src_files)
108LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) $(icu4j_resource_dirs)
Brian Carlstrom3711c212013-06-25 15:59:29 -0700109LOCAL_NO_STANDARD_LIBRARIES := true
110LOCAL_JAVACFLAGS := $(local_javac_flags)
111LOCAL_DX_FLAGS := --core-library
112LOCAL_MODULE_TAGS := optional
113LOCAL_MODULE := core-libart
114LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
115LOCAL_REQUIRED_MODULES := tzdata
Narayan Kamathf37f7812015-04-01 09:34:24 +0100116LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
Brian Carlstrom3711c212013-06-25 15:59:29 -0700117include $(BUILD_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700118
Kenny Root38375a42013-04-23 15:50:31 -0700119ifeq ($(LIBCORE_SKIP_TESTS),)
120# Make the core-tests library.
121include $(CLEAR_VARS)
Narayan Kamath51525b52013-11-15 18:02:54 +0000122LOCAL_SRC_FILES := $(test_src_files)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700123LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
124LOCAL_NO_STANDARD_LIBRARIES := true
Neil Fuller9496b212014-09-04 11:11:56 +0100125LOCAL_JAVA_LIBRARIES := core-libart okhttp core-junit bouncycastle
Neil Fuller62fba1e2014-05-29 11:52:06 +0100126LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests
Elliott Hughesd6108342011-02-22 10:13:54 -0800127LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromb094af32010-05-28 17:37:37 -0700128LOCAL_MODULE := core-tests
Elliott Hughes73d3e262012-08-28 17:56:09 -0700129LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Jesse Wilson706d5352010-06-08 17:20:09 -0700130include $(BUILD_STATIC_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700131endif
Jesse Wilson706d5352010-06-08 17:20:09 -0700132
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700133ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Rootb397b192013-08-29 14:24:47 -0700134# Make the core-tests-support library.
135include $(CLEAR_VARS)
136LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
137LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
138LOCAL_NO_STANDARD_LIBRARIES := true
Neil Fuller9496b212014-09-04 11:11:56 +0100139LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle
Kenny Rootb397b192013-08-29 14:24:47 -0700140LOCAL_JAVACFLAGS := $(local_javac_flags)
Kenny Rootb397b192013-08-29 14:24:47 -0700141LOCAL_MODULE := core-tests-support
142LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
143include $(BUILD_STATIC_JAVA_LIBRARY)
144endif
145
146ifeq ($(LIBCORE_SKIP_TESTS),)
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700147# Make the jsr166-tests library.
148include $(CLEAR_VARS)
149LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests)
150LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
151LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom18e74062014-08-05 12:50:01 -0700152LOCAL_JAVA_LIBRARIES := core-libart core-junit
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700153LOCAL_JAVACFLAGS := $(local_javac_flags)
154LOCAL_MODULE := jsr166-tests
155LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
156include $(BUILD_STATIC_JAVA_LIBRARY)
157endif
158
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700159#
160# Build for the host.
161#
162
Elliott Hughese983a0b2015-01-16 10:47:17 -0800163ifeq ($(HOST_OS),linux)
164
Tsu Chiang Chuang25963ae2013-07-23 16:39:20 -0700165include $(CLEAR_VARS)
166LOCAL_SRC_FILES := $(call all-main-java-files-under, dex)
167LOCAL_MODULE_TAGS := optional
168LOCAL_MODULE := dex-host
169include $(BUILD_HOST_JAVA_LIBRARY)
170
Ian Rogers3deabd22014-05-23 15:12:42 -0700171# Definitions to make the core library.
172include $(CLEAR_VARS)
Narayan Kamathf37f7812015-04-01 09:34:24 +0100173LOCAL_SRC_FILES := $(libart_core_src_files) $(icu4j_src_files)
174LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) $(icu4j_resource_dirs)
Ian Rogers3deabd22014-05-23 15:12:42 -0700175LOCAL_NO_STANDARD_LIBRARIES := true
176LOCAL_JAVACFLAGS := $(local_javac_flags)
177LOCAL_DX_FLAGS := --core-library
178LOCAL_MODULE_TAGS := optional
179LOCAL_MODULE := core-libart-hostdex
180LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
181LOCAL_REQUIRED_MODULES := tzdata-host
Narayan Kamathf37f7812015-04-01 09:34:24 +0100182LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
Ian Rogers3deabd22014-05-23 15:12:42 -0700183include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700184
Ian Rogers3deabd22014-05-23 15:12:42 -0700185# Make the core-tests library.
186ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800187 include $(CLEAR_VARS)
Narayan Kamath51525b52013-11-15 18:02:54 +0000188 LOCAL_SRC_FILES := $(test_src_files)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800189 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
Neil Fuller9496b212014-09-04 11:11:56 +0100190 LOCAL_NO_STANDARD_LIBRARIES := true
191 LOCAL_JAVA_LIBRARIES := core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex
Brian Carlstrom22a12c92013-01-17 16:18:31 -0800192 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800193 LOCAL_JAVACFLAGS := $(local_javac_flags)
Ying Wange79ac582012-08-23 11:25:27 -0700194 LOCAL_MODULE_TAGS := optional
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800195 LOCAL_MODULE := core-tests-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700196 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000197 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Ian Rogers3deabd22014-05-23 15:12:42 -0700198endif
Kenny Rootba07db52013-08-29 13:40:35 -0700199
Ian Rogers3deabd22014-05-23 15:12:42 -0700200# Make the core-tests-support library.
201ifeq ($(LIBCORE_SKIP_TESTS),)
Kenny Rootba07db52013-08-29 13:40:35 -0700202 include $(CLEAR_VARS)
203 LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
204 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
Neil Fuller9496b212014-09-04 11:11:56 +0100205 LOCAL_NO_STANDARD_LIBRARIES := true
206 LOCAL_JAVA_LIBRARIES := core-libart-hostdex core-junit-hostdex bouncycastle-hostdex
Kenny Rootba07db52013-08-29 13:40:35 -0700207 LOCAL_JAVACFLAGS := $(local_javac_flags)
208 LOCAL_MODULE_TAGS := optional
209 LOCAL_MODULE := core-tests-support-hostdex
210 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Narayan Kamath70e8ce82013-10-28 14:17:35 +0000211 include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800212endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800213
Elliott Hughese983a0b2015-01-16 10:47:17 -0800214endif # HOST_OS == linux
215
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800216#
217# Local droiddoc for faster libcore testing
218#
219#
220# Run with:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800221# mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800222#
223# Main output:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800224# ../out/target/common/docs/libcore/reference/packages.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800225#
226# All text for proofreading (or running tools over):
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800227# ../out/target/common/docs/libcore-proofread.txt
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800228#
229# TODO list of missing javadoc, etc:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800230# ../out/target/common/docs/libcore-docs-todo.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800231#
232# Rerun:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800233# rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800234#
235include $(CLEAR_VARS)
236
237# for shared defintion of libcore_to_document
238include $(LOCAL_PATH)/Docs.mk
239
Ying Wang21ac42d2013-12-04 15:54:36 -0800240LOCAL_SRC_FILES := $(libcore_to_document)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800241# rerun doc generation without recompiling the java
242LOCAL_JAVA_LIBRARIES:=
Elliott Hughesd6108342011-02-22 10:13:54 -0800243LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800244LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
245
246LOCAL_MODULE := libcore
Elliott Hughes73d3e262012-08-28 17:56:09 -0700247LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800248
Elliott Hughesb9863272012-11-08 14:28:29 -0800249LOCAL_DROIDDOC_OPTIONS := \
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800250 -offlinemode \
251 -title "libcore" \
252 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
253 -todo ../$(LOCAL_MODULE)-docs-todo.html \
254 -hdf android.whichdoc offline
255
256LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
257
258include $(BUILD_DROIDDOC)