blob: 8ffe5113c2beedaab196d1841f9e0a8b5d47e025 [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 Kangb281ddc2023-08-17 18:14:35 +000067}
68
Jihoon Kang67b64432023-05-31 22:25:21 +000069java_library {
70 name: "core.current.stubs",
71 defaults: [
72 "core.current.stubs.defaults",
73 ],
74 static_libs: [
75 "core.current.stubs.from-source",
76 ],
77 product_variables: {
78 build_from_text_stub: {
79 static_libs: [
80 "core.current.stubs.from-text",
81 ],
82 exclude_static_libs: [
83 "core.current.stubs.from-source",
84 ],
85 },
Paul Duffinbb360c32021-07-10 23:31:50 +010086 },
87}
88
Jihoon Kangbd093452023-12-26 19:08:01 +000089java_library {
90 name: "core.current.stubs.exportable.from-source",
91 defaults: [
92 "core.current.stubs.defaults",
93 ],
94 static_libs: [
95 "art.module.public.api.stubs.exportable",
96 "conscrypt.module.public.api.stubs.exportable",
97 "i18n.module.public.api.stubs.exportable",
98 ],
99 dist: {
100 targets: dist_targets,
101 dest: "core.current.stubs.jar",
102 },
103}
104
105java_library {
106 name: "core.current.stubs.exportable",
107 defaults: [
108 "core.current.stubs.defaults",
109 ],
110 static_libs: [
111 "core.current.stubs.exportable.from-source",
112 ],
113}
114
Paul Duffinbb360c32021-07-10 23:31:50 +0100115// Distributed with the SDK for turning into system modules to compile apps
116// against.
Paul Duffinbce9f082021-10-28 12:34:41 +0100117//
118// Also, produces dist files that are used by the
119// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
120// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +0100121java_library {
122 name: "core-current-stubs-for-system-modules",
123 visibility: ["//development/sdk"],
124 static_libs: [
125 "core.current.stubs",
126 // This one is not on device but it's needed when javac compiles code
127 // containing lambdas.
128 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100129 ],
130 sdk_version: "none",
131 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +0100132 dists: [
133 {
134 // Legacy dist location for the public file.
135 dest: "core-for-system-modules.jar",
136 targets: dist_targets,
137 },
138 {
139 dest: "system-modules/public/core-for-system-modules.jar",
140 targets: dist_targets,
141 },
142 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100143}
144
Spandan Dasb0f3d422023-03-29 20:59:47 +0000145// Defaults module to strip out android annotations
146java_defaults {
147 name: "system-modules-no-annotations",
148 sdk_version: "none",
149 system_modules: "none",
150 jarjar_rules: "jarjar-strip-annotations-rules.txt",
151}
152
Sorin Bascabdbae602022-07-26 15:24:15 +0100153// Same as core-current-stubs-for-system-modules, but android annotations are
154// stripped.
155java_library {
156 name: "core-current-stubs-for-system-modules-no-annotations",
157 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000158 defaults: [
159 "system-modules-no-annotations",
160 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100161 static_libs: [
162 "core-current-stubs-for-system-modules",
163 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100164 dists: [
165 {
166 // Legacy dist location for the public file.
167 dest: "core-for-system-modules-no-annotations.jar",
168 targets: dist_targets,
169 },
170 {
171 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
172 targets: dist_targets,
173 },
174 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100175}
176
Paul Duffinbb360c32021-07-10 23:31:50 +0100177// Used when compiling higher-level code against core.current.stubs.
178java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000179 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100180 visibility: ["//visibility:public"],
181 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100182 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100183 ],
184}
185
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400186java_defaults {
187 name: "core.module_lib.stubs.defaults",
188 visibility: ["//visibility:private"],
189 sdk_version: "none",
190 system_modules: "none",
191}
192
Paul Duffinbb360c32021-07-10 23:31:50 +0100193// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
194// provided by the core libraries.
195//
196// Don't use this directly, use "sdk_version: module_current".
197java_library {
198 name: "core.module_lib.stubs",
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400199 defaults: [
200 "core.module_lib.stubs.defaults",
201 ],
202 static_libs: [
203 "core.module_lib.stubs.from-source",
204 ],
205 product_variables: {
206 build_from_text_stub: {
207 static_libs: [
208 "core.module_lib.stubs.from-text",
209 ],
210 exclude_static_libs: [
211 "core.module_lib.stubs.from-source",
212 ],
213 },
214 },
215}
216
217java_library {
218 name: "core.module_lib.stubs.from-source",
219 defaults: [
220 "core.module_lib.stubs.defaults",
221 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100222 static_libs: [
223 "art.module.public.api.stubs.module_lib",
224
225 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
226 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
227 // @SystemApi(MODULE_LIBRARIES).
228 "conscrypt.module.public.api.stubs",
229 "i18n.module.public.api.stubs",
230 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100231}
232
Jihoon Kangbfa2f9e2023-11-01 22:49:35 +0000233java_api_library {
234 name: "core.module_lib.stubs.from-text",
235 api_surface: "module-lib",
236 api_contributions: [
237 "art.module.public.api.stubs.source.api.contribution",
238 "art.module.public.api.stubs.source.system.api.contribution",
239 "art.module.public.api.stubs.source.module_lib.api.contribution",
240
241 // Add the module-lib correspondence when Conscrypt or i18N module
242 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
243 // @SystemApi(MODULE_LIBRARIES).
244 "conscrypt.module.public.api.stubs.source.api.contribution",
245 "i18n.module.public.api.stubs.source.api.contribution",
246 ],
247 libs: [
248 "stub-annotations",
249 ],
250 visibility: ["//visibility:private"],
251}
252
Paul Duffinbce9f082021-10-28 12:34:41 +0100253// Produces a dist file that is used by the
254// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
255// directory.
256java_library {
257 name: "core-module-lib-stubs-for-system-modules",
258 visibility: ["//visibility:private"],
259 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100260 "core.module_lib.stubs",
261 // This one is not on device but it's needed when javac compiles code
262 // containing lambdas.
263 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100264 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100265 sdk_version: "none",
266 system_modules: "none",
267 dist: {
268 dest: "system-modules/module-lib/core-for-system-modules.jar",
269 targets: dist_targets,
270 },
271}
272
Sorin Basca69f4b082022-05-09 13:55:11 +0100273// Same as core-module-lib-stubs-for-system-modules, but android annotations are
274// stripped. This is used by the Java toolchain, while the annotated stub is to
275// be used by Kotlin one.
276java_library {
277 name: "core-module-lib-stubs-for-system-modules-no-annotations",
278 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000279 defaults: [
280 "system-modules-no-annotations",
281 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100282 static_libs: [
283 "core-module-lib-stubs-for-system-modules",
284 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100285 dist: {
286 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
287 targets: dist_targets,
288 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100289}
290
Paul Duffinbce9f082021-10-28 12:34:41 +0100291// Used when compiling higher-level code with sdk_version "module_current"
292java_system_modules {
293 name: "core-module-lib-stubs-system-modules",
294 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100295 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100296 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100297 visibility: ["//visibility:public"],
298}
299
300// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
301// this.
302// TODO(http://b/134561230) - limit the number of dependents on this.
303core_platform_visibility = ["//visibility:public"]
304
305// Libraries containing the core platform API stubs for the core libraries.
306//
307// Although this stubs library is primarily used by the Java compiler / build to indicate
308// the core platform API surface area, compile_dex: true is used so that the Core Platform
309// API annotations are available to the dex tools that enable enforcement of runtime
310// accessibility. b/119068555
311java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000312 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100313 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000314 defaults: [
315 "core.platform.api.stubs.defaults",
316 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100317 static_libs: [
318 "art.module.public.api.stubs.module_lib",
319 "conscrypt.module.platform.api.stubs",
320 "legacy.i18n.module.platform.api.stubs",
321 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000322}
323
Jihoon Kangbd093452023-12-26 19:08:01 +0000324java_library {
325 name: "legacy.core.platform.api.stubs.exportable.from-source",
326 visibility: core_platform_visibility,
327 defaults: [
328 "core.platform.api.stubs.defaults",
329 ],
330 static_libs: [
331 "art.module.public.api.stubs.exportable.module_lib",
332 "conscrypt.module.platform.api.stubs.exportable",
333 "legacy.i18n.module.platform.api.stubs.exportable",
334 ],
335}
336
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000337java_defaults {
338 name: "android_core_platform_stubs_current_contributions",
339 api_surface: "core_platform",
340 api_contributions: [
341 "art.module.public.api.stubs.source.api.contribution",
342 "art.module.public.api.stubs.source.system.api.contribution",
343 "art.module.public.api.stubs.source.module_lib.api.contribution",
344 "conscrypt.module.platform.api.stubs.source.api.contribution",
345 "i18n.module.public.api.stubs.source.api.contribution",
346 ],
347}
348
349java_api_library {
350 name: "legacy.core.platform.api.stubs.from-text",
351 api_surface: "core_platform",
352 defaults: [
353 "android_core_platform_stubs_current_contributions",
354 ],
355 api_contributions: [
356 "legacy.i18n.module.platform.api.stubs.source.api.contribution",
357 ],
358 libs: [
359 "stub-annotations",
360 ],
361}
362
Jihoon Kang67b64432023-05-31 22:25:21 +0000363java_library {
364 name: "legacy.core.platform.api.stubs",
365 visibility: core_platform_visibility,
366 defaults: [
367 "core.platform.api.stubs.defaults",
368 ],
369 static_libs: [
370 "legacy.core.platform.api.stubs.from-source",
371 ],
372 product_variables: {
373 build_from_text_stub: {
374 static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400375 "legacy.core.platform.api.stubs.from-text",
Jihoon Kang67b64432023-05-31 22:25:21 +0000376 ],
377 exclude_static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400378 "legacy.core.platform.api.stubs.from-source",
Jihoon Kang67b64432023-05-31 22:25:21 +0000379 ],
380 },
381 },
382}
383
Jihoon Kangbd093452023-12-26 19:08:01 +0000384java_library {
385 name: "legacy.core.platform.api.stubs.exportable",
386 visibility: core_platform_visibility,
387 defaults: [
388 "core.platform.api.stubs.defaults",
389 ],
390 static_libs: [
391 "legacy.core.platform.api.stubs.exportable.from-source",
392 ],
393}
394
Jihoon Kang67b64432023-05-31 22:25:21 +0000395java_defaults {
396 name: "core.platform.api.stubs.defaults",
397 hostdex: true,
398 compile_dex: true,
399
400 sdk_version: "none",
401 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100402 patch_module: "java.base",
403}
404
Sorin Basca69f4b082022-05-09 13:55:11 +0100405// Same as legacy.core.platform.api.stubs, but android annotations are
406// stripped. This is used by the Java toolchain, while the annotated stub is to
407// be used by Kotlin one.
408java_library {
409 name: "legacy.core.platform.api.no.annotations.stubs",
410 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000411 defaults: [
412 "system-modules-no-annotations",
413 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100414 hostdex: true,
415 compile_dex: true,
416
Sorin Basca69f4b082022-05-09 13:55:11 +0100417 static_libs: [
418 "legacy.core.platform.api.stubs",
419 ],
420 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100421}
422
Paul Duffinbb360c32021-07-10 23:31:50 +0100423java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000424 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100425 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000426 defaults: [
427 "core.platform.api.stubs.defaults",
428 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100429 static_libs: [
430 "art.module.public.api.stubs.module_lib",
431 // conscrypt only has a stable version, so it is okay to depend on it here:
432 "conscrypt.module.platform.api.stubs",
433 "stable.i18n.module.platform.api.stubs",
434 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000435}
436
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000437java_api_library {
438 name: "stable.core.platform.api.stubs.from-text",
439 api_surface: "core_platform",
440 defaults: [
441 "android_core_platform_stubs_current_contributions",
442 ],
443 api_contributions: [
444 "stable.i18n.module.platform.api.stubs.source.api.contribution",
445 ],
446 libs: [
447 "stub-annotations",
448 ],
449}
450
Jihoon Kang67b64432023-05-31 22:25:21 +0000451java_library {
452 name: "stable.core.platform.api.stubs",
453 visibility: core_platform_visibility,
454 defaults: [
455 "core.platform.api.stubs.defaults",
456 ],
457 static_libs: [
458 "stable.core.platform.api.stubs.from-source",
459 ],
460 product_variables: {
461 build_from_text_stub: {
462 static_libs: [
463 "stable.core.platform.api.stubs.from-text",
464 ],
465 exclude_static_libs: [
466 "stable.core.platform.api.stubs.from-source",
467 ],
468 },
469 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100470}
471
Sorin Basca69f4b082022-05-09 13:55:11 +0100472// Same as stable.core.platform.api.stubs, but android annotations are
473// stripped. This is used by the Java toolchain, while the annotated stub is to
474// be used by Kotlin one.
475java_library {
476 name: "stable.core.platform.api.no.annotations.stubs",
477 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000478 defaults: [
479 "system-modules-no-annotations",
480 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100481 hostdex: true,
482 compile_dex: true,
483
Sorin Basca69f4b082022-05-09 13:55:11 +0100484 static_libs: [
485 "stable.core.platform.api.stubs",
486 ],
487 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100488}
489
Paul Duffinbb360c32021-07-10 23:31:50 +0100490// Used when compiling higher-level code against *.core.platform.api.stubs.
491java_system_modules {
492 name: "legacy-core-platform-api-stubs-system-modules",
493 visibility: core_platform_visibility,
494 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100495 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100496 // This one is not on device but it's needed when javac compiles code
497 // containing lambdas.
498 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100499 ],
500}
501
502java_system_modules {
503 name: "stable-core-platform-api-stubs-system-modules",
504 visibility: core_platform_visibility,
505 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100506 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100507 // This one is not on device but it's needed when javac compiles code
508 // containing lambdas.
509 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100510 ],
511}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000512
513// Used when compiling higher-level code against art.module.public.api.stubs.
514// This abstraction should come from the inner tree linking against the stubs
515// and not from an "sdk", since parts of this abstraction do not belong to an
516// official API (e.g. stub-annotations).
517//
518// This is only intended for use within core libraries and must not be used
519// from outside.
520java_system_modules {
521 name: "art-module-public-api-stubs-system-modules",
522 visibility: [
523 "//art/build/sdk",
524 "//external/conscrypt",
525 "//external/icu/android_icu4j",
526 "//external/wycheproof",
527 ],
528 libs: [
529 "art.module.public.api.stubs",
530 // This one is not on device but it's needed when javac compiles code
531 // containing lambdas.
532 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000533
534 // Ensure that core libraries that depend on the public API can access
535 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
536 // annotations.
537 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000538 ],
539}
540
541// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
542//
543// This is only intended for use within core libraries and must not be used
544// from outside.
545java_system_modules {
546 name: "art-module-lib-api-stubs-system-modules",
547 visibility: [
548 "//art/build/sdk",
549 "//external/conscrypt",
550 "//external/icu/android_icu4j",
551 ],
552 libs: [
553 "art.module.public.api.stubs.module_lib",
554 ],
555}
556
557// Used when compiling against art.module.intra.core.api.stubs.
558java_system_modules {
559 name: "art-module-intra-core-api-stubs-system-modules",
560 visibility: [
561 "//art/build/sdk",
562 "//external/bouncycastle",
563 "//external/conscrypt",
564 "//external/icu/android_icu4j",
565 ],
566 libs: [
567 // The intra core API stubs library.
568 "art.module.intra.core.api.stubs",
569
570 // Additional classes needed by javac but which are not present in the stubs.
571 "art-module-intra-core-api-stubs-system-modules-lib",
572 ],
573}