1// 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",
38    "annotated_java_files.bp",
39]
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,
55    errorprone: {
56        javacflags: [
57            "-Xep:MissingOverride:OFF",  // Ignore missing @Override.
58        ],
59    },
60}
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    ],
76    openjdk9: {
77        srcs: ["luni/src/module/java/module-info.java"],
78        javacflags: ["--patch-module=java.base=."],
79    },
80    java_resource_dirs: core_resource_dirs,
81    java_resources: [":android_icu4j_resources"],
82
83    required: [
84        "tzdata",
85        "tzlookup.xml",
86    ],
87
88    system_modules: "none",
89
90    installable: false,
91}
92
93java_system_modules {
94    name: "core-all-system-modules",
95    libs: ["core-all"],
96}
97
98java_library {
99    name: "core-oj",
100    defaults: ["libcore_java_defaults"],
101    hostdex: true,
102
103    srcs: [":openjdk_java_files"],
104    java_resource_dirs: core_resource_dirs,
105    libs: ["core-all"],
106    system_modules: "core-all-system-modules",
107    openjdk9: {
108        javacflags: ["--patch-module=java.base=."],
109    },
110    jacoco: {
111        exclude_filter: [
112            "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",
120            "java.util.AbstractMap",
121            "java.util.HashMap",
122            "java.util.HashMap$Node",
123            "java.util.Map",
124        ],
125    },
126
127    notice: "ojluni/NOTICE",
128
129    required: [
130        "tzdata",
131        "tzlookup.xml",
132    ],
133
134}
135
136// Definitions to make the core library.
137java_library {
138    name: "core-libart",
139    defaults: ["libcore_java_defaults"],
140    hostdex: true,
141
142    srcs: [
143        ":non_openjdk_java_files",
144        ":android_icu4j_src_files",
145    ],
146    java_resources: [":android_icu4j_resources"],
147
148    libs: ["core-all"],
149    system_modules: "core-all-system-modules",
150    openjdk9: {
151        javacflags: ["--patch-module=java.base=."],
152    },
153    jacoco: {
154        exclude_filter: [
155            "java.lang.DexCache",
156            "dalvik.system.ClassExt",
157        ],
158    },
159
160    required: [
161        "tzdata",
162        "tzlookup.xml",
163    ],
164}
165
166// 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"],
176    dex_preopt: {
177        enabled: false,
178    },
179    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"],
193    dex_preopt: {
194        enabled: false,
195    },
196    notice: "ojluni/NOTICE",
197    required: [
198        "tzdata",
199        "tzlookup.xml",
200    ],
201}
202
203// 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"],
215    system_modules: "core-all-system-modules",
216    openjdk9: {
217        javacflags: ["--patch-module=java.base=."],
218    },
219
220    notice: "ojluni/NOTICE",
221
222    installable: false,
223    include_srcs: true,
224}
225
226java_system_modules {
227    name: "core-system-modules",
228    libs: [
229        "core-oj",
230        "core-libart",
231        "core-lambda-stubs",
232    ],
233}
234
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}
272
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) && " +
287         "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " +
288         "(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; " +
291         " echo -e \"********************\" >&2; exit 1) ) && " +
292         "(rm $(genDir)/annotated_java_files.bp.tmp) && " +
293         "(external/annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -d $(genDir) $(location annotations/ojluni.jaif) $(in)) && " +
294         "($(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    ],
311    custom_template: "droiddoc-templates-sdk",
312    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}
322