blob: 98de1f2c83eb8fd1cd8664b50effcda0a66dacb2 [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)
Ying Wangff053c32012-08-21 17:20:51 -070058ifneq ($(EMMA_INSTRUMENT_STATIC),true)
Jesse Wilson7898a912010-09-13 15:42:41 -070059 core_src_files += $(call all-java-files-under, ../external/emma/core ../external/emma/pregenerated)
60 core_resource_dirs += ../external/emma/core/res ../external/emma/pregenerated/res
61endif
Ying Wangff053c32012-08-21 17:20:51 -070062endif
Jesse Wilson7898a912010-09-13 15:42:41 -070063
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080064local_javac_flags=-encoding UTF-8
65#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
66local_javac_flags+=-Xmaxwarns 9999999
Dan Bornstein6ac43c22009-10-24 15:33:49 -070067
68#
69# Build for the target (device).
70#
71
72# Definitions to make the core library.
73
74include $(CLEAR_VARS)
75
76LOCAL_SRC_FILES := $(core_src_files)
77LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
78
79LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -080080LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -070081LOCAL_DX_FLAGS := --core-library
82
Jesse Wilson53fbc0a2010-09-16 15:46:05 -070083LOCAL_MODULE_TAGS := optional
Dan Bornstein6ac43c22009-10-24 15:33:49 -070084LOCAL_MODULE := core
Elliott Hughes73d3e262012-08-28 17:56:09 -070085LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Elliott Hughes055fe872012-10-18 11:26:48 -070086LOCAL_REQUIRED_MODULES := tzdata
Dan Bornstein6ac43c22009-10-24 15:33:49 -070087
88include $(BUILD_JAVA_LIBRARY)
89
90core-intermediates := ${intermediates}
91
92
Brian Carlstrom302e3302011-03-01 23:59:06 -080093# Make the core-tests library.
Elliott Hughesc5cd6e82012-10-18 18:13:10 -070094ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -070095include $(CLEAR_VARS)
Brian Carlstrom302e3302011-03-01 23:59:06 -080096LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
Brian Carlstrom51ee38b2010-07-23 15:57:52 -070097LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
98LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom37a816a2011-03-18 12:52:04 -070099LOCAL_JAVA_LIBRARIES := bouncycastle core core-junit
Kenny Roota96f0f82013-01-17 16:23:31 -0800100LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc mockwebserver nist-pkix-tests
Elliott Hughesd6108342011-02-22 10:13:54 -0800101LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromb094af32010-05-28 17:37:37 -0700102LOCAL_MODULE := core-tests
Elliott Hughes73d3e262012-08-28 17:56:09 -0700103LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Jesse Wilson706d5352010-06-08 17:20:09 -0700104include $(BUILD_STATIC_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700105endif
Jesse Wilson706d5352010-06-08 17:20:09 -0700106
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700107# This one's tricky. One of our tests needs to have a
108# resource with a "#" in its name, but Perforce doesn't
109# allow us to submit such a file. So we create it here
110# on-the-fly.
Ying Wang43624e72011-06-06 15:34:59 -0700111TMP_RESOURCE_DIR := $(intermediates.COMMON)/tmp/
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700112TMP_RESOURCE_FILE := org/apache/harmony/luni/tests/java/lang/test\#.properties
113
114$(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE):
115 @mkdir -p $(dir $@)
116 @echo "Hello, world!" > $@
117
Ying Wang43624e72011-06-06 15:34:59 -0700118$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args) -C "$(TMP_RESOURCE_DIR)" "$(TMP_RESOURCE_FILE)"
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700119$(LOCAL_INTERMEDIATE_TARGETS): $(TMP_RESOURCE_DIR)$(TMP_RESOURCE_FILE)
120
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700121
122#
123# Build for the host.
124#
125
126ifeq ($(WITH_HOST_DALVIK),true)
127
128 # Definitions to make the core library.
129
130 include $(CLEAR_VARS)
131
132 LOCAL_SRC_FILES := $(core_src_files)
133 LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs)
134
135 LOCAL_NO_STANDARD_LIBRARIES := true
Elliott Hughes48d0b3f2010-12-14 09:48:52 -0800136 LOCAL_JAVACFLAGS := $(local_javac_flags)
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700137 LOCAL_DX_FLAGS := --core-library
138
Jesse Wilson7898a912010-09-13 15:42:41 -0700139 LOCAL_BUILD_HOST_DEX := true
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700140
Jean-Baptiste Queruf2678962010-09-14 13:50:14 -0700141 LOCAL_MODULE_TAGS := optional
Jesse Wilson53fbc0a2010-09-16 15:46:05 -0700142 LOCAL_MODULE := core-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700143 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Elliott Hughes055fe872012-10-18 11:26:48 -0700144 LOCAL_REQUIRED_MODULES := tzdata-host
Dan Bornstein6ac43c22009-10-24 15:33:49 -0700145
146 include $(BUILD_HOST_JAVA_LIBRARY)
147
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800148 # Make the core-tests library.
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700149 ifeq ($(LIBCORE_SKIP_TESTS),)
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800150 include $(CLEAR_VARS)
151 LOCAL_SRC_FILES := $(call all-test-java-files-under,dalvik dom json luni support xml)
152 LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
153 LOCAL_NO_STANDARD_LIBRARIES := true
Brian Carlstrom37a816a2011-03-18 12:52:04 -0700154 LOCAL_JAVA_LIBRARIES := bouncycastle-hostdex core-hostdex core-junit-hostdex
Brian Carlstrom22a12c92013-01-17 16:18:31 -0800155 LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800156 LOCAL_JAVACFLAGS := $(local_javac_flags)
Ying Wange79ac582012-08-23 11:25:27 -0700157 LOCAL_MODULE_TAGS := optional
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800158 LOCAL_MODULE := core-tests-hostdex
Elliott Hughes73d3e262012-08-28 17:56:09 -0700159 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromd39b1d62011-03-06 23:15:39 -0800160 LOCAL_BUILD_HOST_DEX := true
161 include $(BUILD_HOST_JAVA_LIBRARY)
Elliott Hughesc5cd6e82012-10-18 18:13:10 -0700162 endif
Elliott Hughes67cc34b2010-02-19 22:14:19 -0800163endif
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800164
165#
166# Local droiddoc for faster libcore testing
167#
168#
169# Run with:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800170# mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800171#
172# Main output:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800173# ../out/target/common/docs/libcore/reference/packages.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800174#
175# All text for proofreading (or running tools over):
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800176# ../out/target/common/docs/libcore-proofread.txt
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800177#
178# TODO list of missing javadoc, etc:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800179# ../out/target/common/docs/libcore-docs-todo.html
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800180#
181# Rerun:
Elliott Hughes92fc63e2013-02-07 17:05:57 -0800182# rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800183#
184include $(CLEAR_VARS)
185
186# for shared defintion of libcore_to_document
187include $(LOCAL_PATH)/Docs.mk
188
Brian Carlstromcfa84a22011-03-24 13:55:02 -0700189LOCAL_SRC_FILES:=$(call libcore_to_document,$(LOCAL_PATH))
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800190# rerun doc generation without recompiling the java
191LOCAL_JAVA_LIBRARIES:=
Elliott Hughesd6108342011-02-22 10:13:54 -0800192LOCAL_JAVACFLAGS := $(local_javac_flags)
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800193LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
194
195LOCAL_MODULE := libcore
Elliott Hughes73d3e262012-08-28 17:56:09 -0700196LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800197
Elliott Hughesb9863272012-11-08 14:28:29 -0800198LOCAL_DROIDDOC_OPTIONS := \
Brian Carlstromdc3c1522011-01-05 17:48:05 -0800199 -offlinemode \
200 -title "libcore" \
201 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
202 -todo ../$(LOCAL_MODULE)-docs-todo.html \
203 -hdf android.whichdoc offline
204
205LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
206
207include $(BUILD_DROIDDOC)