• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- mode: makefile -*-
2# 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
24# 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).
39
40define 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
45$(foreach dir,$(1),$(patsubst ./%,%,$(shell cd $(LOCAL_PATH) && find $(dir)/src/test/java -name "*.java" 2> /dev/null)))
46endef
47
48define all-core-resource-dirs
49$(shell cd $(LOCAL_PATH) && ls -d */src/$(1)/{java,resources} 2> /dev/null)
50endef
51
52# The Java files and their associated resources.
53common_core_src_files := $(call all-main-java-files-under,dalvik dex dom json luni xml)
54core_resource_dirs := $(call all-core-resource-dirs,main)
55test_resource_dirs := $(call all-core-resource-dirs,test)
56test_src_files := $(call all-test-java-files-under,dalvik dom harmony-tests json luni xml)
57
58ifeq ($(EMMA_INSTRUMENT),true)
59ifneq ($(EMMA_INSTRUMENT_STATIC),true)
60    common_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
63endif
64
65libart_core_src_files += $(common_core_src_files) $(call all-main-java-files-under,libart)
66
67local_javac_flags=-encoding UTF-8
68#local_javac_flags+=-Xlint:all -Xlint:-serial,-deprecation,-unchecked
69local_javac_flags+=-Xmaxwarns 9999999
70
71#
72# 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
93icu4j_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
99
100#
101# Build for the target (device).
102#
103
104# Definitions to make the core library.
105
106include $(CLEAR_VARS)
107LOCAL_SRC_FILES := $(libart_core_src_files) $(icu4j_src_files)
108LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) $(icu4j_resource_dirs)
109LOCAL_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
116LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
117include $(BUILD_JAVA_LIBRARY)
118
119# Path to the ICU4C data files in the Android device file system:
120icu4c_data := /system/usr/icu
121# TODO: It's quite hideous that this double-slash between icu4j and main is required.
122# It's because we provide a variable substition of the make-rule generated jar command
123# to substitute a processed ICUProperties.config file in place of the original.
124#
125# We can avoid this by filtering out ICUConfig.properties from our list of resources.
126icu4j_config_root := $(LOCAL_PATH)/../external/icu/icu4j//main/classes/core/src
127include external/icu/icu4j/adjust_icudt_path.mk
128
129ifeq ($(LIBCORE_SKIP_TESTS),)
130# Make the core-tests library.
131include $(CLEAR_VARS)
132LOCAL_SRC_FILES := $(test_src_files)
133LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
134LOCAL_NO_STANDARD_LIBRARIES := true
135LOCAL_JAVA_LIBRARIES := core-libart okhttp core-junit bouncycastle
136LOCAL_STATIC_JAVA_LIBRARIES := core-tests-support sqlite-jdbc mockwebserver nist-pkix-tests
137LOCAL_JAVACFLAGS := $(local_javac_flags)
138LOCAL_MODULE := core-tests
139LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
140include $(BUILD_STATIC_JAVA_LIBRARY)
141endif
142
143ifeq ($(LIBCORE_SKIP_TESTS),)
144# Make the core-tests-support library.
145include $(CLEAR_VARS)
146LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
147LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
148LOCAL_NO_STANDARD_LIBRARIES := true
149LOCAL_JAVA_LIBRARIES := core-libart core-junit bouncycastle
150LOCAL_JAVACFLAGS := $(local_javac_flags)
151LOCAL_MODULE := core-tests-support
152LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
153include $(BUILD_STATIC_JAVA_LIBRARY)
154endif
155
156ifeq ($(LIBCORE_SKIP_TESTS),)
157# Make the jsr166-tests library.
158include $(CLEAR_VARS)
159LOCAL_SRC_FILES :=  $(call all-test-java-files-under, jsr166-tests)
160LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
161LOCAL_NO_STANDARD_LIBRARIES := true
162LOCAL_JAVA_LIBRARIES := core-libart core-junit
163LOCAL_JAVACFLAGS := $(local_javac_flags)
164LOCAL_MODULE := jsr166-tests
165LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
166include $(BUILD_STATIC_JAVA_LIBRARY)
167endif
168
169#
170# Build for the host.
171#
172
173ifeq ($(HOST_OS),linux)
174
175include $(CLEAR_VARS)
176LOCAL_SRC_FILES := $(call all-main-java-files-under, dex)
177LOCAL_MODULE_TAGS := optional
178LOCAL_MODULE := dex-host
179include $(BUILD_HOST_JAVA_LIBRARY)
180
181# Definitions to make the core library.
182include $(CLEAR_VARS)
183LOCAL_SRC_FILES := $(libart_core_src_files) $(icu4j_src_files)
184LOCAL_JAVA_RESOURCE_DIRS := $(core_resource_dirs) $(icu4j_resource_dirs)
185LOCAL_NO_STANDARD_LIBRARIES := true
186LOCAL_JAVACFLAGS := $(local_javac_flags)
187LOCAL_DX_FLAGS := --core-library
188LOCAL_MODULE_TAGS := optional
189LOCAL_MODULE := core-libart-hostdex
190LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
191LOCAL_REQUIRED_MODULES := tzdata-host
192LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.txt
193include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
194
195# Make the core-tests library.
196ifeq ($(LIBCORE_SKIP_TESTS),)
197    include $(CLEAR_VARS)
198    LOCAL_SRC_FILES := $(test_src_files)
199    LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
200    LOCAL_NO_STANDARD_LIBRARIES := true
201    LOCAL_JAVA_LIBRARIES := core-libart-hostdex okhttp-hostdex bouncycastle-hostdex core-junit-hostdex core-tests-support-hostdex
202    LOCAL_STATIC_JAVA_LIBRARIES := sqlite-jdbc-host mockwebserver-host nist-pkix-tests-host
203    LOCAL_JAVACFLAGS := $(local_javac_flags)
204    LOCAL_MODULE_TAGS := optional
205    LOCAL_MODULE := core-tests-hostdex
206    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
207    include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
208endif
209
210# Make the core-tests-support library.
211ifeq ($(LIBCORE_SKIP_TESTS),)
212    include $(CLEAR_VARS)
213    LOCAL_SRC_FILES := $(call all-test-java-files-under,support)
214    LOCAL_JAVA_RESOURCE_DIRS := $(test_resource_dirs)
215    LOCAL_NO_STANDARD_LIBRARIES := true
216    LOCAL_JAVA_LIBRARIES := core-libart-hostdex core-junit-hostdex bouncycastle-hostdex
217    LOCAL_JAVACFLAGS := $(local_javac_flags)
218    LOCAL_MODULE_TAGS := optional
219    LOCAL_MODULE := core-tests-support-hostdex
220    LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
221    include $(BUILD_HOST_DALVIK_JAVA_LIBRARY)
222endif
223
224endif # HOST_OS == linux
225
226#
227# Local droiddoc for faster libcore testing
228#
229#
230# Run with:
231#     mm -j32 libcore-docs
232#
233# Main output:
234#     ../out/target/common/docs/libcore/reference/packages.html
235#
236# All text for proofreading (or running tools over):
237#     ../out/target/common/docs/libcore-proofread.txt
238#
239# TODO list of missing javadoc, etc:
240#     ../out/target/common/docs/libcore-docs-todo.html
241#
242# Rerun:
243#     rm -rf ../out/target/common/docs/libcore-timestamp && mm -j32 libcore-docs
244#
245include $(CLEAR_VARS)
246
247# for shared defintion of libcore_to_document
248include $(LOCAL_PATH)/Docs.mk
249
250LOCAL_SRC_FILES := $(libcore_to_document)
251# rerun doc generation without recompiling the java
252LOCAL_JAVA_LIBRARIES:=
253LOCAL_JAVACFLAGS := $(local_javac_flags)
254LOCAL_MODULE_CLASS:=JAVA_LIBRARIES
255
256LOCAL_MODULE := libcore
257LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/JavaLibrary.mk
258
259LOCAL_DROIDDOC_OPTIONS := \
260 -offlinemode \
261 -title "libcore" \
262 -proofread $(OUT_DOCS)/$(LOCAL_MODULE)-proofread.txt \
263 -todo ../$(LOCAL_MODULE)-docs-todo.html \
264 -hdf android.whichdoc offline
265
266LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:=build/tools/droiddoc/templates-sdk
267
268include $(BUILD_DROIDDOC)
269