blob: 372502d4160b33d0d69ae42c4de8dec080e6fcc9 [file] [log] [blame]
Paul Duffinbb360c32021-07-10 23:31:50 +01001// Copyright (C) 2021 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 Android core libraries, i.e. ART, I18n and
17// Conscrypt.
18//
19// These are here as the definitions are used by the build itself and include
20// parts from all three of those modules.
21//
22
23// A stubs target containing the parts of the public SDK API provided by the
24// core libraries.
25//
26// Don't use this directly, use "sdk_version: core_current".
Bob Badour36dc7c62021-08-27 13:30:35 -070027package {
28 default_applicable_licenses: ["Android-Apache-2.0"],
29}
30
Paul Duffinbce9f082021-10-28 12:34:41 +010031dist_targets = [
32 "sdk",
33 "win_sdk",
34]
35
Paul Duffinbb360c32021-07-10 23:31:50 +010036java_library {
37 name: "core.current.stubs",
38 visibility: ["//visibility:public"],
39 static_libs: [
40 "art.module.public.api.stubs",
41 "conscrypt.module.public.api.stubs",
42 "i18n.module.public.api.stubs",
43 ],
44 sdk_version: "none",
45 system_modules: "none",
46
47 dist: {
Paul Duffinbce9f082021-10-28 12:34:41 +010048 targets: dist_targets,
Paul Duffinbb360c32021-07-10 23:31:50 +010049 },
50}
51
52// Distributed with the SDK for turning into system modules to compile apps
53// against.
Paul Duffinbce9f082021-10-28 12:34:41 +010054//
55// Also, produces dist files that are used by the
56// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
57// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +010058java_library {
59 name: "core-current-stubs-for-system-modules",
60 visibility: ["//development/sdk"],
61 static_libs: [
62 "core.current.stubs",
63 // This one is not on device but it's needed when javac compiles code
64 // containing lambdas.
65 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +010066 ],
67 sdk_version: "none",
68 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +010069 dists: [
70 {
71 // Legacy dist location for the public file.
72 dest: "core-for-system-modules.jar",
73 targets: dist_targets,
74 },
75 {
76 dest: "system-modules/public/core-for-system-modules.jar",
77 targets: dist_targets,
78 },
79 ],
Paul Duffinbb360c32021-07-10 23:31:50 +010080}
81
Spandan Dasb0f3d422023-03-29 20:59:47 +000082// Defaults module to strip out android annotations
83java_defaults {
84 name: "system-modules-no-annotations",
85 sdk_version: "none",
86 system_modules: "none",
87 jarjar_rules: "jarjar-strip-annotations-rules.txt",
88}
89
Sorin Bascabdbae602022-07-26 15:24:15 +010090// Same as core-current-stubs-for-system-modules, but android annotations are
91// stripped.
92java_library {
93 name: "core-current-stubs-for-system-modules-no-annotations",
94 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +000095 defaults: [
96 "system-modules-no-annotations",
97 ],
Sorin Bascabdbae602022-07-26 15:24:15 +010098 static_libs: [
99 "core-current-stubs-for-system-modules",
100 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100101 dists: [
102 {
103 // Legacy dist location for the public file.
104 dest: "core-for-system-modules-no-annotations.jar",
105 targets: dist_targets,
106 },
107 {
108 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
109 targets: dist_targets,
110 },
111 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100112}
113
Paul Duffinbb360c32021-07-10 23:31:50 +0100114// Used when compiling higher-level code against core.current.stubs.
115java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000116 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100117 visibility: ["//visibility:public"],
118 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100119 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100120 ],
121}
122
123// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
124// provided by the core libraries.
125//
126// Don't use this directly, use "sdk_version: module_current".
127java_library {
128 name: "core.module_lib.stubs",
129 static_libs: [
130 "art.module.public.api.stubs.module_lib",
131
132 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
133 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
134 // @SystemApi(MODULE_LIBRARIES).
135 "conscrypt.module.public.api.stubs",
136 "i18n.module.public.api.stubs",
137 ],
138 sdk_version: "none",
139 system_modules: "none",
140 visibility: ["//visibility:private"],
141}
142
Paul Duffinbce9f082021-10-28 12:34:41 +0100143// Produces a dist file that is used by the
144// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
145// directory.
146java_library {
147 name: "core-module-lib-stubs-for-system-modules",
148 visibility: ["//visibility:private"],
149 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100150 "core.module_lib.stubs",
151 // This one is not on device but it's needed when javac compiles code
152 // containing lambdas.
153 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100154 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100155 sdk_version: "none",
156 system_modules: "none",
157 dist: {
158 dest: "system-modules/module-lib/core-for-system-modules.jar",
159 targets: dist_targets,
160 },
161}
162
Sorin Basca69f4b082022-05-09 13:55:11 +0100163// Same as core-module-lib-stubs-for-system-modules, but android annotations are
164// stripped. This is used by the Java toolchain, while the annotated stub is to
165// be used by Kotlin one.
166java_library {
167 name: "core-module-lib-stubs-for-system-modules-no-annotations",
168 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000169 defaults: [
170 "system-modules-no-annotations",
171 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100172 static_libs: [
173 "core-module-lib-stubs-for-system-modules",
174 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100175 dist: {
176 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
177 targets: dist_targets,
178 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100179}
180
Paul Duffinbce9f082021-10-28 12:34:41 +0100181// Used when compiling higher-level code with sdk_version "module_current"
182java_system_modules {
183 name: "core-module-lib-stubs-system-modules",
184 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100185 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100186 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100187 visibility: ["//visibility:public"],
188}
189
190// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
191// this.
192// TODO(http://b/134561230) - limit the number of dependents on this.
193core_platform_visibility = ["//visibility:public"]
194
195// Libraries containing the core platform API stubs for the core libraries.
196//
197// Although this stubs library is primarily used by the Java compiler / build to indicate
198// the core platform API surface area, compile_dex: true is used so that the Core Platform
199// API annotations are available to the dex tools that enable enforcement of runtime
200// accessibility. b/119068555
201java_library {
202 name: "legacy.core.platform.api.stubs",
203 visibility: core_platform_visibility,
204 hostdex: true,
205 compile_dex: true,
206
207 sdk_version: "none",
208 system_modules: "none",
209 static_libs: [
210 "art.module.public.api.stubs.module_lib",
211 "conscrypt.module.platform.api.stubs",
212 "legacy.i18n.module.platform.api.stubs",
213 ],
214 patch_module: "java.base",
215}
216
Sorin Basca69f4b082022-05-09 13:55:11 +0100217// Same as legacy.core.platform.api.stubs, but android annotations are
218// stripped. This is used by the Java toolchain, while the annotated stub is to
219// be used by Kotlin one.
220java_library {
221 name: "legacy.core.platform.api.no.annotations.stubs",
222 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000223 defaults: [
224 "system-modules-no-annotations",
225 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100226 hostdex: true,
227 compile_dex: true,
228
Sorin Basca69f4b082022-05-09 13:55:11 +0100229 static_libs: [
230 "legacy.core.platform.api.stubs",
231 ],
232 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100233}
234
Paul Duffinbb360c32021-07-10 23:31:50 +0100235java_library {
236 name: "stable.core.platform.api.stubs",
237 visibility: core_platform_visibility,
238 hostdex: true,
239 compile_dex: true,
240
241 sdk_version: "none",
242 system_modules: "none",
243 static_libs: [
244 "art.module.public.api.stubs.module_lib",
245 // conscrypt only has a stable version, so it is okay to depend on it here:
246 "conscrypt.module.platform.api.stubs",
247 "stable.i18n.module.platform.api.stubs",
248 ],
249 patch_module: "java.base",
250}
251
Sorin Basca69f4b082022-05-09 13:55:11 +0100252// Same as stable.core.platform.api.stubs, but android annotations are
253// stripped. This is used by the Java toolchain, while the annotated stub is to
254// be used by Kotlin one.
255java_library {
256 name: "stable.core.platform.api.no.annotations.stubs",
257 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000258 defaults: [
259 "system-modules-no-annotations",
260 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100261 hostdex: true,
262 compile_dex: true,
263
Sorin Basca69f4b082022-05-09 13:55:11 +0100264 static_libs: [
265 "stable.core.platform.api.stubs",
266 ],
267 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100268}
269
Paul Duffinbb360c32021-07-10 23:31:50 +0100270// Used when compiling higher-level code against *.core.platform.api.stubs.
271java_system_modules {
272 name: "legacy-core-platform-api-stubs-system-modules",
273 visibility: core_platform_visibility,
274 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100275 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100276 // This one is not on device but it's needed when javac compiles code
277 // containing lambdas.
278 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100279 ],
280}
281
282java_system_modules {
283 name: "stable-core-platform-api-stubs-system-modules",
284 visibility: core_platform_visibility,
285 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100286 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100287 // This one is not on device but it's needed when javac compiles code
288 // containing lambdas.
289 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100290 ],
291}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000292
293// Used when compiling higher-level code against art.module.public.api.stubs.
294// This abstraction should come from the inner tree linking against the stubs
295// and not from an "sdk", since parts of this abstraction do not belong to an
296// official API (e.g. stub-annotations).
297//
298// This is only intended for use within core libraries and must not be used
299// from outside.
300java_system_modules {
301 name: "art-module-public-api-stubs-system-modules",
302 visibility: [
303 "//art/build/sdk",
304 "//external/conscrypt",
305 "//external/icu/android_icu4j",
306 "//external/wycheproof",
307 ],
308 libs: [
309 "art.module.public.api.stubs",
310 // This one is not on device but it's needed when javac compiles code
311 // containing lambdas.
312 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000313
314 // Ensure that core libraries that depend on the public API can access
315 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
316 // annotations.
317 "art.module.api.annotations.for.system.modules",
318
319 // Make nullability annotations available when compiling public stubs.
320 // They are provided as a separate library because while the
321 // annotations are not themselves part of the public API provided by
322 // this module they are used in the stubs.
323 "stub-annotations",
324 ],
325}
326
327// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
328//
329// This is only intended for use within core libraries and must not be used
330// from outside.
331java_system_modules {
332 name: "art-module-lib-api-stubs-system-modules",
333 visibility: [
334 "//art/build/sdk",
335 "//external/conscrypt",
336 "//external/icu/android_icu4j",
337 ],
338 libs: [
339 "art.module.public.api.stubs.module_lib",
340 ],
341}
342
343// Used when compiling against art.module.intra.core.api.stubs.
344java_system_modules {
345 name: "art-module-intra-core-api-stubs-system-modules",
346 visibility: [
347 "//art/build/sdk",
348 "//external/bouncycastle",
349 "//external/conscrypt",
350 "//external/icu/android_icu4j",
351 ],
352 libs: [
353 // The intra core API stubs library.
354 "art.module.intra.core.api.stubs",
355
356 // Additional classes needed by javac but which are not present in the stubs.
357 "art-module-intra-core-api-stubs-system-modules-lib",
358 ],
359}