blob: 57b0e21d7a96ff2091c3ba87c482712f652578dd [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",
41 dist: {
42 targets: dist_targets,
43 },
44}
45
46java_library {
47 name: "core.current.stubs.from-source",
48 defaults: [
49 "core.current.stubs.defaults",
50 ],
Paul Duffinbb360c32021-07-10 23:31:50 +010051 static_libs: [
52 "art.module.public.api.stubs",
53 "conscrypt.module.public.api.stubs",
54 "i18n.module.public.api.stubs",
55 ],
Jihoon Kang67b64432023-05-31 22:25:21 +000056}
Paul Duffinbb360c32021-07-10 23:31:50 +010057
Jihoon Kangb281ddc2023-08-17 18:14:35 +000058java_api_library {
59 name: "core.current.stubs.from-text",
60 api_surface: "core",
61 api_contributions: [
62 "art.module.public.api.stubs.source.api.contribution",
63 "conscrypt.module.public.api.stubs.source.api.contribution",
64 "i18n.module.public.api.stubs.source.api.contribution",
65 ],
66 libs: [
67 "stub-annotations",
68 ],
Jihoon Kang063ec002023-06-28 01:16:23 +000069 enable_validation: false,
Jihoon Kangb281ddc2023-08-17 18:14:35 +000070}
71
Jihoon Kang67b64432023-05-31 22:25:21 +000072java_library {
73 name: "core.current.stubs",
74 defaults: [
75 "core.current.stubs.defaults",
76 ],
77 static_libs: [
78 "core.current.stubs.from-source",
79 ],
80 product_variables: {
81 build_from_text_stub: {
82 static_libs: [
83 "core.current.stubs.from-text",
84 ],
85 exclude_static_libs: [
86 "core.current.stubs.from-source",
87 ],
88 },
Paul Duffinbb360c32021-07-10 23:31:50 +010089 },
90}
91
92// Distributed with the SDK for turning into system modules to compile apps
93// against.
Paul Duffinbce9f082021-10-28 12:34:41 +010094//
95// Also, produces dist files that are used by the
96// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
97// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +010098java_library {
99 name: "core-current-stubs-for-system-modules",
100 visibility: ["//development/sdk"],
101 static_libs: [
102 "core.current.stubs",
103 // This one is not on device but it's needed when javac compiles code
104 // containing lambdas.
105 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100106 ],
107 sdk_version: "none",
108 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +0100109 dists: [
110 {
111 // Legacy dist location for the public file.
112 dest: "core-for-system-modules.jar",
113 targets: dist_targets,
114 },
115 {
116 dest: "system-modules/public/core-for-system-modules.jar",
117 targets: dist_targets,
118 },
119 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100120}
121
Spandan Dasb0f3d422023-03-29 20:59:47 +0000122// Defaults module to strip out android annotations
123java_defaults {
124 name: "system-modules-no-annotations",
125 sdk_version: "none",
126 system_modules: "none",
127 jarjar_rules: "jarjar-strip-annotations-rules.txt",
128}
129
Sorin Bascabdbae602022-07-26 15:24:15 +0100130// Same as core-current-stubs-for-system-modules, but android annotations are
131// stripped.
132java_library {
133 name: "core-current-stubs-for-system-modules-no-annotations",
134 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000135 defaults: [
136 "system-modules-no-annotations",
137 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100138 static_libs: [
139 "core-current-stubs-for-system-modules",
140 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100141 dists: [
142 {
143 // Legacy dist location for the public file.
144 dest: "core-for-system-modules-no-annotations.jar",
145 targets: dist_targets,
146 },
147 {
148 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
149 targets: dist_targets,
150 },
151 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100152}
153
Paul Duffinbb360c32021-07-10 23:31:50 +0100154// Used when compiling higher-level code against core.current.stubs.
155java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000156 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100157 visibility: ["//visibility:public"],
158 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100159 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100160 ],
161}
162
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400163java_defaults {
164 name: "core.module_lib.stubs.defaults",
165 visibility: ["//visibility:private"],
166 sdk_version: "none",
167 system_modules: "none",
168}
169
Paul Duffinbb360c32021-07-10 23:31:50 +0100170// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
171// provided by the core libraries.
172//
173// Don't use this directly, use "sdk_version: module_current".
174java_library {
175 name: "core.module_lib.stubs",
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400176 defaults: [
177 "core.module_lib.stubs.defaults",
178 ],
179 static_libs: [
180 "core.module_lib.stubs.from-source",
181 ],
182 product_variables: {
183 build_from_text_stub: {
184 static_libs: [
185 "core.module_lib.stubs.from-text",
186 ],
187 exclude_static_libs: [
188 "core.module_lib.stubs.from-source",
189 ],
190 },
191 },
192}
193
194java_library {
195 name: "core.module_lib.stubs.from-source",
196 defaults: [
197 "core.module_lib.stubs.defaults",
198 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100199 static_libs: [
200 "art.module.public.api.stubs.module_lib",
201
202 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
203 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
204 // @SystemApi(MODULE_LIBRARIES).
205 "conscrypt.module.public.api.stubs",
206 "i18n.module.public.api.stubs",
207 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100208}
209
Jihoon Kangbfa2f9e2023-11-01 22:49:35 +0000210java_api_library {
211 name: "core.module_lib.stubs.from-text",
212 api_surface: "module-lib",
213 api_contributions: [
214 "art.module.public.api.stubs.source.api.contribution",
215 "art.module.public.api.stubs.source.system.api.contribution",
216 "art.module.public.api.stubs.source.module_lib.api.contribution",
217
218 // Add the module-lib correspondence when Conscrypt or i18N module
219 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
220 // @SystemApi(MODULE_LIBRARIES).
221 "conscrypt.module.public.api.stubs.source.api.contribution",
222 "i18n.module.public.api.stubs.source.api.contribution",
223 ],
224 libs: [
225 "stub-annotations",
226 ],
227 visibility: ["//visibility:private"],
228}
229
Paul Duffinbce9f082021-10-28 12:34:41 +0100230// Produces a dist file that is used by the
231// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
232// directory.
233java_library {
234 name: "core-module-lib-stubs-for-system-modules",
235 visibility: ["//visibility:private"],
236 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100237 "core.module_lib.stubs",
238 // This one is not on device but it's needed when javac compiles code
239 // containing lambdas.
240 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100241 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100242 sdk_version: "none",
243 system_modules: "none",
244 dist: {
245 dest: "system-modules/module-lib/core-for-system-modules.jar",
246 targets: dist_targets,
247 },
248}
249
Sorin Basca69f4b082022-05-09 13:55:11 +0100250// Same as core-module-lib-stubs-for-system-modules, but android annotations are
251// stripped. This is used by the Java toolchain, while the annotated stub is to
252// be used by Kotlin one.
253java_library {
254 name: "core-module-lib-stubs-for-system-modules-no-annotations",
255 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000256 defaults: [
257 "system-modules-no-annotations",
258 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100259 static_libs: [
260 "core-module-lib-stubs-for-system-modules",
261 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100262 dist: {
263 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
264 targets: dist_targets,
265 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100266}
267
Paul Duffinbce9f082021-10-28 12:34:41 +0100268// Used when compiling higher-level code with sdk_version "module_current"
269java_system_modules {
270 name: "core-module-lib-stubs-system-modules",
271 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100272 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100273 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100274 visibility: ["//visibility:public"],
275}
276
277// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
278// this.
279// TODO(http://b/134561230) - limit the number of dependents on this.
280core_platform_visibility = ["//visibility:public"]
281
282// Libraries containing the core platform API stubs for the core libraries.
283//
284// Although this stubs library is primarily used by the Java compiler / build to indicate
285// the core platform API surface area, compile_dex: true is used so that the Core Platform
286// API annotations are available to the dex tools that enable enforcement of runtime
287// accessibility. b/119068555
288java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000289 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100290 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000291 defaults: [
292 "core.platform.api.stubs.defaults",
293 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100294 static_libs: [
295 "art.module.public.api.stubs.module_lib",
296 "conscrypt.module.platform.api.stubs",
297 "legacy.i18n.module.platform.api.stubs",
298 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000299}
300
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000301java_defaults {
302 name: "android_core_platform_stubs_current_contributions",
303 api_surface: "core_platform",
304 api_contributions: [
305 "art.module.public.api.stubs.source.api.contribution",
306 "art.module.public.api.stubs.source.system.api.contribution",
307 "art.module.public.api.stubs.source.module_lib.api.contribution",
308 "conscrypt.module.platform.api.stubs.source.api.contribution",
309 "i18n.module.public.api.stubs.source.api.contribution",
310 ],
311}
312
313java_api_library {
314 name: "legacy.core.platform.api.stubs.from-text",
315 api_surface: "core_platform",
316 defaults: [
317 "android_core_platform_stubs_current_contributions",
318 ],
319 api_contributions: [
320 "legacy.i18n.module.platform.api.stubs.source.api.contribution",
321 ],
322 libs: [
323 "stub-annotations",
324 ],
325}
326
Jihoon Kang67b64432023-05-31 22:25:21 +0000327java_library {
328 name: "legacy.core.platform.api.stubs",
329 visibility: core_platform_visibility,
330 defaults: [
331 "core.platform.api.stubs.defaults",
332 ],
333 static_libs: [
334 "legacy.core.platform.api.stubs.from-source",
335 ],
336 product_variables: {
337 build_from_text_stub: {
338 static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400339 "legacy.core.platform.api.stubs.from-text",
Jihoon Kang67b64432023-05-31 22:25:21 +0000340 ],
341 exclude_static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400342 "legacy.core.platform.api.stubs.from-source",
Jihoon Kang67b64432023-05-31 22:25:21 +0000343 ],
344 },
345 },
346}
347
348java_defaults {
349 name: "core.platform.api.stubs.defaults",
350 hostdex: true,
351 compile_dex: true,
352
353 sdk_version: "none",
354 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100355 patch_module: "java.base",
356}
357
Sorin Basca69f4b082022-05-09 13:55:11 +0100358// Same as legacy.core.platform.api.stubs, but android annotations are
359// stripped. This is used by the Java toolchain, while the annotated stub is to
360// be used by Kotlin one.
361java_library {
362 name: "legacy.core.platform.api.no.annotations.stubs",
363 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000364 defaults: [
365 "system-modules-no-annotations",
366 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100367 hostdex: true,
368 compile_dex: true,
369
Sorin Basca69f4b082022-05-09 13:55:11 +0100370 static_libs: [
371 "legacy.core.platform.api.stubs",
372 ],
373 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100374}
375
Paul Duffinbb360c32021-07-10 23:31:50 +0100376java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000377 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100378 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000379 defaults: [
380 "core.platform.api.stubs.defaults",
381 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100382 static_libs: [
383 "art.module.public.api.stubs.module_lib",
384 // conscrypt only has a stable version, so it is okay to depend on it here:
385 "conscrypt.module.platform.api.stubs",
386 "stable.i18n.module.platform.api.stubs",
387 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000388}
389
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000390java_api_library {
391 name: "stable.core.platform.api.stubs.from-text",
392 api_surface: "core_platform",
393 defaults: [
394 "android_core_platform_stubs_current_contributions",
395 ],
396 api_contributions: [
397 "stable.i18n.module.platform.api.stubs.source.api.contribution",
398 ],
399 libs: [
400 "stub-annotations",
401 ],
402}
403
Jihoon Kang67b64432023-05-31 22:25:21 +0000404java_library {
405 name: "stable.core.platform.api.stubs",
406 visibility: core_platform_visibility,
407 defaults: [
408 "core.platform.api.stubs.defaults",
409 ],
410 static_libs: [
411 "stable.core.platform.api.stubs.from-source",
412 ],
413 product_variables: {
414 build_from_text_stub: {
415 static_libs: [
416 "stable.core.platform.api.stubs.from-text",
417 ],
418 exclude_static_libs: [
419 "stable.core.platform.api.stubs.from-source",
420 ],
421 },
422 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100423}
424
Sorin Basca69f4b082022-05-09 13:55:11 +0100425// Same as stable.core.platform.api.stubs, but android annotations are
426// stripped. This is used by the Java toolchain, while the annotated stub is to
427// be used by Kotlin one.
428java_library {
429 name: "stable.core.platform.api.no.annotations.stubs",
430 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000431 defaults: [
432 "system-modules-no-annotations",
433 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100434 hostdex: true,
435 compile_dex: true,
436
Sorin Basca69f4b082022-05-09 13:55:11 +0100437 static_libs: [
438 "stable.core.platform.api.stubs",
439 ],
440 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100441}
442
Paul Duffinbb360c32021-07-10 23:31:50 +0100443// Used when compiling higher-level code against *.core.platform.api.stubs.
444java_system_modules {
445 name: "legacy-core-platform-api-stubs-system-modules",
446 visibility: core_platform_visibility,
447 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100448 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100449 // This one is not on device but it's needed when javac compiles code
450 // containing lambdas.
451 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100452 ],
453}
454
455java_system_modules {
456 name: "stable-core-platform-api-stubs-system-modules",
457 visibility: core_platform_visibility,
458 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100459 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100460 // This one is not on device but it's needed when javac compiles code
461 // containing lambdas.
462 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100463 ],
464}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000465
466// Used when compiling higher-level code against art.module.public.api.stubs.
467// This abstraction should come from the inner tree linking against the stubs
468// and not from an "sdk", since parts of this abstraction do not belong to an
469// official API (e.g. stub-annotations).
470//
471// This is only intended for use within core libraries and must not be used
472// from outside.
473java_system_modules {
474 name: "art-module-public-api-stubs-system-modules",
475 visibility: [
476 "//art/build/sdk",
477 "//external/conscrypt",
478 "//external/icu/android_icu4j",
479 "//external/wycheproof",
480 ],
481 libs: [
482 "art.module.public.api.stubs",
483 // This one is not on device but it's needed when javac compiles code
484 // containing lambdas.
485 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000486
487 // Ensure that core libraries that depend on the public API can access
488 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
489 // annotations.
490 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000491 ],
492}
493
494// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
495//
496// This is only intended for use within core libraries and must not be used
497// from outside.
498java_system_modules {
499 name: "art-module-lib-api-stubs-system-modules",
500 visibility: [
501 "//art/build/sdk",
502 "//external/conscrypt",
503 "//external/icu/android_icu4j",
504 ],
505 libs: [
506 "art.module.public.api.stubs.module_lib",
507 ],
508}
509
510// Used when compiling against art.module.intra.core.api.stubs.
511java_system_modules {
512 name: "art-module-intra-core-api-stubs-system-modules",
513 visibility: [
514 "//art/build/sdk",
515 "//external/bouncycastle",
516 "//external/conscrypt",
517 "//external/icu/android_icu4j",
518 ],
519 libs: [
520 // The intra core API stubs library.
521 "art.module.intra.core.api.stubs",
522
523 // Additional classes needed by javac but which are not present in the stubs.
524 "art-module-intra-core-api-stubs-system-modules-lib",
525 ],
526}
Spandan Das4f771f12023-03-29 22:25:59 +0000527
528build = [
529 "TxtStubLibraries.bp",
530]