blob: 7179fda9144ebb8cdf16d44631817ca5db04a6f1 [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 Wilsone590b9c2011-01-13 17:20:50 -080053core_src_files := $(call all-main-java-files-under,dalvik dom json luni support 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)
56
Jesse Wilson7898a912010-09-13 15:42:41 -070057ifeq ($(EMMA_INSTRUMENT),true)
58 core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
59 core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res
60endif
61
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080062local_javac_flags=-encoding UTF-8
63#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
64local_javac_flags+=-Xmaxwarns 9999999
Dan Bornstein6ac43c22009-10-24 15:33:49 -070065
66#
67# Build for the target (device).
68#
69
70# Definitions to make the core library.
71
72include $(CLEAR_VARS)
73
74LOCAL_SRC_FILES := $(core_src_files)
75LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
76
77LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080078LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070079LOCAL_DX_FLAGS := --core-library
80
81LOCAL_NO_EMMA_INSTRUMENT := true
82LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070083LOCAL_MODULE_TAGS := optional
Dan Bornstein6ac43c22009-10-24 15:33:49 -070084LOCAL_MODULE := core
85
86include $(BUILD_JAVA_LIBRARY)
87
88core-intermediates := ${intermediates}
89
90
Jesse Wilson32cfe952010-05-04 16:36:03 -070091# Make core-junit
92include $(CLEAR_VARS)
93LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
94LOCAL_NO_STANDARD_LIBRARIES := true
95LOCAL_JAVA_LIBRARIES := core
Elliott Hughesd6108342011-02-22 10:13:54 -080096LOCAL_JAVACFLAGS := $(local_javac_flags)
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070097LOCAL_MODULE_TAGS := optional
Jesse Wilson32cfe952010-05-04 16:36:03 -070098LOCAL_MODULE := core-junit
99include $(BUILD_JAVA_LIBRARY)
100
Brian Carlstrom302e3302011-03-01 23:59:06 -0800101# Make the core-tests library.
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700102include $(CLEAR_VARS)
Brian Carlstrom302e3302011-03-01 23:59:06 -0800103LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -0700104LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
105LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom37a816a2011-03-18 12:52:04 -0700106LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
Jesse Wilson09336c92011-06-07 08:08:10 -0700107LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc mockwebserver
Elliott Hughesd6108342011-02-22 10:13:54 -0800108LOCAL_JAVACFLAGS := $(local_javac_flags)
Jesse Wilsond5d35262010-05-12 23:56:14 -0700109LOCAL_MODULE_TAGS := tests
Brian Carlstromb094af32010-05-28 17:37:37 -0700110LOCAL_MODULE := core-tests
Guang Zhu83244e52010-06-11 18:48:30 -0700111LOCAL_NO_EMMA_INSTRUMENT := true
112LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson706d5352010-06-08 17:20:09 -0700113include $(BUILD_STATIC_JAVA_LIBRARY)
114
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700115# This one's tricky. One of our tests needs to have a
116# resource with a "#" in its name, but Perforce doesn't
117# allow us to submit such a file. So we create it here
118# on-the-fly.
Ying Wang43624e72011-06-06 15:34:59 -0700119TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700120TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
121
122$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
123 @mkdir -p $(dir $@)
124 @echo "Hello, world!" > $@
125
Ying Wang43624e72011-06-06 15:34:59 -0700126$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700127$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
128
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700129
130#
131# Build for the host.
132#
133
134ifeq ($(WITH_HOST_DALVIK),true)
135
136 # Definitions to make the core library.
137
138 include $(CLEAR_VARS)
139
140 LOCAL_SRC_FILES := $(core_src_files)
141 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
142
143 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800144 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700145 LOCAL_DX_FLAGS := --core-library
146
147 LOCAL_NO_EMMA_INSTRUMENT := true
148 LOCAL_NO_EMMA_COMPILE := true
Jesse Wilson7898a912010-09-13 15:42:41 -0700149 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700150
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700151 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700152 LOCAL_MODULE := core-hostdex
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700153
154 include $(BUILD_HOST_JAVA_LIBRARY)
155
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800156 # Make core-junit
157 include $(CLEAR_VARS)
158 LOCAL_SRC_FILES := $(call all-main-java-files-under,junit)
159 LOCAL_NO_STANDARD_LIBRARIES := true
160 LOCAL_JAVA_LIBRARIES := core-hostdex
161 LOCAL_JAVACFLAGS := $(local_javac_flags)
162 LOCAL_MODULE_TAGS := optional
163 LOCAL_MODULE := core-junit-hostdex
164 LOCAL_BUILD_HOST_DEX := true
165 include $(BUILD_HOST_JAVA_LIBRARY)
166
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800167 # Make the core-tests library.
168 include $(CLEAR_VARS)
169 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
170 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
171 LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom37a816a2011-03-18 12:52:04 -0700172 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex
Jesse Wilson09336c92011-06-07 08:08:10 -0700173 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-hostdex
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800174 LOCAL_JAVACFLAGS := $(local_javac_flags)
175 LOCAL_MODULE_TAGS := tests
176 LOCAL_MODULE := core-tests-hostdex
177 LOCAL_NO_EMMA_INSTRUMENT := true
178 LOCAL_NO_EMMA_COMPILE := true
179 LOCAL_BUILD_HOST_DEX := true
180 include $(BUILD_HOST_JAVA_LIBRARY)
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800181endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800182
183#
184# Local droiddoc for faster libcore testing
185#
186#
187# Run with:
188# m libcore-docs
189#
190# Main output:
191# out/target/common/docs/libcore/reference/packages.html
192#
193# All text for proofreading (or running tools over):
194# out/target/common/docs/libcore-proofread.txt
195#
196# TODO list of missing javadoc, etc:
197# out/target/common/docs/libcore-docs-todo.html
198#
199# Rerun:
200# rm -rf out/target/common/docs/libcore-timestamp && m libcore-docs
201#
202include $(CLEAR_VARS)
203
204# for shared defintion of libcore_to_document
205include $(LOCAL_PATH)/Docs.mk
206
Brian Carlstromcfa84a22011-03-24 13:55:02 -0700207LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH))
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800208# rerun doc generation without recompiling the java
209LOCAL_JAVA_LIBRARIES:=
Elliott Hughesd6108342011-02-22 10:13:54 -0800210LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800211LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
212
213LOCAL_MODULE := libcore
214
215LOCAL_DROIDDOC_OPTIONS:= \
216 -offlinemode \
217 -title "libcore" \
218 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
219 -todo ../$(LOCAL_MODULE)-docs-todo.html \
220 -hdf android.whichdoc offline
221
222LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
223
224include $(BUILD_DROIDDOC)