blob: 517cc055220bc49c76ea5fcec5b0de50deb2a33d [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.
Andreas Gampe24a20172018-06-13 11:28:45 -070058 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -080059 ],
60 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070061}
62
63//
64// Build for the target (device).
65//
66
67java_library {
68 name: "core-all",
69 defaults: ["libcore_java_defaults"],
70
71 srcs: [
72 ":openjdk_java_files",
73 ":non_openjdk_java_files",
74 ":android_icu4j_src_files",
75 ":openjdk_lambda_stub_files",
76 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -070077 openjdk9: {
78 srcs: ["luni/src/module/java/module-info.java"],
79 javacflags: ["--patch-module=java.base=."],
80 },
Colin Crossaf0b54c2017-09-27 17:22:32 -070081 java_resource_dirs: core_resource_dirs,
Colin Crossa4d9fc42017-09-29 18:04:37 -070082 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -070083
84 required: [
85 "tzdata",
86 "tzlookup.xml",
87 ],
88
Colin Crossa4d9fc42017-09-29 18:04:37 -070089 system_modules: "none",
90
Colin Crossaf0b54c2017-09-27 17:22:32 -070091 installable: false,
92}
93
Colin Crossa4d9fc42017-09-29 18:04:37 -070094java_system_modules {
95 name: "core-all-system-modules",
96 libs: ["core-all"],
97}
98
Colin Crossaf0b54c2017-09-27 17:22:32 -070099java_library {
100 name: "core-oj",
101 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700102 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700103 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700104
105 srcs: [":openjdk_java_files"],
106 java_resource_dirs: core_resource_dirs,
107 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700108 system_modules: "core-all-system-modules",
109 openjdk9: {
110 javacflags: ["--patch-module=java.base=."],
111 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700112
113 notice: "ojluni/NOTICE",
114
115 required: [
116 "tzdata",
117 "tzlookup.xml",
118 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700119
Colin Crossaf0b54c2017-09-27 17:22:32 -0700120}
121
122// Definitions to make the core library.
123java_library {
124 name: "core-libart",
125 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700126 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700127 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700128
129 srcs: [
130 ":non_openjdk_java_files",
131 ":android_icu4j_src_files",
132 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700133 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700134
135 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700136 system_modules: "core-all-system-modules",
137 openjdk9: {
138 javacflags: ["--patch-module=java.base=."],
139 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700140
141 required: [
142 "tzdata",
143 "tzlookup.xml",
144 ],
145}
146
Colin Cross3c6c2e22017-10-18 13:24:52 -0700147// A guaranteed unstripped version of core-oj and core-libart.
148// The build system may or may not strip the core-oj and core-libart jars,
149// but these will not be stripped. See b/24535627.
150java_library {
151 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700152 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700153 static_libs: ["core-oj"],
154 no_standard_libs: true,
155 libs: ["core-all"],
156 system_modules: "core-all-system-modules",
157 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800158 dex_preopt: {
159 enabled: false,
160 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700161 notice: "ojluni/NOTICE",
162 required: [
163 "tzdata",
164 "tzlookup.xml",
165 ],
166}
167
168java_library {
169 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700170 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700171 static_libs: ["core-libart"],
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
Colin Crossaf0b54c2017-09-27 17:22:32 -0700186// A library that exists to satisfy javac when
187// compiling source code that contains lambdas.
188java_library {
189 name: "core-lambda-stubs",
190 defaults: ["libcore_java_defaults"],
191
192 srcs: [
193 ":openjdk_lambda_stub_files",
194 ":openjdk_lambda_duplicate_stub_files",
195 ],
196
197 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700198 system_modules: "core-all-system-modules",
199 openjdk9: {
200 javacflags: ["--patch-module=java.base=."],
201 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700202
203 notice: "ojluni/NOTICE",
204
205 installable: false,
206 include_srcs: true,
207}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700208
209java_system_modules {
210 name: "core-system-modules",
211 libs: [
212 "core-oj",
213 "core-libart",
214 "core-lambda-stubs",
215 ],
216}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700217
218// Build libcore test rules
219java_library_static {
220 name: "core-test-rules",
221 hostdex: true,
222 no_framework_libs: true,
223 srcs: [
224 "dalvik/test-rules/src/main/**/*.java",
225 "test-rules/src/main/**/*.java",
226 ],
227 static_libs: ["junit"],
228}
229
230// Make the core-tests-support library.
231java_library_static {
232 name: "core-tests-support",
233 hostdex: true,
234 no_framework_libs: true,
235 srcs: ["support/src/test/java/**/*.java"],
236 libs: [
237 "junit",
238 "bouncycastle",
239 ],
240 static_libs: [
241 "bouncycastle-bcpkix",
242 "bouncycastle-ocsp",
243 ],
244}
245
246// Make the jsr166-tests library.
247java_library_static {
248 name: "jsr166-tests",
249 srcs: ["jsr166-tests/src/test/java/**/*.java"],
250 no_framework_libs: true,
251 libs: [
252 "junit",
253 ],
254}
Nan Zhang65f27a32018-01-05 10:41:46 -0800255
256genrule {
257 name: "gen-ojluni-jaif-annotated-srcs",
258 tools: [
259 "gen-annotated-java-files-bp",
260 "soong_zip",
261 ],
262 tool_files: [
263 ":insert-annotations-to-source",
264 "annotations/ojluni.jaif",
265 ],
266 srcs: [
267 ":annotated_ojluni_files",
268 ],
269 cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800270 "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800271 "(echo -e \"********************\" >&2; " +
272 " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " +
273 " 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 -0800274 " echo -e \"********************\" >&2; exit 1) ) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800275 "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800276 "(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 -0800277 "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
278 out: [
279 "ojluni_jaif_annotated_srcs.srcjar",
280 ],
281}
282
Nan Zhang3824a822018-03-21 21:41:02 +0000283//
284// Local droiddoc for faster libcore testing
285//
286// Run with:
287// mm -j32 core-docs
288//
289// Main output:
290// ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/reference/packages.html
291//
292// All text for proofreading (or running tools over):
293// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
294//
295// TODO list of missing javadoc, etc:
296// ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/core-docs-todo.html
297//
Nan Zhang65f27a32018-01-05 10:41:46 -0800298droiddoc {
299 name: "core-docs",
300 srcs: [
301 ":openjdk_javadoc_files",
302 ":non_openjdk_javadoc_files",
303 ":android_icu4j_src_files_for_docs",
304 ":gen-ojluni-jaif-annotated-srcs",
305 ],
306 exclude_srcs: [
307 ":annotated_ojluni_files",
308 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800309 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800310 hdf: [
311 "android.whichdoc offline",
312 ],
313 knowntags: [
314 "known_oj_tags.txt",
315 ],
316 proofread_file: "core-docs-proofread.txt",
317 todo_file: "core-docs-todo.html",
318 args: "-offlinemode -title \"libcore\"",
319}
Nan Zhangd55722b2018-02-27 15:08:20 -0800320
321filegroup {
322 name: "known-oj-tags",
323 srcs: [
324 "known_oj_tags.txt",
325 ],
326}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700327
328droiddoc {
329 name: "core-current-stubs-gen-docs",
330 srcs: [
331 ":openjdk_javadoc_files",
332 ":non_openjdk_javadoc_files",
333 ":android_icu4j_src_files_for_docs",
334 ":gen-ojluni-jaif-annotated-srcs",
335 ],
336 exclude_srcs: [
337 ":annotated_ojluni_files",
338 ],
339 custom_template: "droiddoc-templates-sdk",
340 installable: false,
341 no_framework_libs: true,
342 args: "-nodocs",
343}
344
345java_library_static {
346 name: "core.current.stubs",
347 srcs: [
348 ":core-current-stubs-gen-docs",
349 ],
350 errorprone: {
351 javacflags: [
352 "-Xep:MissingOverride:OFF",
353 ],
354 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100355 openjdk9: {
356 javacflags: ["--patch-module=java.base=."],
357 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700358 no_standard_libs: true,
359 system_modules: "none",
360}