blob: a690c20778032a798de271ec0c92ff579692600b [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 Crossbb180be2017-10-09 14:54:53 -0700102 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700103
104 srcs: [":openjdk_java_files"],
105 java_resource_dirs: core_resource_dirs,
106 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700107 system_modules: "core-all-system-modules",
108 openjdk9: {
109 javacflags: ["--patch-module=java.base=."],
110 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700111
112 notice: "ojluni/NOTICE",
113
114 required: [
115 "tzdata",
116 "tzlookup.xml",
117 ],
Colin Crossbb180be2017-10-09 14:54:53 -0700118
Colin Crossaf0b54c2017-09-27 17:22:32 -0700119}
120
121// Definitions to make the core library.
122java_library {
123 name: "core-libart",
124 defaults: ["libcore_java_defaults"],
Colin Crossbb180be2017-10-09 14:54:53 -0700125 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700126
127 srcs: [
128 ":non_openjdk_java_files",
129 ":android_icu4j_src_files",
130 ],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700131 java_resources: [":android_icu4j_resources"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700132
133 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700134 system_modules: "core-all-system-modules",
135 openjdk9: {
136 javacflags: ["--patch-module=java.base=."],
137 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700138
139 required: [
140 "tzdata",
141 "tzlookup.xml",
142 ],
143}
144
Colin Cross3c6c2e22017-10-18 13:24:52 -0700145// A guaranteed unstripped version of core-oj and core-libart.
146// The build system may or may not strip the core-oj and core-libart jars,
147// but these will not be stripped. See b/24535627.
148java_library {
149 name: "core-oj-testdex",
150 static_libs: ["core-oj"],
151 no_standard_libs: true,
152 libs: ["core-all"],
153 system_modules: "core-all-system-modules",
154 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800155 dex_preopt: {
156 enabled: false,
157 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700158 notice: "ojluni/NOTICE",
159 required: [
160 "tzdata",
161 "tzlookup.xml",
162 ],
163}
164
165java_library {
166 name: "core-libart-testdex",
167 static_libs: ["core-libart"],
168 no_standard_libs: true,
169 libs: ["core-all"],
170 system_modules: "core-all-system-modules",
171 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800172 dex_preopt: {
173 enabled: false,
174 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700175 notice: "ojluni/NOTICE",
176 required: [
177 "tzdata",
178 "tzlookup.xml",
179 ],
180}
181
Colin Crossaf0b54c2017-09-27 17:22:32 -0700182// A library that exists to satisfy javac when
183// compiling source code that contains lambdas.
184java_library {
185 name: "core-lambda-stubs",
186 defaults: ["libcore_java_defaults"],
187
188 srcs: [
189 ":openjdk_lambda_stub_files",
190 ":openjdk_lambda_duplicate_stub_files",
191 ],
192
193 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700194 system_modules: "core-all-system-modules",
195 openjdk9: {
196 javacflags: ["--patch-module=java.base=."],
197 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700198
199 notice: "ojluni/NOTICE",
200
201 installable: false,
202 include_srcs: true,
203}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700204
205java_system_modules {
206 name: "core-system-modules",
207 libs: [
208 "core-oj",
209 "core-libart",
210 "core-lambda-stubs",
211 ],
212}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700213
214// Build libcore test rules
215java_library_static {
216 name: "core-test-rules",
217 hostdex: true,
218 no_framework_libs: true,
219 srcs: [
220 "dalvik/test-rules/src/main/**/*.java",
221 "test-rules/src/main/**/*.java",
222 ],
223 static_libs: ["junit"],
224}
225
226// Make the core-tests-support library.
227java_library_static {
228 name: "core-tests-support",
229 hostdex: true,
230 no_framework_libs: true,
231 srcs: ["support/src/test/java/**/*.java"],
232 libs: [
233 "junit",
234 "bouncycastle",
235 ],
236 static_libs: [
237 "bouncycastle-bcpkix",
238 "bouncycastle-ocsp",
239 ],
240}
241
242// Make the jsr166-tests library.
243java_library_static {
244 name: "jsr166-tests",
245 srcs: ["jsr166-tests/src/test/java/**/*.java"],
246 no_framework_libs: true,
247 libs: [
248 "junit",
249 ],
250}
Nan Zhang65f27a32018-01-05 10:41:46 -0800251
252genrule {
253 name: "gen-ojluni-jaif-annotated-srcs",
254 tools: [
255 "gen-annotated-java-files-bp",
256 "soong_zip",
257 ],
258 tool_files: [
259 ":insert-annotations-to-source",
260 "annotations/ojluni.jaif",
261 ],
262 srcs: [
263 ":annotated_ojluni_files",
264 ],
265 cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800266 "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800267 "(echo -e \"********************\" >&2; " +
268 " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " +
269 " 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 -0800270 " echo -e \"********************\" >&2; exit 1) ) && " +
Nan Zhang65f27a32018-01-05 10:41:46 -0800271 "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
Nan Zhang8c561442018-02-27 17:21:49 -0800272 "(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 -0800273 "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))",
274 out: [
275 "ojluni_jaif_annotated_srcs.srcjar",
276 ],
277}
278
Nan Zhang3824a822018-03-21 21:41:02 +0000279//
280// Local droiddoc for faster libcore testing
281//
282// Run with:
283// mm -j32 core-docs
284//
285// Main output:
286// ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/reference/packages.html
287//
288// All text for proofreading (or running tools over):
289// ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt
290//
291// TODO list of missing javadoc, etc:
292// ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/core-docs-todo.html
293//
Nan Zhang65f27a32018-01-05 10:41:46 -0800294droiddoc {
295 name: "core-docs",
296 srcs: [
297 ":openjdk_javadoc_files",
298 ":non_openjdk_javadoc_files",
299 ":android_icu4j_src_files_for_docs",
300 ":gen-ojluni-jaif-annotated-srcs",
301 ],
302 exclude_srcs: [
303 ":annotated_ojluni_files",
304 ],
Dan Willemsenf2b04582018-02-26 14:36:32 -0800305 custom_template: "droiddoc-templates-sdk",
Nan Zhang65f27a32018-01-05 10:41:46 -0800306 hdf: [
307 "android.whichdoc offline",
308 ],
309 knowntags: [
310 "known_oj_tags.txt",
311 ],
312 proofread_file: "core-docs-proofread.txt",
313 todo_file: "core-docs-todo.html",
314 args: "-offlinemode -title \"libcore\"",
315}
Nan Zhangd55722b2018-02-27 15:08:20 -0800316
317filegroup {
318 name: "known-oj-tags",
319 srcs: [
320 "known_oj_tags.txt",
321 ],
322}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700323
324droiddoc {
325 name: "core-current-stubs-gen-docs",
326 srcs: [
327 ":openjdk_javadoc_files",
328 ":non_openjdk_javadoc_files",
329 ":android_icu4j_src_files_for_docs",
330 ":gen-ojluni-jaif-annotated-srcs",
331 ],
332 exclude_srcs: [
333 ":annotated_ojluni_files",
334 ],
335 custom_template: "droiddoc-templates-sdk",
336 installable: false,
337 no_framework_libs: true,
338 args: "-nodocs",
339}
340
341java_library_static {
342 name: "core.current.stubs",
343 srcs: [
344 ":core-current-stubs-gen-docs",
345 ],
346 errorprone: {
347 javacflags: [
348 "-Xep:MissingOverride:OFF",
349 ],
350 },
Tobias Thierer496a9382018-06-12 14:09:11 +0100351 openjdk9: {
352 javacflags: ["--patch-module=java.base=."],
353 },
Nan Zhang602fc0e2018-03-22 16:14:22 -0700354 no_standard_libs: true,
355 system_modules: "none",
356}