blob: 378aca231a418bf6cf89ac80f57d2e10d5ef5b94 [file] [log] [blame]
Colin Crossaf0b54c2017-09-27 17:22:32 -07001// Copyright (C) 2007 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//
16// Definitions for building the Java library and associated tests.
17//
18
19// libcore is divided into modules.
20//
21// The structure of each module is:
22//
23// src/
24// main/ # To be shipped on every device.
25// java/ # Java source for library code.
26// native/ # C++ source for library code.
27// resources/ # Support files.
28// test/ # Built only on demand, for testing.
29// java/ # Java source for tests.
30// native/ # C++ source for tests (rare).
31// resources/ # Support files.
32//
33// All subdirectories are optional
34
35build = [
36 "openjdk_java_files.bp",
37 "non_openjdk_java_files.bp",
Colin Crossfb7218e2017-10-27 17:50:42 +000038 "annotated_java_files.bp",
Colin Crossaf0b54c2017-09-27 17:22:32 -070039]
40
41// The Java files and their associated resources.
42core_resource_dirs = [
43 "luni/src/main/java",
44 "ojluni/src/main/resources/",
45]
46
47java_defaults {
48 name: "libcore_java_defaults",
49 javacflags: [
50 //"-Xlint:all",
51 //"-Xlint:-serial,-deprecation,-unchecked",
52 ],
53 dxflags: ["--core-library"],
54 no_standard_libs: true,
Andreas Gampe66b31732018-02-20 09:22:16 -080055 errorprone: {
56 javacflags: [
57 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
58 ],
59 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070060}
61
62//
63// Build for the target (device).
64//
65
66java_library {
67 name: "core-all",
68 defaults: ["libcore_java_defaults"],
69
70 srcs: [
71 ":openjdk_java_files",
72 ":non_openjdk_java_files",
73 ":android_icu4j_src_files",
74 ":openjdk_lambda_stub_files",
75 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -070076 openjdk9: {
77 srcs: ["luni/src/module/java/module-info.java"],
78 javacflags: ["--patch-module=java.base=."],
79 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070080 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -070081 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -070082
83 required: [
84 "tzdata",
85 "tzlookup.xml",
86 ],
87
Colin Crossa4d9fc42017-09-29 18:04:37 -070088 system_modules: "none",
89
Colin Crossaf0b54c2017-09-27 17:22:32 -070090 installable: false,
91}
92
Colin Crossa4d9fc42017-09-29 18:04:37 -070093java_system_modules {
94 name: "core-all-system-modules",
95 libs: ["core-all"],
96}
97
Colin Crossaf0b54c2017-09-27 17:22:32 -070098java_library {
99 name: "core-oj",
100 defaults: ["libcore_java_defaults"],
Colin Crossbb180be2017-10-09 14:54:53 -0700101 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700102
103 srcs: [":openjdk_java_files"],
104 java_resource_dirs: core_resource_dirs,
105 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700106 system_modules: "core-all-system-modules",
107 openjdk9: {
108 javacflags: ["--patch-module=java.base=."],
109 },
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000110 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000111 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000112 "java.lang.Class",
113 "java.lang.Long",
114 "java.lang.Number",
115 "java.lang.Object",
116 "java.lang.String",
117 "java.lang.invoke.MethodHandle",
118 "java.lang.ref.Reference",
119 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000120 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000121 "java.util.HashMap",
122 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000123 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000124 ],
125 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700126
127 notice: "ojluni/NOTICE",
128
129 required: [
130 "tzdata",
131 "tzlookup.xml",
132 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700133
Colin Crossaf0b54c2017-09-27 17:22:32 -0700134}
135
136// Definitions to make the core library.
137java_library {
138 name: "core-libart",
139 defaults: ["libcore_java_defaults"],
Colin Crossbb180be2017-10-09 14:54:53 -0700140 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700141
142 srcs: [
143 ":non_openjdk_java_files",
144 ":android_icu4j_src_files",
145 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700146 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700147
148 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700149 system_modules: "core-all-system-modules",
150 openjdk9: {
151 javacflags: ["--patch-module=java.base=."],
152 },
Pete Gillin80ebe872018-02-13 15:21:20 +0000153 jacoco: {
154 exclude_filter: [
155 "java.lang.DexCache",
156 "dalvik.system.ClassExt",
157 ],
158 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700159
160 required: [
161 "tzdata",
162 "tzlookup.xml",
163 ],
164}
165
Colin Cross3c6c2e22017-10-18 13:24:52 -0700166// A guaranteed unstripped version of core-oj and core-libart.
167// The build system may or may not strip the core-oj and core-libart jars,
168// but these will not be stripped. See b/24535627.
169java_library {
170 name: "core-oj-testdex",
171 static_libs: ["core-oj"],
172 no_standard_libs: true,
173 libs: ["core-all"],
174 system_modules: "core-all-system-modules",
175 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800176 dex_preopt: {
177 enabled: false,
178 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700179 notice: "ojluni/NOTICE",
180 required: [
181 "tzdata",
182 "tzlookup.xml",
183 ],
184}
185
186java_library {
187 name: "core-libart-testdex",
188 static_libs: ["core-libart"],
189 no_standard_libs: true,
190 libs: ["core-all"],
191 system_modules: "core-all-system-modules",
192 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800193 dex_preopt: {
194 enabled: false,
195 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700196 notice: "ojluni/NOTICE",
197 required: [
198 "tzdata",
199 "tzlookup.xml",
200 ],
201}
202
Colin Crossaf0b54c2017-09-27 17:22:32 -0700203// A library that exists to satisfy javac when
204// compiling source code that contains lambdas.
205java_library {
206 name: "core-lambda-stubs",
207 defaults: ["libcore_java_defaults"],
208
209 srcs: [
210 ":openjdk_lambda_stub_files",
211 ":openjdk_lambda_duplicate_stub_files",
212 ],
213
214 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700215 system_modules: "core-all-system-modules",
216 openjdk9: {
217 javacflags: ["--patch-module=java.base=."],
218 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700219
220 notice: "ojluni/NOTICE",
221
222 installable: false,
223 include_srcs: true,
224}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700225
226java_system_modules {
227 name: "core-system-modules",
228 libs: [
229 "core-oj",
230 "core-libart",
231 "core-lambda-stubs",
232 ],
233}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700234
235// Build libcore test rules
236java_library_static {
237 name: "core-test-rules",
238 hostdex: true,
239 no_framework_libs: true,
240 srcs: [
241 "dalvik/test-rules/src/main/**/*.java",
242 "test-rules/src/main/**/*.java",
243 ],
244 static_libs: ["junit"],
245}
246
247// Make the core-tests-support library.
248java_library_static {
249 name: "core-tests-support",
250 hostdex: true,
251 no_framework_libs: true,
252 srcs: ["support/src/test/java/**/*.java"],
253 libs: [
254 "junit",
255 "bouncycastle",
256 ],
257 static_libs: [
258 "bouncycastle-bcpkix",
259 "bouncycastle-ocsp",
260 ],
261}
262
263// Make the jsr166-tests library.
264java_library_static {
265 name: "jsr166-tests",
266 srcs: ["jsr166-tests/src/test/java/**/*.java"],
267 no_framework_libs: true,
268 libs: [
269 "junit",
270 ],
271}
Nan Zhang65f27a32018-01-05 10:41:46 -0800272
273genrule {
274 name: "gen-ojluni-jaif-annotated-srcs",
275 tools: [
276 "gen-annotated-java-files-bp",
277 "soong_zip",
278 ],
279 tool_files: [
280 ":insert-annotations-to-source",
281 "annotations/ojluni.jaif",
282 ],
283 srcs: [
284 ":annotated_ojluni_files",
285 ],
286 cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800287 "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800288 "(echo -e \"********************\" >&2; " +
289 " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " +
290 " echo -e \"libcore/annotations/generate_annotated_java_files.py libcore/annotations/ojluni.jaif > libcore/annotated_java_files.bp\" >&2; " +
Nan Zhang8c561442018-02-27 17:21:49 -0800291 " echo -e \"********************\" >&2; exit 1) ) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800292 "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800293 "(external/annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -d $(genDir) $(location annotations/ojluni.jaif) $(in)) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800294 "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
295 out: [
296 "ojluni_jaif_annotated_srcs.srcjar",
297 ],
298}
299
300droiddoc {
301 name: "core-docs",
302 srcs: [
303 ":openjdk_javadoc_files",
304 ":non_openjdk_javadoc_files",
305 ":android_icu4j_src_files_for_docs",
306 ":gen-ojluni-jaif-annotated-srcs",
307 ],
308 exclude_srcs: [
309 ":annotated_ojluni_files",
310 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800311 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800312 hdf: [
313 "android.whichdoc offline",
314 ],
315 knowntags: [
316 "known_oj_tags.txt",
317 ],
318 proofread_file: "core-docs-proofread.txt",
319 todo_file: "core-docs-todo.html",
320 args: "-offlinemode -title \"libcore\"",
321}