blob: 21588e91d13b5073127c775135a880c938973462 [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
Pete Gillin7db7faa2018-07-31 13:29:35 +0100283// Make the annotated stubs in ojluni/annotations available to metalava:
284droiddoc_exported_dir {
285 name: "ojluni-annotated-stubs",
286 path: "ojluni/annotations",
287}
288
Nan Zhang3824a822018-03-21 21:41:02 +0000289//
290// Local droiddoc for faster libcore testing
291//
292// Run with:
293// mm -j32 core-docs
294//
295// Main output:
296// ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/reference/packages.html
297//
298// All text for proofreading (or running tools over):
299// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
300//
301// TODO list of missing javadoc, etc:
302// ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/core-docs-todo.html
303//
Nan Zhang65f27a32018-01-05 10:41:46 -0800304droiddoc {
305 name: "core-docs",
306 srcs: [
307 ":openjdk_javadoc_files",
308 ":non_openjdk_javadoc_files",
309 ":android_icu4j_src_files_for_docs",
310 ":gen-ojluni-jaif-annotated-srcs",
311 ],
312 exclude_srcs: [
313 ":annotated_ojluni_files",
314 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800315 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800316 hdf: [
317 "android.whichdoc offline",
318 ],
319 knowntags: [
320 "known_oj_tags.txt",
321 ],
322 proofread_file: "core-docs-proofread.txt",
323 todo_file: "core-docs-todo.html",
324 args: "-offlinemode -title \"libcore\"",
325}
Nan Zhangd55722b2018-02-27 15:08:20 -0800326
327filegroup {
328 name: "known-oj-tags",
329 srcs: [
330 "known_oj_tags.txt",
331 ],
332}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700333
334droiddoc {
335 name: "core-current-stubs-gen-docs",
336 srcs: [
337 ":openjdk_javadoc_files",
338 ":non_openjdk_javadoc_files",
339 ":android_icu4j_src_files_for_docs",
340 ":gen-ojluni-jaif-annotated-srcs",
341 ],
342 exclude_srcs: [
343 ":annotated_ojluni_files",
344 ],
345 custom_template: "droiddoc-templates-sdk",
346 installable: false,
347 no_framework_libs: true,
348 args: "-nodocs",
349}
350
351java_library_static {
352 name: "core.current.stubs",
353 srcs: [
354 ":core-current-stubs-gen-docs",
355 ],
356 errorprone: {
357 javacflags: [
358 "-Xep:MissingOverride:OFF",
359 ],
360 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100361 openjdk9: {
362 javacflags: ["--patch-module=java.base=."],
363 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700364 no_standard_libs: true,
365 system_modules: "none",
366}