blob: 797dfee0bbc805890bb38472f8cb4b53a7cac1c9 [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.
Jesse Wilson2bea5ee2011-09-18 12:55:16 -040053core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni support xml)
Brian Carlstrom895bba42013-05-13 10:19:39 -070054core_src_files += $(call all-main-java-files-under,libdvm)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070055core_resource_dirs := $(call all-core-resource-dirs,main)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070056test_resource_dirs := $(call all-core-resource-dirs,test)
57
Jesse Wilson7898a912010-09-13 15:42:41 -070058ifeq ($(EMMA_INSTRUMENT),true)
Ying Wangff053c32012-08-21 17:20:51 -070059ifneq ($(EMMA_INSTRUMENT_STATIC),true)
Jesse Wilson7898a912010-09-13 15:42:41 -070060 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
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
69#
70# Build for the target (device).
71#
72
73# Definitions to make the core library.
74
75include $(CLEAR_VARS)
76
77LOCAL_SRC_FILES := $(core_src_files)
78LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
79
80LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080081LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070082LOCAL_DX_FLAGS := --core-library
83
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 -070088
89include $(BUILD_JAVA_LIBRARY)
90
91core-intermediates := ${intermediates}
92
93
Kenny Root38375a42013-04-23 15:50:31 -070094# Create the conscrypt library
Brian Carlstrom51ee38b2010-07-23 15:57:52 -070095include $(CLEAR_VARS)
Kenny Root38375a42013-04-23 15:50:31 -070096LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
97LOCAL_JAVA_LIBRARIES := core
98LOCAL_NO_STANDARD_LIBRARIES := true
99LOCAL_JAVACFLAGS := $(local_javac_flags)
100LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
101LOCAL_MODULE_TAGS := optional
102LOCAL_MODULE := conscrypt
103LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
104include $(BUILD_JAVA_LIBRARY)
105
106# Create the conscrypt library without jarjar for tests
107include $(CLEAR_VARS)
108LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
109LOCAL_JAVA_LIBRARIES := core
110LOCAL_NO_STANDARD_LIBRARIES := true
111LOCAL_JAVACFLAGS := $(local_javac_flags)
112LOCAL_MODULE_TAGS := optional
113LOCAL_MODULE := conscrypt-nojarjar
114LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Kenny Rootaae2e512013-08-29 10:09:03 -0700115include $(BUILD_JAVA_LIBRARY)
Kenny Root38375a42013-04-23 15:50:31 -0700116
117
118ifeq ($(LIBCORE_SKIP_TESTS),)
119# Make the core-tests library.
120include $(CLEAR_VARS)
Ian Rogers3d41b9a2013-08-19 10:57:22 -0700121LOCAL_SRC_FILES := $(call all-test-java-files-under,crypto dalvik dom harmony-tests json luni support xml)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700122LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
123LOCAL_NO_STANDARD_LIBRARIES := true
Kenny Rootaae2e512013-08-29 10:09:03 -0700124LOCAL_JAVA_LIBRARIES := bouncycastle core conscrypt-nojarjar core-junit okhttp
125LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc mockwebserver nist-pkix-tests okhttp-tests
Elliott Hughesd6108342011-02-22 10:13:54 -0800126LOCAL_JAVACFLAGS := $(local_javac_flags)
Kenny Root38375a42013-04-23 15:50:31 -0700127LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
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),)
134# Make the jsr166-tests library.
135include $(CLEAR_VARS)
136LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests)
137LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
138LOCAL_NO_STANDARD_LIBRARIES := true
139LOCAL_JAVA_LIBRARIES := core core-junit
140LOCAL_JAVACFLAGS := $(local_javac_flags)
141LOCAL_MODULE := jsr166-tests
142LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
143include $(BUILD_STATIC_JAVA_LIBRARY)
144endif
145
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700146# This one's tricky. One of our tests needs to have a
147# resource with a "#" in its name, but Perforce doesn't
148# allow us to submit such a file. So we create it here
149# on-the-fly.
Ying Wang43624e72011-06-06 15:34:59 -0700150TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700151TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
152
153$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
154 @mkdir -p $(dir $@)
155 @echo "Hello, world!" > $@
156
Ying Wang43624e72011-06-06 15:34:59 -0700157$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700158$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
159
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700160
161#
162# Build for the host.
163#
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
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700171ifeq ($(WITH_HOST_DALVIK),true)
172
173 # Definitions to make the core library.
174
175 include $(CLEAR_VARS)
176
177 LOCAL_SRC_FILES := $(core_src_files)
178 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
179
180 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800181 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700182 LOCAL_DX_FLAGS := --core-library
183
Jesse Wilson7898a912010-09-13 15:42:41 -0700184 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700185
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700186 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700187 LOCAL_MODULE := core-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700188 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Elliott Hughes055fe872012-10-18 11:26:48 -0700189 LOCAL_REQUIRED_MODULES := tzdata-host
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700190
191 include $(BUILD_HOST_JAVA_LIBRARY)
192
Kenny Root38375a42013-04-23 15:50:31 -0700193 # Make the conscrypt-hostdex library
194 include $(CLEAR_VARS)
195 LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
196 LOCAL_JAVA_LIBRARIES := core-hostdex
197 LOCAL_NO_STANDARD_LIBRARIES := true
198 LOCAL_JAVACFLAGS := $(local_javac_flags)
199 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
200 LOCAL_BUILD_HOST_DEX := true
201 LOCAL_MODULE_TAGS := optional
202 LOCAL_MODULE := conscrypt-hostdex
203 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
204 include $(BUILD_HOST_JAVA_LIBRARY)
205
206 # Make the conscrypt-hostdex-nojarjar for tests
207 include $(CLEAR_VARS)
208 LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
209 LOCAL_JAVA_LIBRARIES := core-hostdex
210 LOCAL_NO_STANDARD_LIBRARIES := true
211 LOCAL_JAVACFLAGS := $(local_javac_flags)
212 LOCAL_BUILD_HOST_DEX := true
213 LOCAL_MODULE_TAGS := optional
214 LOCAL_MODULE := conscrypt-hostdex-nojarjar
215 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
216 include $(BUILD_HOST_JAVA_LIBRARY)
217
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800218 # Make the core-tests library.
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700219 ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800220 include $(CLEAR_VARS)
Kenny Root38375a42013-04-23 15:50:31 -0700221 LOCAL_SRC_FILES := $(call all-test-java-files-under,crypto dalvik dom json luni support xml)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800222 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
223 LOCAL_NO_STANDARD_LIBRARIES := true
Kenny Root38375a42013-04-23 15:50:31 -0700224 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex conscrypt-hostdex-nojarjar core-junit-hostdex okhttp-hostdex
Brian Carlstrom22a12c92013-01-17 16:18:31 -0800225 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800226 LOCAL_JAVACFLAGS := $(local_javac_flags)
Kenny Root38375a42013-04-23 15:50:31 -0700227 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
Ying Wange79ac582012-08-23 11:25:27 -0700228 LOCAL_MODULE_TAGS := optional
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800229 LOCAL_MODULE := core-tests-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700230 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800231 LOCAL_BUILD_HOST_DEX := true
232 include $(BUILD_HOST_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700233 endif
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800234endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800235
236#
237# Local droiddoc for faster libcore testing
238#
239#
240# Run with:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800241# mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800242#
243# Main output:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800244# ../out/target/common/docs/libcore/reference/packages.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800245#
246# All text for proofreading (or running tools over):
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800247# ../out/target/common/docs/libcore-proofread.txt
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800248#
249# TODO list of missing javadoc, etc:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800250# ../out/target/common/docs/libcore-docs-todo.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800251#
252# Rerun:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800253# rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800254#
255include $(CLEAR_VARS)
256
257# for shared defintion of libcore_to_document
258include $(LOCAL_PATH)/Docs.mk
259
Brian Carlstromcfa84a22011-03-24 13:55:02 -0700260LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH))
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800261# rerun doc generation without recompiling the java
262LOCAL_JAVA_LIBRARIES:=
Elliott Hughesd6108342011-02-22 10:13:54 -0800263LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800264LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
265
266LOCAL_MODULE := libcore
Elliott Hughes73d3e262012-08-28 17:56:09 -0700267LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800268
Elliott Hughesb9863272012-11-08 14:28:29 -0800269LOCAL_DROIDDOC_OPTIONS := \
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800270 -offlinemode \
271 -title "libcore" \
272 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
273 -todo ../$(LOCAL_MODULE)-docs-todo.html \
274 -hdf android.whichdoc offline
275
276LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
277
278include $(BUILD_DROIDDOC)