blob: da865404bf81788521152201703125e5c646602f [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 Kang85bc1932024-07-01 17:04:46 +000041 is_stubs_module: true,
Jihoon Kang67b64432023-05-31 22:25:21 +000042}
43
Jihoon Kanga043a1b2024-03-21 20:54:49 +000044soong_config_module_type {
45 name: "core_current_stubs_soong_config_defaults",
46 module_type: "java_defaults",
47 config_namespace: "ANDROID",
48 bool_variables: [
49 "release_hidden_api_exportable_stubs",
50 ],
51 properties: [
52 "dist.targets",
53 "dist.dest",
54 ],
55}
56
57core_current_stubs_soong_config_defaults {
58 name: "core_current_stubs_everything_soong_config_defaults",
59 soong_config_variables: {
60 release_hidden_api_exportable_stubs: {
61 conditions_default: {
62 dist: {
63 targets: dist_targets,
64 dest: "core.current.stubs.jar",
65 },
66 },
67 },
68 },
69}
70
71core_current_stubs_soong_config_defaults {
72 name: "core_current_stubs_exportable_soong_config_defaults",
73 soong_config_variables: {
74 release_hidden_api_exportable_stubs: {
75 dist: {
76 targets: dist_targets,
77 dest: "core.current.stubs.jar",
78 },
79 },
80 },
81}
82
Jihoon Kang67b64432023-05-31 22:25:21 +000083java_library {
Jihoon Kangb0f4c022024-08-06 00:15:25 +000084 name: "core.current.stubs",
Jihoon Kang67b64432023-05-31 22:25:21 +000085 defaults: [
86 "core.current.stubs.defaults",
Jihoon Kanga043a1b2024-03-21 20:54:49 +000087 "core_current_stubs_everything_soong_config_defaults",
Jihoon Kang67b64432023-05-31 22:25:21 +000088 ],
Paul Duffinbb360c32021-07-10 23:31:50 +010089 static_libs: [
90 "art.module.public.api.stubs",
91 "conscrypt.module.public.api.stubs",
92 "i18n.module.public.api.stubs",
93 ],
Jihoon Kang67b64432023-05-31 22:25:21 +000094}
Paul Duffinbb360c32021-07-10 23:31:50 +010095
Jihoon Kangb0f4c022024-08-06 00:15:25 +000096// Used for bootstrapping ART system modules
Jihoon Kangb281ddc2023-08-17 18:14:35 +000097java_api_library {
98 name: "core.current.stubs.from-text",
Jihoon Kangb0f4c022024-08-06 00:15:25 +000099 defaults: [
100 "core.current.stubs.defaults",
101 ],
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000102 api_surface: "core",
103 api_contributions: [
104 "art.module.public.api.stubs.source.api.contribution",
105 "conscrypt.module.public.api.stubs.source.api.contribution",
106 "i18n.module.public.api.stubs.source.api.contribution",
107 ],
108 libs: [
109 "stub-annotations",
110 ],
Jihoon Kang063ec002023-06-28 01:16:23 +0000111 enable_validation: false,
Jihoon Kang5d701272024-02-15 21:53:49 +0000112 stubs_type: "everything",
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000113}
114
Jihoon Kang67b64432023-05-31 22:25:21 +0000115java_library {
Jihoon Kangb0f4c022024-08-06 00:15:25 +0000116 name: "core.current.stubs.exportable",
Jihoon Kangbd093452023-12-26 19:08:01 +0000117 defaults: [
118 "core.current.stubs.defaults",
Jihoon Kanga043a1b2024-03-21 20:54:49 +0000119 "core_current_stubs_exportable_soong_config_defaults",
Jihoon Kangbd093452023-12-26 19:08:01 +0000120 ],
121 static_libs: [
122 "art.module.public.api.stubs.exportable",
123 "conscrypt.module.public.api.stubs.exportable",
124 "i18n.module.public.api.stubs.exportable",
125 ],
Jihoon Kangbd093452023-12-26 19:08:01 +0000126}
127
Paul Duffinbb360c32021-07-10 23:31:50 +0100128// Distributed with the SDK for turning into system modules to compile apps
129// against.
Paul Duffinbce9f082021-10-28 12:34:41 +0100130//
131// Also, produces dist files that are used by the
132// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
133// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +0100134java_library {
135 name: "core-current-stubs-for-system-modules",
136 visibility: ["//development/sdk"],
137 static_libs: [
138 "core.current.stubs",
139 // This one is not on device but it's needed when javac compiles code
140 // containing lambdas.
141 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100142 ],
143 sdk_version: "none",
144 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +0100145 dists: [
146 {
147 // Legacy dist location for the public file.
148 dest: "core-for-system-modules.jar",
149 targets: dist_targets,
150 },
151 {
152 dest: "system-modules/public/core-for-system-modules.jar",
153 targets: dist_targets,
154 },
155 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100156}
157
Spandan Dasb0f3d422023-03-29 20:59:47 +0000158// Defaults module to strip out android annotations
159java_defaults {
160 name: "system-modules-no-annotations",
161 sdk_version: "none",
162 system_modules: "none",
163 jarjar_rules: "jarjar-strip-annotations-rules.txt",
164}
165
Sorin Bascabdbae602022-07-26 15:24:15 +0100166// Same as core-current-stubs-for-system-modules, but android annotations are
167// stripped.
168java_library {
169 name: "core-current-stubs-for-system-modules-no-annotations",
170 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000171 defaults: [
172 "system-modules-no-annotations",
173 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100174 static_libs: [
175 "core-current-stubs-for-system-modules",
176 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100177 dists: [
178 {
179 // Legacy dist location for the public file.
180 dest: "core-for-system-modules-no-annotations.jar",
181 targets: dist_targets,
182 },
183 {
184 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
185 targets: dist_targets,
186 },
187 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100188}
189
Paul Duffinbb360c32021-07-10 23:31:50 +0100190// Used when compiling higher-level code against core.current.stubs.
191java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000192 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100193 visibility: ["//visibility:public"],
194 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100195 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100196 ],
197}
198
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400199java_defaults {
200 name: "core.module_lib.stubs.defaults",
201 visibility: ["//visibility:private"],
202 sdk_version: "none",
203 system_modules: "none",
204}
205
Paul Duffinbb360c32021-07-10 23:31:50 +0100206// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
207// provided by the core libraries.
208//
209// Don't use this directly, use "sdk_version: module_current".
210java_library {
211 name: "core.module_lib.stubs",
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400212 defaults: [
213 "core.module_lib.stubs.defaults",
214 ],
215 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100216 "art.module.public.api.stubs.module_lib",
217
218 // Replace the following with 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",
222 "i18n.module.public.api.stubs",
223 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100224}
225
Paul Duffinbce9f082021-10-28 12:34:41 +0100226// Produces a dist file that is used by the
227// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
228// directory.
229java_library {
230 name: "core-module-lib-stubs-for-system-modules",
231 visibility: ["//visibility:private"],
232 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100233 "core.module_lib.stubs",
234 // This one is not on device but it's needed when javac compiles code
235 // containing lambdas.
236 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100237 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100238 sdk_version: "none",
239 system_modules: "none",
240 dist: {
241 dest: "system-modules/module-lib/core-for-system-modules.jar",
242 targets: dist_targets,
243 },
244}
245
Sorin Basca69f4b082022-05-09 13:55:11 +0100246// Same as core-module-lib-stubs-for-system-modules, but android annotations are
247// stripped. This is used by the Java toolchain, while the annotated stub is to
248// be used by Kotlin one.
249java_library {
250 name: "core-module-lib-stubs-for-system-modules-no-annotations",
251 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000252 defaults: [
253 "system-modules-no-annotations",
254 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100255 static_libs: [
256 "core-module-lib-stubs-for-system-modules",
257 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100258 dist: {
259 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
260 targets: dist_targets,
261 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100262}
263
Paul Duffinbce9f082021-10-28 12:34:41 +0100264// Used when compiling higher-level code with sdk_version "module_current"
265java_system_modules {
266 name: "core-module-lib-stubs-system-modules",
267 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100268 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100269 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100270 visibility: ["//visibility:public"],
271}
272
273// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
274// this.
275// TODO(http://b/134561230) - limit the number of dependents on this.
276core_platform_visibility = ["//visibility:public"]
277
278// Libraries containing the core platform API stubs for the core libraries.
279//
280// Although this stubs library is primarily used by the Java compiler / build to indicate
281// the core platform API surface area, compile_dex: true is used so that the Core Platform
282// API annotations are available to the dex tools that enable enforcement of runtime
283// accessibility. b/119068555
284java_library {
Jihoon Kangb0f4c022024-08-06 00:15:25 +0000285 name: "legacy.core.platform.api.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100286 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000287 defaults: [
288 "core.platform.api.stubs.defaults",
289 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100290 static_libs: [
291 "art.module.public.api.stubs.module_lib",
292 "conscrypt.module.platform.api.stubs",
293 "legacy.i18n.module.platform.api.stubs",
294 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000295}
296
Jihoon Kangbd093452023-12-26 19:08:01 +0000297java_library {
Jihoon Kangb0f4c022024-08-06 00:15:25 +0000298 name: "legacy.core.platform.api.stubs.exportable",
Jihoon Kangbd093452023-12-26 19:08:01 +0000299 visibility: core_platform_visibility,
300 defaults: [
301 "core.platform.api.stubs.defaults",
302 ],
303 static_libs: [
304 "art.module.public.api.stubs.exportable.module_lib",
305 "conscrypt.module.platform.api.stubs.exportable",
306 "legacy.i18n.module.platform.api.stubs.exportable",
307 ],
308}
309
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000310java_defaults {
311 name: "android_core_platform_stubs_current_contributions",
312 api_surface: "core_platform",
313 api_contributions: [
314 "art.module.public.api.stubs.source.api.contribution",
315 "art.module.public.api.stubs.source.system.api.contribution",
316 "art.module.public.api.stubs.source.module_lib.api.contribution",
317 "conscrypt.module.platform.api.stubs.source.api.contribution",
318 "i18n.module.public.api.stubs.source.api.contribution",
319 ],
320}
321
Jihoon Kang67b64432023-05-31 22:25:21 +0000322java_defaults {
323 name: "core.platform.api.stubs.defaults",
324 hostdex: true,
325 compile_dex: true,
326
327 sdk_version: "none",
328 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100329 patch_module: "java.base",
Jihoon Kang85bc1932024-07-01 17:04:46 +0000330 is_stubs_module: true,
Paul Duffinbb360c32021-07-10 23:31:50 +0100331}
332
Sorin Basca69f4b082022-05-09 13:55:11 +0100333// Same as legacy.core.platform.api.stubs, but android annotations are
334// stripped. This is used by the Java toolchain, while the annotated stub is to
335// be used by Kotlin one.
336java_library {
337 name: "legacy.core.platform.api.no.annotations.stubs",
338 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000339 defaults: [
340 "system-modules-no-annotations",
341 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100342 hostdex: true,
343 compile_dex: true,
344
Sorin Basca69f4b082022-05-09 13:55:11 +0100345 static_libs: [
346 "legacy.core.platform.api.stubs",
347 ],
348 patch_module: "java.base",
Jihoon Kang85bc1932024-07-01 17:04:46 +0000349 is_stubs_module: true,
Sorin Basca69f4b082022-05-09 13:55:11 +0100350}
351
Paul Duffinbb360c32021-07-10 23:31:50 +0100352java_library {
Jihoon Kangb0f4c022024-08-06 00:15:25 +0000353 name: "stable.core.platform.api.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100354 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000355 defaults: [
356 "core.platform.api.stubs.defaults",
357 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100358 static_libs: [
359 "art.module.public.api.stubs.module_lib",
360 // conscrypt only has a stable version, so it is okay to depend on it here:
361 "conscrypt.module.platform.api.stubs",
362 "stable.i18n.module.platform.api.stubs",
363 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000364}
365
Sorin Basca69f4b082022-05-09 13:55:11 +0100366// Same as stable.core.platform.api.stubs, but android annotations are
367// stripped. This is used by the Java toolchain, while the annotated stub is to
368// be used by Kotlin one.
369java_library {
370 name: "stable.core.platform.api.no.annotations.stubs",
371 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000372 defaults: [
373 "system-modules-no-annotations",
374 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100375 hostdex: true,
376 compile_dex: true,
377
Sorin Basca69f4b082022-05-09 13:55:11 +0100378 static_libs: [
379 "stable.core.platform.api.stubs",
380 ],
381 patch_module: "java.base",
Jihoon Kang85bc1932024-07-01 17:04:46 +0000382 is_stubs_module: true,
Sorin Basca69f4b082022-05-09 13:55:11 +0100383}
384
Paul Duffinbb360c32021-07-10 23:31:50 +0100385// Used when compiling higher-level code against *.core.platform.api.stubs.
386java_system_modules {
387 name: "legacy-core-platform-api-stubs-system-modules",
388 visibility: core_platform_visibility,
389 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100390 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100391 // This one is not on device but it's needed when javac compiles code
392 // containing lambdas.
393 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100394 ],
395}
396
397java_system_modules {
398 name: "stable-core-platform-api-stubs-system-modules",
399 visibility: core_platform_visibility,
400 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100401 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100402 // This one is not on device but it's needed when javac compiles code
403 // containing lambdas.
404 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100405 ],
406}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000407
408// Used when compiling higher-level code against art.module.public.api.stubs.
409// This abstraction should come from the inner tree linking against the stubs
410// and not from an "sdk", since parts of this abstraction do not belong to an
411// official API (e.g. stub-annotations).
412//
413// This is only intended for use within core libraries and must not be used
414// from outside.
415java_system_modules {
416 name: "art-module-public-api-stubs-system-modules",
417 visibility: [
418 "//art/build/sdk",
419 "//external/conscrypt",
420 "//external/icu/android_icu4j",
421 "//external/wycheproof",
422 ],
423 libs: [
424 "art.module.public.api.stubs",
425 // This one is not on device but it's needed when javac compiles code
426 // containing lambdas.
427 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000428
429 // Ensure that core libraries that depend on the public API can access
430 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
431 // annotations.
432 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000433 ],
434}
435
436// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
437//
438// This is only intended for use within core libraries and must not be used
439// from outside.
440java_system_modules {
441 name: "art-module-lib-api-stubs-system-modules",
442 visibility: [
443 "//art/build/sdk",
444 "//external/conscrypt",
445 "//external/icu/android_icu4j",
446 ],
447 libs: [
448 "art.module.public.api.stubs.module_lib",
449 ],
450}
451
452// Used when compiling against art.module.intra.core.api.stubs.
453java_system_modules {
454 name: "art-module-intra-core-api-stubs-system-modules",
455 visibility: [
456 "//art/build/sdk",
457 "//external/bouncycastle",
458 "//external/conscrypt",
459 "//external/icu/android_icu4j",
460 ],
461 libs: [
462 // The intra core API stubs library.
463 "art.module.intra.core.api.stubs",
464
465 // Additional classes needed by javac but which are not present in the stubs.
466 "art-module-intra-core-api-stubs-system-modules-lib",
467 ],
468}