blob: 14b3c66a05566bec80ef1493b5dc002ef49c7a56 [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.
Kenny Rootb397b192013-08-29 14:24:47 -070053core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni 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)
Kenny Rootb397b192013-08-29 14:24:47 -0700121LOCAL_SRC_FILES := $(call all-test-java-files-under,crypto dalvik dom harmony-tests json luni 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
Kenny Rootb397b192013-08-29 14:24:47 -0700125LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support 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),)
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
139LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
140LOCAL_STATIC_JAVA_LIBRARIES := mockwebserver
141LOCAL_JAVACFLAGS := $(local_javac_flags)
142LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
143LOCAL_MODULE := core-tests-support
144LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
145include $(BUILD_STATIC_JAVA_LIBRARY)
146endif
147
148ifeq ($(LIBCORE_SKIP_TESTS),)
Tsu Chiang Chuang808558f2013-08-21 11:46:49 -0700149# Make the jsr166-tests library.
150include $(CLEAR_VARS)
151LOCAL_SRC_FILES := $(call all-test-java-files-under, jsr166-tests)
152LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
153LOCAL_NO_STANDARD_LIBRARIES := true
154LOCAL_JAVA_LIBRARIES := core core-junit
155LOCAL_JAVACFLAGS := $(local_javac_flags)
156LOCAL_MODULE := jsr166-tests
157LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
158include $(BUILD_STATIC_JAVA_LIBRARY)
159endif
160
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700161# This one's tricky. One of our tests needs to have a
162# resource with a "#" in its name, but Perforce doesn't
163# allow us to submit such a file. So we create it here
164# on-the-fly.
Ying Wang43624e72011-06-06 15:34:59 -0700165TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700166TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
167
168$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
169 @mkdir -p $(dir $@)
170 @echo "Hello, world!" > $@
171
Ying Wang43624e72011-06-06 15:34:59 -0700172$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700173$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
174
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700175
176#
177# Build for the host.
178#
179
Tsu Chiang Chuang25963ae2013-07-23 16:39:20 -0700180include $(CLEAR_VARS)
181LOCAL_SRC_FILES := $(call all-main-java-files-under, dex)
182LOCAL_MODULE_TAGS := optional
183LOCAL_MODULE := dex-host
184include $(BUILD_HOST_JAVA_LIBRARY)
185
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700186ifeq ($(WITH_HOST_DALVIK),true)
187
188 # Definitions to make the core library.
189
190 include $(CLEAR_VARS)
191
192 LOCAL_SRC_FILES := $(core_src_files)
193 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
194
195 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800196 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700197 LOCAL_DX_FLAGS := --core-library
198
Jesse Wilson7898a912010-09-13 15:42:41 -0700199 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700200
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700201 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700202 LOCAL_MODULE := core-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700203 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Elliott Hughes055fe872012-10-18 11:26:48 -0700204 LOCAL_REQUIRED_MODULES := tzdata-host
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700205
206 include $(BUILD_HOST_JAVA_LIBRARY)
207
Kenny Root38375a42013-04-23 15:50:31 -0700208 # Make the conscrypt-hostdex library
209 include $(CLEAR_VARS)
210 LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
211 LOCAL_JAVA_LIBRARIES := core-hostdex
212 LOCAL_NO_STANDARD_LIBRARIES := true
213 LOCAL_JAVACFLAGS := $(local_javac_flags)
214 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
215 LOCAL_BUILD_HOST_DEX := true
216 LOCAL_MODULE_TAGS := optional
217 LOCAL_MODULE := conscrypt-hostdex
218 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
219 include $(BUILD_HOST_JAVA_LIBRARY)
220
221 # Make the conscrypt-hostdex-nojarjar for tests
222 include $(CLEAR_VARS)
223 LOCAL_SRC_FILES := $(call all-main-java-files-under,crypto)
224 LOCAL_JAVA_LIBRARIES := core-hostdex
225 LOCAL_NO_STANDARD_LIBRARIES := true
226 LOCAL_JAVACFLAGS := $(local_javac_flags)
227 LOCAL_BUILD_HOST_DEX := true
228 LOCAL_MODULE_TAGS := optional
229 LOCAL_MODULE := conscrypt-hostdex-nojarjar
230 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
231 include $(BUILD_HOST_JAVA_LIBRARY)
232
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800233 # Make the core-tests library.
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700234 ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800235 include $(CLEAR_VARS)
Kenny Root38375a42013-04-23 15:50:31 -0700236 LOCAL_SRC_FILES := $(call all-test-java-files-under,crypto dalvik dom json luni support xml)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800237 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
238 LOCAL_NO_STANDARD_LIBRARIES := true
Kenny Root38375a42013-04-23 15:50:31 -0700239 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex conscrypt-hostdex-nojarjar core-junit-hostdex okhttp-hostdex
Brian Carlstrom22a12c92013-01-17 16:18:31 -0800240 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800241 LOCAL_JAVACFLAGS := $(local_javac_flags)
Kenny Root38375a42013-04-23 15:50:31 -0700242 LOCAL_JARJAR_RULES := $(LOCAL_PATH)/crypto/jarjar-rules.txt
Ying Wange79ac582012-08-23 11:25:27 -0700243 LOCAL_MODULE_TAGS := optional
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800244 LOCAL_MODULE := core-tests-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700245 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800246 LOCAL_BUILD_HOST_DEX := true
247 include $(BUILD_HOST_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700248 endif
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800249endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800250
251#
252# Local droiddoc for faster libcore testing
253#
254#
255# Run with:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800256# mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800257#
258# Main output:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800259# ../out/target/common/docs/libcore/reference/packages.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800260#
261# All text for proofreading (or running tools over):
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800262# ../out/target/common/docs/libcore-proofread.txt
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800263#
264# TODO list of missing javadoc, etc:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800265# ../out/target/common/docs/libcore-docs-todo.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800266#
267# Rerun:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800268# rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800269#
270include $(CLEAR_VARS)
271
272# for shared defintion of libcore_to_document
273include $(LOCAL_PATH)/Docs.mk
274
Brian Carlstromcfa84a22011-03-24 13:55:02 -0700275LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH))
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800276# rerun doc generation without recompiling the java
277LOCAL_JAVA_LIBRARIES:=
Elliott Hughesd6108342011-02-22 10:13:54 -0800278LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800279LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
280
281LOCAL_MODULE := libcore
Elliott Hughes73d3e262012-08-28 17:56:09 -0700282LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800283
Elliott Hughesb9863272012-11-08 14:28:29 -0800284LOCAL_DROIDDOC_OPTIONS := \
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800285 -offlinemode \
286 -title "libcore" \
287 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
288 -todo ../$(LOCAL_MODULE)-docs-todo.html \
289 -hdf android.whichdoc offline
290
291LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
292
293include $(BUILD_DROIDDOC)