blob: f446439ebf76d4c16f2563a1bfefd78274178c91 [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//
Neil Fuller77e3f3b2018-10-19 10:22:32 +010016// Definitions for building the Android core library and associated tests.
Colin Crossaf0b54c2017-09-27 17:22:32 -070017//
18
Neil Fuller77e3f3b2018-10-19 10:22:32 +010019// The Android core library provides low-level APIs for use by the rest of the
20// Android software stack. It is made up of various parts, some of which can be
21// found in libcore/ and other parts that can be found in various external/
22// directories. See the "core-system-modules" definition for the parts.
23
Neil Fullercf756882018-08-28 18:42:22 +010024// libcore has some sub-directories that follow a common structure:
25// e.g. dalvik, dom, harmony-tests, json, jsr166-tests, luni, libart, ojluni,
26// support, xml, xmlpull.
Colin Crossaf0b54c2017-09-27 17:22:32 -070027//
Neil Fullercf756882018-08-28 18:42:22 +010028// The structure of these is generally:
Colin Crossaf0b54c2017-09-27 17:22:32 -070029//
30// src/
31// main/ # To be shipped on every device.
32// java/ # Java source for library code.
Neil Fullercf756882018-08-28 18:42:22 +010033// native/ # C/C++ source for library code.
Colin Crossaf0b54c2017-09-27 17:22:32 -070034// resources/ # Support files.
35// test/ # Built only on demand, for testing.
36// java/ # Java source for tests.
Neil Fullercf756882018-08-28 18:42:22 +010037// native/ # C/C++ source for tests (rare).
Colin Crossaf0b54c2017-09-27 17:22:32 -070038// resources/ # Support files.
39//
Neil Fullercf756882018-08-28 18:42:22 +010040// All subdirectories are optional.
Colin Crossaf0b54c2017-09-27 17:22:32 -070041
42build = [
43 "openjdk_java_files.bp",
44 "non_openjdk_java_files.bp",
45]
46
47// The Java files and their associated resources.
48core_resource_dirs = [
49 "luni/src/main/java",
50 "ojluni/src/main/resources/",
51]
52
Neil Fuller866ed4a2018-09-06 12:05:46 +010053// The source files that go into core-oj.
54filegroup {
55 name: "core_oj_java_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +010056 visibility: [
57 "//libcore:__subpackages__",
58 ],
Neil Fuller866ed4a2018-09-06 12:05:46 +010059 srcs: [":openjdk_java_files"],
60}
61
Neil Fullere32e2e12019-02-26 11:48:30 +000062// OpenJDK source is not annotated with @hide so we need this separate
Neil Fuller866ed4a2018-09-06 12:05:46 +010063// filegroup for just the parts that contribute to the API.
64filegroup {
65 name: "core_oj_api_files",
66 srcs: [":openjdk_javadoc_files"],
67}
68
69// The source files that go into core-libart.
70filegroup {
71 name: "core_libart_java_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +010072 visibility: [
73 "//libcore:__subpackages__",
74 ],
Neil Fuller866ed4a2018-09-06 12:05:46 +010075 srcs: [
76 ":non_openjdk_java_files",
77 ":android_icu4j_src_files",
78 ],
79}
80
Neil Fullere32e2e12019-02-26 11:48:30 +000081// Some parts of libart are not annotated with @hide so we need this separate
Neil Fuller866ed4a2018-09-06 12:05:46 +010082// filegroup for just the parts that contribute to the API.
83filegroup {
84 name: "core_libart_api_files",
85 srcs: [
86 ":non_openjdk_javadoc_files",
87 ":android_icu4j_src_files",
88 ],
89}
90
Neil Fullere32e2e12019-02-26 11:48:30 +000091// The set of files for the core library that have been marked up with @hide
92// for the public SDK APIs. Used from frameworks/base/ to indicate the source
93// files for inclusion in the public SDK docs.
94filegroup {
95 name: "core_public_api_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +010096 visibility: [
97 "//frameworks/base",
98 ],
Neil Fullere32e2e12019-02-26 11:48:30 +000099 srcs: [
100 ":core_oj_api_files",
101 ":core_libart_api_files",
102 ":conscrypt_public_api_files",
103 ],
104}
105
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100106// The set of files for the core library that have been marked up with @hide and
107// API-related annotations. Note that this includes the intra-core and
108// core-platform APIs as well as the public APIs.
109//
Neil Fullere32e2e12019-02-26 11:48:30 +0000110// Some source files in :core_oj_api_files and :openjdk_mmodule_extra_files are
111// annotated by applying annotations to the .annotated.java stubs files in
112// ojluni/annotated/mmodules and rather than in the original source. See the comments
113// in openjdk_java_files.bp for more details.
Neil Fuller866ed4a2018-09-06 12:05:46 +0100114filegroup {
115 name: "core_api_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100116 visibility: [
117 "//libcore:__subpackages__",
118 ],
Neil Fuller866ed4a2018-09-06 12:05:46 +0100119 srcs: [
Neil Fullerd129bc92018-09-26 11:12:58 +0100120 ":apache-xml_api_files",
Neil Fullera77f7102018-09-21 19:04:41 +0100121 ":bouncycastle_java_files",
Neil Fuller603e1a72018-09-25 11:55:41 +0100122 ":conscrypt_java_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100123 ":core_oj_api_files",
124 ":core_libart_api_files",
Neil Fuller641d5f92018-09-24 15:40:39 +0100125 ":okhttp_api_files",
Pete Gillinc9935b62018-09-25 14:42:40 +0100126 ":openjdk_mmodule_extra_files",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100127 ],
128}
129
Colin Crossaf0b54c2017-09-27 17:22:32 -0700130java_defaults {
131 name: "libcore_java_defaults",
132 javacflags: [
133 //"-Xlint:all",
134 //"-Xlint:-serial,-deprecation,-unchecked",
135 ],
136 dxflags: ["--core-library"],
Andreas Gampe66b31732018-02-20 09:22:16 -0800137 errorprone: {
138 javacflags: [
Paul Duffinc31f6bb2019-05-15 12:32:44 +0100139 "-Xep:MissingOverride:OFF", // Ignore missing @Override.
140 "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom
Andreas Gampe66b31732018-02-20 09:22:16 -0800141 ],
142 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700143}
144
145//
146// Build for the target (device).
147//
148
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100149// Visibility of core-all* build modules; we restrict visibility of core-all deliberately to
150// a small set of build modules that the core library team control. See core-all-system-modules
151// for more details.
152core_all_visibility = [
153 "//external/apache-harmony:__subpackages__",
154 "//external/apache-xml",
155 "//external/bouncycastle",
156 "//external/conscrypt",
157 "//external/icu/android_icu4j",
158 "//external/okhttp",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100159 "//libcore:__subpackages__",
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100160]
161
Tobias Thierer52331642019-05-29 12:11:39 +0000162// A target used to bootstrap compilation for the core library.
163// See core-all-system-modules for more details.
164java_library {
165 name: "core-all",
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100166 visibility: core_all_visibility,
Tobias Thierer52331642019-05-29 12:11:39 +0000167 defaults: ["libcore_java_defaults"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700168
169 srcs: [
Neil Fuller866ed4a2018-09-06 12:05:46 +0100170 ":core_oj_java_files",
171 ":core_libart_java_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700172 ":openjdk_lambda_stub_files",
Pete Gillin54035812019-05-08 15:09:39 +0100173 ":openjdk_generated_annotation_stub_files",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700174 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700175
Paul Duffin83c25382019-06-07 14:10:49 +0100176 sdk_version: "none",
Colin Crossec80f4f2018-08-15 21:17:11 -0700177 system_modules: "none",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700178 openjdk9: {
179 srcs: ["luni/src/module/java/module-info.java"],
180 javacflags: ["--patch-module=java.base=."],
181 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700182
Colin Crossaf0b54c2017-09-27 17:22:32 -0700183 java_resource_dirs: core_resource_dirs,
Victor Chang7fef4052018-09-25 14:12:03 +0100184 static_libs: ["android_icu4j_resources_lib"],
Tobias Thiererde991232018-03-07 15:10:46 +0000185 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700186
Colin Crossaf0b54c2017-09-27 17:22:32 -0700187 installable: false,
188}
189
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100190// A system modules definition for use by core library targets only. It only
191// contains the core-all jar, which contains the classes that end up in core-oj,
192// core-libart as well as the lambda stubs needed to compile Java lambda code.
193// It does not contain other parts of core library like conscrypt, bouncycastle,
194// etc. This system_modules definition is used to bootstrap compilation for
195// other parts of the core library like core-oj, core-libart, conscrypt,
196// bouncycastle, etc.
197//
198// If you want to compile against the entire core library implementation, for
199// example to build core library tests, see "core-system-modules" instead.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700200java_system_modules {
201 name: "core-all-system-modules",
Tobias Thierercf66bfd2019-05-29 13:18:25 +0100202 visibility: core_all_visibility,
Colin Crossa4d9fc42017-09-29 18:04:37 -0700203 libs: ["core-all"],
204}
205
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100206// Contains the parts of core library associated with OpenJDK.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700207java_library {
208 name: "core-oj",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000209 visibility: [
210 "//art/build/apex",
211 "//external/wycheproof",
Paul Duffin94f70232019-05-22 16:22:29 +0100212 "//libcore/benchmarks",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000213 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700214 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700215 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700216 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700217
Neil Fuller866ed4a2018-09-06 12:05:46 +0100218 srcs: [":core_oj_java_files"],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700219 java_resource_dirs: core_resource_dirs,
Colin Crossec80f4f2018-08-15 21:17:11 -0700220
Paul Duffin83c25382019-06-07 14:10:49 +0100221 sdk_version: "none",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700222 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700223 system_modules: "core-all-system-modules",
224 openjdk9: {
225 javacflags: ["--patch-module=java.base=."],
226 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700227
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000228 jacoco: {
Pete Gillin27ca0582018-01-10 17:04:17 +0000229 exclude_filter: [
Pete Gillin3f59bad2018-01-30 11:20:29 +0000230 "java.lang.Class",
231 "java.lang.Long",
232 "java.lang.Number",
233 "java.lang.Object",
234 "java.lang.String",
235 "java.lang.invoke.MethodHandle",
236 "java.lang.ref.Reference",
237 "java.lang.reflect.Proxy",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000238 "java.util.AbstractMap",
Pete Gillin3f59bad2018-01-30 11:20:29 +0000239 "java.util.HashMap",
240 "java.util.HashMap$Node",
Pete Gillinb1868ada2018-01-17 11:03:10 +0000241 "java.util.Map",
Pete Gillin7a7a6d22017-12-19 14:56:03 +0000242 ],
243 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700244
245 notice: "ojluni/NOTICE",
246
Colin Crossaf0b54c2017-09-27 17:22:32 -0700247}
248
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100249// Contains parts of core library not associated with OpenJDK. Contains not
250// just java.*, javax.* code but also android.icu.*, android.system.* and
251// various internal libcore.* packages.
Colin Crossaf0b54c2017-09-27 17:22:32 -0700252java_library {
253 name: "core-libart",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000254 visibility: [
255 "//art/build/apex",
256 "//external/robolectric-shadows",
257 "//external/wycheproof",
Paul Duffin94f70232019-05-22 16:22:29 +0100258 "//libcore/benchmarks",
Colin Crossf0ef6252019-05-31 08:26:47 -0700259 "//frameworks/layoutlib",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000260 ],
Colin Crossaf0b54c2017-09-27 17:22:32 -0700261 defaults: ["libcore_java_defaults"],
Colin Cross5b75cdd2018-06-27 11:00:13 -0700262 installable: true,
Colin Crossbb180be2017-10-09 14:54:53 -0700263 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700264
Neil Fuller866ed4a2018-09-06 12:05:46 +0100265 srcs: [":core_libart_java_files"],
Victor Chang7fef4052018-09-25 14:12:03 +0100266 static_libs: ["android_icu4j_resources_lib"],
Tobias Thiererde991232018-03-07 15:10:46 +0000267 java_version: "1.9",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700268
Paul Duffin83c25382019-06-07 14:10:49 +0100269 sdk_version: "none",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700270 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700271 system_modules: "core-all-system-modules",
272 openjdk9: {
273 javacflags: ["--patch-module=java.base=."],
274 },
Colin Crossec80f4f2018-08-15 21:17:11 -0700275
Pete Gillin80ebe872018-02-13 15:21:20 +0000276 jacoco: {
277 exclude_filter: [
278 "java.lang.DexCache",
279 "dalvik.system.ClassExt",
280 ],
281 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700282
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700283 target: {
284 hostdex: {
285 required: [
Neil Fuller53c5f032019-06-05 13:47:39 +0100286 // Files used to simulate the /system, runtime APEX and tzdata
287 // APEX dir structure on host.
288 "icu_tzdata.dat_host_tzdata_apex",
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700289 "tzdata_host",
Neil Fuller53c5f032019-06-05 13:47:39 +0100290 "tzdata_host_tzdata_apex",
Neil Fuller53c5f032019-06-05 13:47:39 +0100291 "tzlookup.xml_host_tzdata_apex",
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700292 "tz_version_host",
Neil Fuller53c5f032019-06-05 13:47:39 +0100293 "tz_version_host_tzdata_apex",
Andreas Gampe9a1ba892019-04-24 12:35:40 -0700294 ],
295 },
296 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700297}
298
Paul Duffin7bb8d232018-10-23 11:48:38 +0100299// Provided solely to contribute information about which hidden parts of the
300// core-oj API are used by apps.
Paul Duffinc6bf27b2019-05-15 14:41:00 +0100301//
302// The build system determines that this library provides hiddenapi information
303// for the core-oj bootjar because its name is of the form <x>-hiddenapi, where
304// <x> is the name of a boot jar. That triggers the generation of a flags.csv
305// file which encapsulates information extracted from the UnsupportedAppUsage
306// annotations in the dex. The information from that file is then encoded into
307// the core-oj file.
308//
309// Usually, e.g. for core-libart, the UnsupportedAppUsage annotations are
310// added to the source that is compiled directly into the bootjar and the build
311// system extracts the information about UnsupportedAppUsage directly from
312// there.
313//
314// This approach of having separate annotated source and a separate build
315// target was taken for ojluni to avoid having to maintain local patches in the
316// ojluni source for UnsupportedAppUsage annotations as that would make it more
317// difficult to pull down changes from upstream.
318//
Paul Duffin7bb8d232018-10-23 11:48:38 +0100319java_library {
320 name: "core-oj-hiddenapi",
Paul Duffin48ac7b62019-03-28 14:28:06 +0000321 // Do not allow this to be accessed from outside this directory.
322 visibility: ["//visibility:private"],
Paul Duffin7bb8d232018-10-23 11:48:38 +0100323 defaults: ["libcore_java_defaults"],
324 compile_dex: true,
325
326 srcs: [":openjdk_hiddenapi_javadoc_files"],
327
Paul Duffin83c25382019-06-07 14:10:49 +0100328 sdk_version: "none",
Paul Duffin7bb8d232018-10-23 11:48:38 +0100329 libs: ["core-all"],
330 system_modules: "core-all-system-modules",
331 openjdk9: {
332 javacflags: ["--patch-module=java.base=."],
333 },
334}
335
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100336//
337// Guaranteed unstripped versions of core-oj and core-libart.
338//
Colin Cross3c6c2e22017-10-18 13:24:52 -0700339// The build system may or may not strip the core-oj and core-libart jars,
340// but these will not be stripped. See b/24535627.
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100341//
342
Colin Cross3c6c2e22017-10-18 13:24:52 -0700343java_library {
344 name: "core-oj-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700345 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700346 static_libs: ["core-oj"],
Paul Duffin83c25382019-06-07 14:10:49 +0100347 sdk_version: "none",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700348 libs: ["core-all"],
349 system_modules: "core-all-system-modules",
350 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800351 dex_preopt: {
352 enabled: false,
353 },
Tobias Thiererde991232018-03-07 15:10:46 +0000354 java_version: "1.9",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700355 notice: "ojluni/NOTICE",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700356}
357
358java_library {
359 name: "core-libart-testdex",
Colin Cross5b75cdd2018-06-27 11:00:13 -0700360 installable: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700361 static_libs: ["core-libart"],
Paul Duffin83c25382019-06-07 14:10:49 +0100362 sdk_version: "none",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700363 libs: ["core-all"],
364 system_modules: "core-all-system-modules",
365 dxflags: ["--core-library"],
Colin Cross485ed362017-12-05 17:24:22 -0800366 dex_preopt: {
367 enabled: false,
368 },
Colin Cross3c6c2e22017-10-18 13:24:52 -0700369 notice: "ojluni/NOTICE",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700370}
371
Tobias Thierere0f8b312018-10-23 23:12:30 +0100372java_defaults {
373 name: "core_lambda_stubs_defaults",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700374 defaults: ["libcore_java_defaults"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100375 hostdex: true,
Colin Crossaf0b54c2017-09-27 17:22:32 -0700376
Paul Duffin83c25382019-06-07 14:10:49 +0100377 sdk_version: "none",
Colin Crossaf0b54c2017-09-27 17:22:32 -0700378 libs: ["core-all"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700379 system_modules: "core-all-system-modules",
380 openjdk9: {
381 javacflags: ["--patch-module=java.base=."],
382 },
Colin Crossaf0b54c2017-09-27 17:22:32 -0700383
384 notice: "ojluni/NOTICE",
385
386 installable: false,
387 include_srcs: true,
388}
Colin Crossa4d9fc42017-09-29 18:04:37 -0700389
Tobias Thierere0f8b312018-10-23 23:12:30 +0100390// Creates a jar that exists to satisfy javac when compiling source code that
391// contains lambdas. This contains all classes / methods required by javac
392// when generating invoke-dynamic lambda implementation code, even those that
393// are also in the public SDK API from API level 26 onwards.
394java_library {
395 name: "core-lambda-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100396 visibility: ["//visibility:public"],
Tobias Thierere0f8b312018-10-23 23:12:30 +0100397 defaults: ["core_lambda_stubs_defaults"],
398 srcs: [
399 ":openjdk_lambda_stub_files",
400 ":openjdk_lambda_duplicate_stub_files",
401 ],
402}
403
404// An alternative to core-lambda-stubs that omits openjdk_lambda_duplicate_stub_files
405// because those classes are also part of the core library public SDK API
406// (since API level 26).
407java_library {
408 name: "core-lambda-stubs-for-system-modules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100409 visibility: [
410 "//libcore/mmodules/core_platform_api",
411 ],
Tobias Thierere0f8b312018-10-23 23:12:30 +0100412 defaults: ["core_lambda_stubs_defaults"],
413 srcs: [
414 ":openjdk_lambda_stub_files",
415 ],
416}
417
Pete Gillin54035812019-05-08 15:09:39 +0100418// Creates a jar that exists to satisfy javac when compiling source code that
419// contains @Generated annotations, which are produced by some code generation
420// tools (notably dagger) but aren't part of the Android API.
421// See http://b/123891440.
422java_library {
423 name: "core-generated-annotation-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100424 visibility: [
425 "//libcore/mmodules/core_platform_api",
426 ],
Pete Gillin54035812019-05-08 15:09:39 +0100427 defaults: ["libcore_java_defaults"],
428 srcs: [
429 ":openjdk_generated_annotation_stub_files",
430 ],
431 hostdex: true,
Paul Duffin83c25382019-06-07 14:10:49 +0100432 sdk_version: "none",
Pete Gillin54035812019-05-08 15:09:39 +0100433 libs: ["core-all"],
434 system_modules: "core-all-system-modules",
435 openjdk9: {
436 javacflags: ["--patch-module=java.base=."],
437 },
438 notice: "ojluni/NOTICE",
439 installable: false,
440 include_srcs: true,
441}
442
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100443// A system modules definition containing the implementations for the various
444// parts that make up the core library.
445//
446// This system module is intended for use by tests that may need access to
447// core library internals. It should not be generally used; most of the
448// platform build should build against API stubs instead. See
449// "core-platform-api-stubs-system-modules", which is the default used by the
450// Android build.
451//
452// This module also includes lambda stubs for compiling source containing
453// Java lambdas.
Colin Crossa4d9fc42017-09-29 18:04:37 -0700454java_system_modules {
455 name: "core-system-modules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100456 visibility: ["//visibility:public"],
Colin Crossa4d9fc42017-09-29 18:04:37 -0700457 libs: [
458 "core-oj",
459 "core-libart",
Neil Fullerb669ccb2018-10-04 23:10:27 +0100460 "bouncycastle",
461 "conscrypt",
462 "okhttp",
Neil Fuller05723a52018-10-19 10:55:05 +0100463 "apache-xml",
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100464 // This one is not on device but it's needed when javac compiles code
465 // containing lambdas.
Tobias Thierere0f8b312018-10-23 23:12:30 +0100466 "core-lambda-stubs-for-system-modules",
Colin Crossa4d9fc42017-09-29 18:04:37 -0700467 ],
468}
Colin Cross3c6c2e22017-10-18 13:24:52 -0700469
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100470// Builds libcore test rules
Colin Cross3c6c2e22017-10-18 13:24:52 -0700471java_library_static {
472 name: "core-test-rules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100473 visibility: [
474 "//frameworks/base/location/tests/locationtests",
475 ],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700476 hostdex: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700477 srcs: [
478 "dalvik/test-rules/src/main/**/*.java",
479 "test-rules/src/main/**/*.java",
480 ],
481 static_libs: ["junit"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100482
Paul Duffin83c25382019-06-07 14:10:49 +0100483 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100484 libs: ["core-all"],
485 system_modules: "core-all-system-modules",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700486}
487
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100488// Builds the core-tests-support library used by various tests.
Colin Cross3c6c2e22017-10-18 13:24:52 -0700489java_library_static {
490 name: "core-tests-support",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100491 visibility: [
492 "//cts/apps/CtsVerifier",
493 "//cts/tests/tests/keystore",
494 "//cts/tests/tests/net",
495 "//cts/tests/tests/net/api23Test",
496 "//external/apache-harmony",
497 "//frameworks/base/core/tests/coretests",
498 "//libcore/benchmarks",
499 "//packages/apps/KeyChain/tests",
500 "//system/timezone/distro/core",
501 ],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700502 hostdex: true,
Colin Cross3c6c2e22017-10-18 13:24:52 -0700503 srcs: ["support/src/test/java/**/*.java"],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100504
Paul Duffin53c491f2019-06-12 13:48:14 +0100505 sdk_version: "core_platform",
Neil Fuller4380ab22018-10-18 19:38:53 +0100506 libs: ["junit"],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700507 static_libs: [
Neil Fullerde8b0862018-10-12 21:53:31 +0100508 "bouncycastle-unbundled",
509 "bouncycastle-bcpkix-unbundled",
510 "bouncycastle-ocsp-unbundled",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700511 ],
512}
513
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100514// Builds the jsr166-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700515java_test {
Colin Cross3c6c2e22017-10-18 13:24:52 -0700516 name: "jsr166-tests",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100517 visibility: [
518 "//cts/tests/libcore/jsr166",
519 ],
Colin Cross3c6c2e22017-10-18 13:24:52 -0700520 srcs: ["jsr166-tests/src/test/java/**/*.java"],
Paul Duffin83c25382019-06-07 14:10:49 +0100521 sdk_version: "none",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700522 libs: [
Neil Fuller4207c7f2018-10-10 14:01:40 +0100523 "core-all",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700524 "junit",
525 ],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100526 system_modules: "core-all-system-modules",
Colin Cross3c6c2e22017-10-18 13:24:52 -0700527}
Nan Zhang65f27a32018-01-05 10:41:46 -0800528
Pete Gillinec902b82019-06-26 17:23:00 +0100529// A filegroup that provides access to a source file for a toolchain test that
530// checks Java 9 language features are handled properly by JarJar.
531filegroup {
532 name: "core-java-9-language-features-source",
533 srcs: ["luni/src/main/java/libcore/internal/Java9LanguageFeatures.java"],
534 visibility: ["//libcore/luni/src/test/java9language"],
535}
536
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100537// Builds the core-tests library.
Colin Crossec80f4f2018-08-15 21:17:11 -0700538java_test {
539 name: "core-tests",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100540 visibility: [
541 "//cts/tests/libcore/luni",
542 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700543 defaults: ["libcore_java_defaults"],
544 hostdex: true,
545 srcs: [
546 "dalvik/src/test/java/**/*.java",
547 "dalvik/test-rules/src/test/java/**/*.java",
548 "dom/src/test/java/**/*.java",
549 "harmony-tests/src/test/java/**/*.java",
550 "json/src/test/java/**/*.java",
551 "luni/src/test/java/**/*.java",
Paul Duffin4ba14532019-03-21 10:32:41 +0000552 "test-rules/src/test/java/**/*.java",
Colin Crossec80f4f2018-08-15 21:17:11 -0700553 "xml/src/test/java/**/*.java",
554 ],
555 exclude_srcs: [
556 "luni/src/test/java/libcore/java/util/zip/Zip64Test.java",
557 "luni/src/test/java/libcore/java/util/zip/Zip64FileTest.java",
558 ],
559
560 java_resource_dirs: [
561 "*/src/test/java",
562 "*/src/test/resources",
563 ],
564 exclude_java_resource_dirs: [
565 "ojluni/src/test/java",
566 "ojluni/src/test/resources",
567 ],
568
569 java_resources: [
Paul Duffin16a057f2019-05-13 12:20:55 +0100570 ":annotations-test",
Colin Crossec80f4f2018-08-15 21:17:11 -0700571 ":filesystemstest",
572 ":parameter-metadata-test",
573 ],
574
Paul Duffin83c25382019-06-07 14:10:49 +0100575 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100576 libs: [
577 "core-all",
578 "okhttp",
579 "bouncycastle",
580 ],
581 system_modules: "core-all-system-modules",
582
Colin Crossec80f4f2018-08-15 21:17:11 -0700583 static_libs: [
584 "archive-patcher",
Pete Gillin05a43202019-06-27 14:41:21 +0100585 "core-java-9-language-tests",
Colin Crossec80f4f2018-08-15 21:17:11 -0700586 "core-test-rules",
587 "core-tests-support",
588 "junit-params",
589 "mockftpserver",
590 "mockito-target",
591 "mockwebserver",
592 "nist-pkix-tests",
593 "slf4j-jdk14",
594 "sqlite-jdbc",
595 "tzdata-testing",
Paul Duffina4df2372018-12-10 15:48:01 +0000596 "truth-prebuilt",
Colin Crossec80f4f2018-08-15 21:17:11 -0700597 ],
598
599 errorprone: {
600 javacflags: [
601 "-Xep:TryFailThrowable:ERROR",
602 "-Xep:ComparisonOutOfRange:ERROR",
603 ],
604 },
Simran Basi3be01e02018-08-21 17:53:49 -0700605
606 test_config: "AndroidTest-core-tests.xml",
Colin Crossec80f4f2018-08-15 21:17:11 -0700607}
608
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100609// Builds the core-ojtests library that contains test code from OpenJDK.
Colin Crossec80f4f2018-08-15 21:17:11 -0700610java_test {
611 name: "core-ojtests",
612 defaults: ["libcore_java_defaults"],
613 hostdex: true,
614
615 srcs: [
616 "ojluni/src/test/java/**/*.java",
617 ],
618 java_resource_dirs: [
619 "ojluni/src/test/java",
620 "ojluni/src/test/resources",
621 ],
Neil Fullerb669ccb2018-10-04 23:10:27 +0100622
Paul Duffin83c25382019-06-07 14:10:49 +0100623 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100624 libs: [
625 "core-all",
626 "okhttp",
627 "bouncycastle",
628 ],
629 system_modules: "core-all-system-modules",
630
Colin Crossec80f4f2018-08-15 21:17:11 -0700631 static_libs: ["testng"],
632
633 // ojluni/src/test/java/util/stream/{bootlib,boottest}
634 // contains tests that are in packages from java.base;
635 // By default, OpenJDK 9's javac will only compile such
636 // code if it's declared to also be in java.base at
637 // compile time.
638 //
639 // For now, we use --patch-module to put all sources
640 // and dependencies from this make target into java.base;
641 // other source directories in this make target are in
642 // packages not from java.base; if this becomes a problem
643 // in future, this could be addressed eg. by splitting
644 // boot{lib,test} out into a separate make target,
645 // deleting those tests or moving them to a different
646 // package.
647 patch_module: "java.base",
648}
649
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100650// Builds the core-ojtests-public library. Excludes any private API tests.
651// Like core-ojtests but smaller.
Colin Crossec80f4f2018-08-15 21:17:11 -0700652java_test {
653 name: "core-ojtests-public",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100654 visibility: [
655 "//cts/tests/libcore/ojluni",
656 ],
Colin Crossec80f4f2018-08-15 21:17:11 -0700657 defaults: ["libcore_java_defaults"],
658 srcs: [
659 "ojluni/src/test/java/**/*.java",
660 ],
661 // Filter out the following:
662 // 1.) DeserializeMethodTest and SerializedLambdaTest, because they depends on stub classes
663 // and won't actually run, and
664 // 2.) util/stream/boot*. Those directories contain classes in the package java.util.stream;
665 // excluding them means we don't need patch_module: "java.base"
666 exclude_srcs: [
667 "**/DeserializeMethodTest.java",
668 "**/SerializedLambdaTest.java",
669 "ojluni/src/test/java/util/stream/boot*/**/*",
670 ],
671 java_resource_dirs: [
672 "ojluni/src/test/java",
673 "ojluni/src/test/resources",
674 // Include source code as part of JAR
675 "ojluni/src/test/dist",
676 ],
Neil Fuller4207c7f2018-10-10 14:01:40 +0100677
Paul Duffin83c25382019-06-07 14:10:49 +0100678 sdk_version: "none",
Neil Fuller4207c7f2018-10-10 14:01:40 +0100679 libs: [
680 "core-all",
681 "bouncycastle",
682 "okhttp",
683 "testng",
684 ],
685 system_modules: "core-all-system-modules",
Colin Crossec80f4f2018-08-15 21:17:11 -0700686}
687
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100688// Exports annotated stubs source files in ojluni/annotations/sdk to make them
689// available to metalava. Used for nullability annotations in OpenJDK source.
Pete Gillin7db7faa2018-07-31 13:29:35 +0100690droiddoc_exported_dir {
Pete Gillin0728b742018-09-17 15:41:45 +0100691 name: "ojluni-annotated-sdk-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100692 visibility: [
693 "//frameworks/base",
694 ],
Pete Gillin0728b742018-09-17 15:41:45 +0100695 path: "ojluni/annotations/sdk",
Pete Gillin7db7faa2018-07-31 13:29:35 +0100696}
Paul Duffin48ac7b62019-03-28 14:28:06 +0000697
Pete Gillin600c7cf2018-08-16 19:28:38 +0100698droiddoc_exported_dir {
699 name: "ojluni-annotated-nullability-stubs",
700 path: "ojluni/annotations/sdk/nullability",
701}
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100702
703// Exports annotated stubs source files in ojluni/annotations/mmodules to make
Paul Duffinc241d6a2019-06-25 15:40:29 +0100704// them available to metalava. Used for core platform API and intra-core API
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100705// annotations in OpenJDK source.
Pete Gillinc9935b62018-09-25 14:42:40 +0100706droiddoc_exported_dir {
707 name: "ojluni-annotated-mmodule-stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100708 visibility: [
709 "//libcore/mmodules/core_platform_api",
710 "//libcore/mmodules/intracoreapi",
711 ],
Pete Gillinc9935b62018-09-25 14:42:40 +0100712 path: "ojluni/annotations/mmodule",
713}
Pete Gillin7db7faa2018-07-31 13:29:35 +0100714
Neil Fuller6f16b462018-09-04 15:40:39 +0100715// A file containing the list of tags that are "known" to us from the OpenJdk
716// source code and so should not cause an error or warning.
Nan Zhangd55722b2018-02-27 15:08:20 -0800717filegroup {
718 name: "known-oj-tags",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100719 visibility: [
720 "//frameworks/base",
721 ],
Nan Zhangd55722b2018-02-27 15:08:20 -0800722 srcs: [
723 "known_oj_tags.txt",
724 ],
725}
Nan Zhang602fc0e2018-03-22 16:14:22 -0700726
Neil Fuller77e3f3b2018-10-19 10:22:32 +0100727// Generates stubs for the parts of the public SDK API provided by the core
728// library.
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000729//
730// Only for use by core.current.stubs target below.
Nan Zhangf0207602018-09-10 18:57:38 -0700731droidstubs {
732 name: "core-current-stubs-gen",
Neil Fuller866ed4a2018-09-06 12:05:46 +0100733 srcs: [":core_api_files"],
Tobias Thiererde991232018-03-07 15:10:46 +0000734 java_version: "1.9",
Nan Zhang602fc0e2018-03-22 16:14:22 -0700735 installable: false,
Paul Duffin419b2422019-06-25 15:42:05 +0100736 sdk_version: "none",
Paul Duffinc31f6bb2019-05-15 12:32:44 +0100737 args: " --exclude-annotations " +
738 "--hide-annotation libcore.api.Hide",
Neil Fullerbe9258e2018-09-24 17:11:27 +0100739 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
Nan Zhang602fc0e2018-03-22 16:14:22 -0700740}
741
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000742// A stubs target containing the parts of the public SDK API provided by the
743// core library.
744//
745// Don't use this directly, use "sdk_version: core_current".
746java_library {
747 name: "core.current.stubs",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100748 visibility: ["//visibility:public"],
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000749 srcs: [":core-current-stubs-gen"],
750 errorprone: {
751 javacflags: [
752 "-Xep:MissingOverride:OFF",
753 ],
754 },
755 openjdk9: {
756 javacflags: ["--patch-module=java.base=."],
757 },
Paul Duffin83c25382019-06-07 14:10:49 +0100758 sdk_version: "none",
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000759 system_modules: "none",
Paul Duffin65641182019-04-08 10:24:23 +0100760
761 dist: {
762 targets: [
763 "sdk",
764 "win_sdk",
765 ],
766 },
Paul Duffin0ca3cbe2019-02-14 15:47:58 +0000767}
768
Neil Fuller61dabbf2018-10-21 22:53:18 +0100769// Used when compiling higher-level code against core.current.stubs.
770java_system_modules {
771 name: "core-current-stubs-system-modules",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100772 visibility: ["//visibility:public"],
Neil Fuller61dabbf2018-10-21 22:53:18 +0100773 libs: [
774 "core.current.stubs",
775 // This one is not on device but it's needed when javac compiles code
776 // containing lambdas.
777 "core-lambda-stubs-for-system-modules",
778 // This one is not on device but it's needed when javac compiles code
779 // containing @Generated annotations produced by some code generation
780 // tools.
781 // See http://b/123891440.
782 "core-generated-annotation-stubs",
783 ],
784}
785
Pete Gillin600c7cf2018-08-16 19:28:38 +0100786// Target for validating nullability annotations for correctness and
787// completeness. To check that there are no nullability errors:
788// make core-current-stubs-nullability-validation
789// To check that there are only the expected nullability warnings:
790// make core-current-stubs-nullability-validation-check-nullability-warnings
791// To update the the list of known expected nullability warnings:
792// make core-current-stubs-nullability-validation-update-nullability-warnings
793droidstubs {
794 name: "core-current-stubs-nullability-validation",
795 srcs: [":core_api_files"],
796 installable: false,
Paul Duffin419b2422019-06-25 15:42:05 +0100797 sdk_version: "none",
Pete Gillin600c7cf2018-08-16 19:28:38 +0100798 annotations_enabled: true,
799 args: "--hide-annotation libcore.api.Hide " +
800 "--validate-nullability-from-merged-stubs ",
801 merge_inclusion_annotations_dirs: ["ojluni-annotated-mmodule-stubs"],
802 merge_annotations_dirs: [
803 "metalava-manual",
804 // N.B. Stubs in this filegroup will be validated:
805 "ojluni-annotated-nullability-stubs",
806 ],
Pete Gillinc5f179b2018-11-14 18:42:19 +0000807 // The list of classes which have nullability annotations included in the source.
808 // (This is in addition to those which have annotations in the merged stubs.)
809 validate_nullability_from_list: "nullability_annotated_classes.txt",
Pete Gillin600c7cf2018-08-16 19:28:38 +0100810 // The expected set of warnings about missing annotations:
811 check_nullability_warnings: "nullability_warnings.txt",
812}
813
Neil Fullere784ef22018-11-16 15:54:30 +0000814// A host library containing time zone related classes. Used for
815// host-side tools and tests that have to deal with Android
816// time zone data.
817java_library_host {
818 name: "timezone-host",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100819 visibility: [
820 "//system/timezone/distro/core",
821 ],
Neil Fullere784ef22018-11-16 15:54:30 +0000822 srcs: [":timezone_host_files"],
823}
Andrei Onea24892e22019-04-16 16:48:37 +0100824
825// The source files that contain the UnsupportedAppUsage annotation and its dependencies.
826filegroup {
827 name: "unsupportedappusage_annotation_files",
Paul Duffinc241d6a2019-06-25 15:40:29 +0100828 visibility: [
829 "//frameworks/base",
830 ],
Andrei Onea24892e22019-04-16 16:48:37 +0100831 srcs: [
832 "dalvik/src/main/java/dalvik/annotation/compat/UnsupportedAppUsage.java",
833 "dalvik/src/main/java/dalvik/system/VersionCodes.java",
834 "luni/src/main/java/libcore/api/CorePlatformApi.java",
835 "luni/src/main/java/libcore/api/IntraCoreApi.java",
836 ],
Neil Fuller86345d72019-04-25 09:15:32 +0100837}