blob: ab72e8b6d0cedd49b3c81e1045ff43b57030fb43 [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
Jihoon Kang67b64432023-05-31 22:25:21 +000036java_defaults {
37 name: "core.current.stubs.defaults",
Paul Duffinbb360c32021-07-10 23:31:50 +010038 visibility: ["//visibility:public"],
Jihoon Kang67b64432023-05-31 22:25:21 +000039 sdk_version: "none",
40 system_modules: "none",
Jihoon Kang67b64432023-05-31 22:25:21 +000041}
42
43java_library {
44 name: "core.current.stubs.from-source",
45 defaults: [
46 "core.current.stubs.defaults",
47 ],
Paul Duffinbb360c32021-07-10 23:31:50 +010048 static_libs: [
49 "art.module.public.api.stubs",
50 "conscrypt.module.public.api.stubs",
51 "i18n.module.public.api.stubs",
52 ],
Jihoon Kang67b64432023-05-31 22:25:21 +000053}
Paul Duffinbb360c32021-07-10 23:31:50 +010054
Jihoon Kangb281ddc2023-08-17 18:14:35 +000055java_api_library {
56 name: "core.current.stubs.from-text",
57 api_surface: "core",
58 api_contributions: [
59 "art.module.public.api.stubs.source.api.contribution",
60 "conscrypt.module.public.api.stubs.source.api.contribution",
61 "i18n.module.public.api.stubs.source.api.contribution",
62 ],
63 libs: [
64 "stub-annotations",
65 ],
Jihoon Kang063ec002023-06-28 01:16:23 +000066 enable_validation: false,
Jihoon Kang5d701272024-02-15 21:53:49 +000067 stubs_type: "everything",
Jihoon Kangb281ddc2023-08-17 18:14:35 +000068}
69
Jihoon Kang67b64432023-05-31 22:25:21 +000070java_library {
71 name: "core.current.stubs",
72 defaults: [
73 "core.current.stubs.defaults",
74 ],
75 static_libs: [
76 "core.current.stubs.from-source",
77 ],
78 product_variables: {
79 build_from_text_stub: {
80 static_libs: [
81 "core.current.stubs.from-text",
82 ],
83 exclude_static_libs: [
84 "core.current.stubs.from-source",
85 ],
86 },
Paul Duffinbb360c32021-07-10 23:31:50 +010087 },
88}
89
Jihoon Kangbd093452023-12-26 19:08:01 +000090java_library {
91 name: "core.current.stubs.exportable.from-source",
92 defaults: [
93 "core.current.stubs.defaults",
94 ],
95 static_libs: [
96 "art.module.public.api.stubs.exportable",
97 "conscrypt.module.public.api.stubs.exportable",
98 "i18n.module.public.api.stubs.exportable",
99 ],
100 dist: {
101 targets: dist_targets,
102 dest: "core.current.stubs.jar",
103 },
104}
105
106java_library {
107 name: "core.current.stubs.exportable",
108 defaults: [
109 "core.current.stubs.defaults",
110 ],
111 static_libs: [
112 "core.current.stubs.exportable.from-source",
113 ],
114}
115
Paul Duffinbb360c32021-07-10 23:31:50 +0100116// Distributed with the SDK for turning into system modules to compile apps
117// against.
Paul Duffinbce9f082021-10-28 12:34:41 +0100118//
119// Also, produces dist files that are used by the
120// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
121// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +0100122java_library {
123 name: "core-current-stubs-for-system-modules",
124 visibility: ["//development/sdk"],
125 static_libs: [
126 "core.current.stubs",
127 // This one is not on device but it's needed when javac compiles code
128 // containing lambdas.
129 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100130 ],
131 sdk_version: "none",
132 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +0100133 dists: [
134 {
135 // Legacy dist location for the public file.
136 dest: "core-for-system-modules.jar",
137 targets: dist_targets,
138 },
139 {
140 dest: "system-modules/public/core-for-system-modules.jar",
141 targets: dist_targets,
142 },
143 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100144}
145
Spandan Dasb0f3d422023-03-29 20:59:47 +0000146// Defaults module to strip out android annotations
147java_defaults {
148 name: "system-modules-no-annotations",
149 sdk_version: "none",
150 system_modules: "none",
151 jarjar_rules: "jarjar-strip-annotations-rules.txt",
152}
153
Sorin Bascabdbae602022-07-26 15:24:15 +0100154// Same as core-current-stubs-for-system-modules, but android annotations are
155// stripped.
156java_library {
157 name: "core-current-stubs-for-system-modules-no-annotations",
158 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000159 defaults: [
160 "system-modules-no-annotations",
161 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100162 static_libs: [
163 "core-current-stubs-for-system-modules",
164 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100165 dists: [
166 {
167 // Legacy dist location for the public file.
168 dest: "core-for-system-modules-no-annotations.jar",
169 targets: dist_targets,
170 },
171 {
172 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
173 targets: dist_targets,
174 },
175 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100176}
177
Paul Duffinbb360c32021-07-10 23:31:50 +0100178// Used when compiling higher-level code against core.current.stubs.
179java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000180 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100181 visibility: ["//visibility:public"],
182 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100183 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100184 ],
185}
186
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400187java_defaults {
188 name: "core.module_lib.stubs.defaults",
189 visibility: ["//visibility:private"],
190 sdk_version: "none",
191 system_modules: "none",
192}
193
Paul Duffinbb360c32021-07-10 23:31:50 +0100194// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
195// provided by the core libraries.
196//
197// Don't use this directly, use "sdk_version: module_current".
198java_library {
199 name: "core.module_lib.stubs",
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400200 defaults: [
201 "core.module_lib.stubs.defaults",
202 ],
203 static_libs: [
204 "core.module_lib.stubs.from-source",
205 ],
206 product_variables: {
207 build_from_text_stub: {
208 static_libs: [
209 "core.module_lib.stubs.from-text",
210 ],
211 exclude_static_libs: [
212 "core.module_lib.stubs.from-source",
213 ],
214 },
215 },
216}
217
218java_library {
219 name: "core.module_lib.stubs.from-source",
220 defaults: [
221 "core.module_lib.stubs.defaults",
222 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100223 static_libs: [
224 "art.module.public.api.stubs.module_lib",
225
226 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
227 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
228 // @SystemApi(MODULE_LIBRARIES).
229 "conscrypt.module.public.api.stubs",
230 "i18n.module.public.api.stubs",
231 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100232}
233
Jihoon Kangbfa2f9e2023-11-01 22:49:35 +0000234java_api_library {
235 name: "core.module_lib.stubs.from-text",
236 api_surface: "module-lib",
237 api_contributions: [
238 "art.module.public.api.stubs.source.api.contribution",
239 "art.module.public.api.stubs.source.system.api.contribution",
240 "art.module.public.api.stubs.source.module_lib.api.contribution",
241
242 // Add the module-lib correspondence when Conscrypt or i18N module
243 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
244 // @SystemApi(MODULE_LIBRARIES).
245 "conscrypt.module.public.api.stubs.source.api.contribution",
246 "i18n.module.public.api.stubs.source.api.contribution",
247 ],
248 libs: [
249 "stub-annotations",
250 ],
251 visibility: ["//visibility:private"],
Jihoon Kang5d701272024-02-15 21:53:49 +0000252 stubs_type: "everything",
Jihoon Kangbfa2f9e2023-11-01 22:49:35 +0000253}
254
Paul Duffinbce9f082021-10-28 12:34:41 +0100255// Produces a dist file that is used by the
256// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
257// directory.
258java_library {
259 name: "core-module-lib-stubs-for-system-modules",
260 visibility: ["//visibility:private"],
261 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100262 "core.module_lib.stubs",
263 // This one is not on device but it's needed when javac compiles code
264 // containing lambdas.
265 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100266 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100267 sdk_version: "none",
268 system_modules: "none",
269 dist: {
270 dest: "system-modules/module-lib/core-for-system-modules.jar",
271 targets: dist_targets,
272 },
273}
274
Sorin Basca69f4b082022-05-09 13:55:11 +0100275// Same as core-module-lib-stubs-for-system-modules, but android annotations are
276// stripped. This is used by the Java toolchain, while the annotated stub is to
277// be used by Kotlin one.
278java_library {
279 name: "core-module-lib-stubs-for-system-modules-no-annotations",
280 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000281 defaults: [
282 "system-modules-no-annotations",
283 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100284 static_libs: [
285 "core-module-lib-stubs-for-system-modules",
286 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100287 dist: {
288 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
289 targets: dist_targets,
290 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100291}
292
Paul Duffinbce9f082021-10-28 12:34:41 +0100293// Used when compiling higher-level code with sdk_version "module_current"
294java_system_modules {
295 name: "core-module-lib-stubs-system-modules",
296 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100297 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100298 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100299 visibility: ["//visibility:public"],
300}
301
302// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
303// this.
304// TODO(http://b/134561230) - limit the number of dependents on this.
305core_platform_visibility = ["//visibility:public"]
306
307// Libraries containing the core platform API stubs for the core libraries.
308//
309// Although this stubs library is primarily used by the Java compiler / build to indicate
310// the core platform API surface area, compile_dex: true is used so that the Core Platform
311// API annotations are available to the dex tools that enable enforcement of runtime
312// accessibility. b/119068555
313java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000314 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100315 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000316 defaults: [
317 "core.platform.api.stubs.defaults",
318 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100319 static_libs: [
320 "art.module.public.api.stubs.module_lib",
321 "conscrypt.module.platform.api.stubs",
322 "legacy.i18n.module.platform.api.stubs",
323 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000324}
325
Jihoon Kangbd093452023-12-26 19:08:01 +0000326java_library {
327 name: "legacy.core.platform.api.stubs.exportable.from-source",
328 visibility: core_platform_visibility,
329 defaults: [
330 "core.platform.api.stubs.defaults",
331 ],
332 static_libs: [
333 "art.module.public.api.stubs.exportable.module_lib",
334 "conscrypt.module.platform.api.stubs.exportable",
335 "legacy.i18n.module.platform.api.stubs.exportable",
336 ],
337}
338
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000339java_defaults {
340 name: "android_core_platform_stubs_current_contributions",
341 api_surface: "core_platform",
342 api_contributions: [
343 "art.module.public.api.stubs.source.api.contribution",
344 "art.module.public.api.stubs.source.system.api.contribution",
345 "art.module.public.api.stubs.source.module_lib.api.contribution",
346 "conscrypt.module.platform.api.stubs.source.api.contribution",
347 "i18n.module.public.api.stubs.source.api.contribution",
348 ],
349}
350
351java_api_library {
352 name: "legacy.core.platform.api.stubs.from-text",
353 api_surface: "core_platform",
354 defaults: [
355 "android_core_platform_stubs_current_contributions",
356 ],
357 api_contributions: [
358 "legacy.i18n.module.platform.api.stubs.source.api.contribution",
359 ],
360 libs: [
361 "stub-annotations",
362 ],
Jihoon Kang5d701272024-02-15 21:53:49 +0000363 stubs_type: "everything",
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000364}
365
Jihoon Kang67b64432023-05-31 22:25:21 +0000366java_library {
367 name: "legacy.core.platform.api.stubs",
368 visibility: core_platform_visibility,
369 defaults: [
370 "core.platform.api.stubs.defaults",
371 ],
372 static_libs: [
373 "legacy.core.platform.api.stubs.from-source",
374 ],
375 product_variables: {
376 build_from_text_stub: {
377 static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400378 "legacy.core.platform.api.stubs.from-text",
Jihoon Kang67b64432023-05-31 22:25:21 +0000379 ],
380 exclude_static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400381 "legacy.core.platform.api.stubs.from-source",
Jihoon Kang67b64432023-05-31 22:25:21 +0000382 ],
383 },
384 },
385}
386
Jihoon Kangbd093452023-12-26 19:08:01 +0000387java_library {
388 name: "legacy.core.platform.api.stubs.exportable",
389 visibility: core_platform_visibility,
390 defaults: [
391 "core.platform.api.stubs.defaults",
392 ],
393 static_libs: [
394 "legacy.core.platform.api.stubs.exportable.from-source",
395 ],
396}
397
Jihoon Kang67b64432023-05-31 22:25:21 +0000398java_defaults {
399 name: "core.platform.api.stubs.defaults",
400 hostdex: true,
401 compile_dex: true,
402
403 sdk_version: "none",
404 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100405 patch_module: "java.base",
406}
407
Sorin Basca69f4b082022-05-09 13:55:11 +0100408// Same as legacy.core.platform.api.stubs, but android annotations are
409// stripped. This is used by the Java toolchain, while the annotated stub is to
410// be used by Kotlin one.
411java_library {
412 name: "legacy.core.platform.api.no.annotations.stubs",
413 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000414 defaults: [
415 "system-modules-no-annotations",
416 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100417 hostdex: true,
418 compile_dex: true,
419
Sorin Basca69f4b082022-05-09 13:55:11 +0100420 static_libs: [
421 "legacy.core.platform.api.stubs",
422 ],
423 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100424}
425
Paul Duffinbb360c32021-07-10 23:31:50 +0100426java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000427 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100428 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000429 defaults: [
430 "core.platform.api.stubs.defaults",
431 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100432 static_libs: [
433 "art.module.public.api.stubs.module_lib",
434 // conscrypt only has a stable version, so it is okay to depend on it here:
435 "conscrypt.module.platform.api.stubs",
436 "stable.i18n.module.platform.api.stubs",
437 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000438}
439
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000440java_api_library {
441 name: "stable.core.platform.api.stubs.from-text",
442 api_surface: "core_platform",
443 defaults: [
444 "android_core_platform_stubs_current_contributions",
445 ],
446 api_contributions: [
447 "stable.i18n.module.platform.api.stubs.source.api.contribution",
448 ],
449 libs: [
450 "stub-annotations",
451 ],
Jihoon Kang5d701272024-02-15 21:53:49 +0000452 stubs_type: "everything",
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000453}
454
Jihoon Kang67b64432023-05-31 22:25:21 +0000455java_library {
456 name: "stable.core.platform.api.stubs",
457 visibility: core_platform_visibility,
458 defaults: [
459 "core.platform.api.stubs.defaults",
460 ],
461 static_libs: [
462 "stable.core.platform.api.stubs.from-source",
463 ],
464 product_variables: {
465 build_from_text_stub: {
466 static_libs: [
467 "stable.core.platform.api.stubs.from-text",
468 ],
469 exclude_static_libs: [
470 "stable.core.platform.api.stubs.from-source",
471 ],
472 },
473 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100474}
475
Sorin Basca69f4b082022-05-09 13:55:11 +0100476// Same as stable.core.platform.api.stubs, but android annotations are
477// stripped. This is used by the Java toolchain, while the annotated stub is to
478// be used by Kotlin one.
479java_library {
480 name: "stable.core.platform.api.no.annotations.stubs",
481 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000482 defaults: [
483 "system-modules-no-annotations",
484 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100485 hostdex: true,
486 compile_dex: true,
487
Sorin Basca69f4b082022-05-09 13:55:11 +0100488 static_libs: [
489 "stable.core.platform.api.stubs",
490 ],
491 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100492}
493
Paul Duffinbb360c32021-07-10 23:31:50 +0100494// Used when compiling higher-level code against *.core.platform.api.stubs.
495java_system_modules {
496 name: "legacy-core-platform-api-stubs-system-modules",
497 visibility: core_platform_visibility,
498 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100499 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100500 // This one is not on device but it's needed when javac compiles code
501 // containing lambdas.
502 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100503 ],
504}
505
506java_system_modules {
507 name: "stable-core-platform-api-stubs-system-modules",
508 visibility: core_platform_visibility,
509 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100510 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100511 // This one is not on device but it's needed when javac compiles code
512 // containing lambdas.
513 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100514 ],
515}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000516
517// Used when compiling higher-level code against art.module.public.api.stubs.
518// This abstraction should come from the inner tree linking against the stubs
519// and not from an "sdk", since parts of this abstraction do not belong to an
520// official API (e.g. stub-annotations).
521//
522// This is only intended for use within core libraries and must not be used
523// from outside.
524java_system_modules {
525 name: "art-module-public-api-stubs-system-modules",
526 visibility: [
527 "//art/build/sdk",
528 "//external/conscrypt",
529 "//external/icu/android_icu4j",
530 "//external/wycheproof",
531 ],
532 libs: [
533 "art.module.public.api.stubs",
534 // This one is not on device but it's needed when javac compiles code
535 // containing lambdas.
536 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000537
538 // Ensure that core libraries that depend on the public API can access
539 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
540 // annotations.
541 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000542 ],
543}
544
545// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
546//
547// This is only intended for use within core libraries and must not be used
548// from outside.
549java_system_modules {
550 name: "art-module-lib-api-stubs-system-modules",
551 visibility: [
552 "//art/build/sdk",
553 "//external/conscrypt",
554 "//external/icu/android_icu4j",
555 ],
556 libs: [
557 "art.module.public.api.stubs.module_lib",
558 ],
559}
560
561// Used when compiling against art.module.intra.core.api.stubs.
562java_system_modules {
563 name: "art-module-intra-core-api-stubs-system-modules",
564 visibility: [
565 "//art/build/sdk",
566 "//external/bouncycastle",
567 "//external/conscrypt",
568 "//external/icu/android_icu4j",
569 ],
570 libs: [
571 // The intra core API stubs library.
572 "art.module.intra.core.api.stubs",
573
574 // Additional classes needed by javac but which are not present in the stubs.
575 "art-module-intra-core-api-stubs-system-modules-lib",
576 ],
577}