blob: 8b7387a854d78378739fcac3c17f82c1088c503a [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
Paul Duffinbce9f082021-10-28 12:34:41 +0100210// Produces a dist file that is used by the
211// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
212// directory.
213java_library {
214 name: "core-module-lib-stubs-for-system-modules",
215 visibility: ["//visibility:private"],
216 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100217 "core.module_lib.stubs",
218 // This one is not on device but it's needed when javac compiles code
219 // containing lambdas.
220 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100221 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100222 sdk_version: "none",
223 system_modules: "none",
224 dist: {
225 dest: "system-modules/module-lib/core-for-system-modules.jar",
226 targets: dist_targets,
227 },
228}
229
Sorin Basca69f4b082022-05-09 13:55:11 +0100230// Same as core-module-lib-stubs-for-system-modules, but android annotations are
231// stripped. This is used by the Java toolchain, while the annotated stub is to
232// be used by Kotlin one.
233java_library {
234 name: "core-module-lib-stubs-for-system-modules-no-annotations",
235 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000236 defaults: [
237 "system-modules-no-annotations",
238 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100239 static_libs: [
240 "core-module-lib-stubs-for-system-modules",
241 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100242 dist: {
243 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
244 targets: dist_targets,
245 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100246}
247
Paul Duffinbce9f082021-10-28 12:34:41 +0100248// Used when compiling higher-level code with sdk_version "module_current"
249java_system_modules {
250 name: "core-module-lib-stubs-system-modules",
251 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100252 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100253 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100254 visibility: ["//visibility:public"],
255}
256
257// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
258// this.
259// TODO(http://b/134561230) - limit the number of dependents on this.
260core_platform_visibility = ["//visibility:public"]
261
262// Libraries containing the core platform API stubs for the core libraries.
263//
264// Although this stubs library is primarily used by the Java compiler / build to indicate
265// the core platform API surface area, compile_dex: true is used so that the Core Platform
266// API annotations are available to the dex tools that enable enforcement of runtime
267// accessibility. b/119068555
268java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000269 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100270 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000271 defaults: [
272 "core.platform.api.stubs.defaults",
273 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100274 static_libs: [
275 "art.module.public.api.stubs.module_lib",
276 "conscrypt.module.platform.api.stubs",
277 "legacy.i18n.module.platform.api.stubs",
278 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000279}
280
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000281java_defaults {
282 name: "android_core_platform_stubs_current_contributions",
283 api_surface: "core_platform",
284 api_contributions: [
285 "art.module.public.api.stubs.source.api.contribution",
286 "art.module.public.api.stubs.source.system.api.contribution",
287 "art.module.public.api.stubs.source.module_lib.api.contribution",
288 "conscrypt.module.platform.api.stubs.source.api.contribution",
289 "i18n.module.public.api.stubs.source.api.contribution",
290 ],
291}
292
293java_api_library {
294 name: "legacy.core.platform.api.stubs.from-text",
295 api_surface: "core_platform",
296 defaults: [
297 "android_core_platform_stubs_current_contributions",
298 ],
299 api_contributions: [
300 "legacy.i18n.module.platform.api.stubs.source.api.contribution",
301 ],
302 libs: [
303 "stub-annotations",
304 ],
305}
306
Jihoon Kang67b64432023-05-31 22:25:21 +0000307java_library {
308 name: "legacy.core.platform.api.stubs",
309 visibility: core_platform_visibility,
310 defaults: [
311 "core.platform.api.stubs.defaults",
312 ],
313 static_libs: [
314 "legacy.core.platform.api.stubs.from-source",
315 ],
316 product_variables: {
317 build_from_text_stub: {
318 static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400319 "legacy.core.platform.api.stubs.from-text",
Jihoon Kang67b64432023-05-31 22:25:21 +0000320 ],
321 exclude_static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400322 "legacy.core.platform.api.stubs.from-source",
Jihoon Kang67b64432023-05-31 22:25:21 +0000323 ],
324 },
325 },
326}
327
328java_defaults {
329 name: "core.platform.api.stubs.defaults",
330 hostdex: true,
331 compile_dex: true,
332
333 sdk_version: "none",
334 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100335 patch_module: "java.base",
336}
337
Sorin Basca69f4b082022-05-09 13:55:11 +0100338// Same as legacy.core.platform.api.stubs, but android annotations are
339// stripped. This is used by the Java toolchain, while the annotated stub is to
340// be used by Kotlin one.
341java_library {
342 name: "legacy.core.platform.api.no.annotations.stubs",
343 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000344 defaults: [
345 "system-modules-no-annotations",
346 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100347 hostdex: true,
348 compile_dex: true,
349
Sorin Basca69f4b082022-05-09 13:55:11 +0100350 static_libs: [
351 "legacy.core.platform.api.stubs",
352 ],
353 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100354}
355
Paul Duffinbb360c32021-07-10 23:31:50 +0100356java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000357 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100358 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000359 defaults: [
360 "core.platform.api.stubs.defaults",
361 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100362 static_libs: [
363 "art.module.public.api.stubs.module_lib",
364 // conscrypt only has a stable version, so it is okay to depend on it here:
365 "conscrypt.module.platform.api.stubs",
366 "stable.i18n.module.platform.api.stubs",
367 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000368}
369
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000370java_api_library {
371 name: "stable.core.platform.api.stubs.from-text",
372 api_surface: "core_platform",
373 defaults: [
374 "android_core_platform_stubs_current_contributions",
375 ],
376 api_contributions: [
377 "stable.i18n.module.platform.api.stubs.source.api.contribution",
378 ],
379 libs: [
380 "stub-annotations",
381 ],
382}
383
Jihoon Kang67b64432023-05-31 22:25:21 +0000384java_library {
385 name: "stable.core.platform.api.stubs",
386 visibility: core_platform_visibility,
387 defaults: [
388 "core.platform.api.stubs.defaults",
389 ],
390 static_libs: [
391 "stable.core.platform.api.stubs.from-source",
392 ],
393 product_variables: {
394 build_from_text_stub: {
395 static_libs: [
396 "stable.core.platform.api.stubs.from-text",
397 ],
398 exclude_static_libs: [
399 "stable.core.platform.api.stubs.from-source",
400 ],
401 },
402 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100403}
404
Sorin Basca69f4b082022-05-09 13:55:11 +0100405// Same as stable.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: "stable.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 "stable.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 +0100423// Used when compiling higher-level code against *.core.platform.api.stubs.
424java_system_modules {
425 name: "legacy-core-platform-api-stubs-system-modules",
426 visibility: core_platform_visibility,
427 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100428 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100429 // This one is not on device but it's needed when javac compiles code
430 // containing lambdas.
431 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100432 ],
433}
434
435java_system_modules {
436 name: "stable-core-platform-api-stubs-system-modules",
437 visibility: core_platform_visibility,
438 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100439 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100440 // This one is not on device but it's needed when javac compiles code
441 // containing lambdas.
442 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100443 ],
444}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000445
446// Used when compiling higher-level code against art.module.public.api.stubs.
447// This abstraction should come from the inner tree linking against the stubs
448// and not from an "sdk", since parts of this abstraction do not belong to an
449// official API (e.g. stub-annotations).
450//
451// This is only intended for use within core libraries and must not be used
452// from outside.
453java_system_modules {
454 name: "art-module-public-api-stubs-system-modules",
455 visibility: [
456 "//art/build/sdk",
457 "//external/conscrypt",
458 "//external/icu/android_icu4j",
459 "//external/wycheproof",
460 ],
461 libs: [
462 "art.module.public.api.stubs",
463 // This one is not on device but it's needed when javac compiles code
464 // containing lambdas.
465 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000466
467 // Ensure that core libraries that depend on the public API can access
468 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
469 // annotations.
470 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000471 ],
472}
473
474// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
475//
476// This is only intended for use within core libraries and must not be used
477// from outside.
478java_system_modules {
479 name: "art-module-lib-api-stubs-system-modules",
480 visibility: [
481 "//art/build/sdk",
482 "//external/conscrypt",
483 "//external/icu/android_icu4j",
484 ],
485 libs: [
486 "art.module.public.api.stubs.module_lib",
487 ],
488}
489
490// Used when compiling against art.module.intra.core.api.stubs.
491java_system_modules {
492 name: "art-module-intra-core-api-stubs-system-modules",
493 visibility: [
494 "//art/build/sdk",
495 "//external/bouncycastle",
496 "//external/conscrypt",
497 "//external/icu/android_icu4j",
498 ],
499 libs: [
500 // The intra core API stubs library.
501 "art.module.intra.core.api.stubs",
502
503 // Additional classes needed by javac but which are not present in the stubs.
504 "art-module-intra-core-api-stubs-system-modules-lib",
505 ],
506}
Spandan Das4f771f12023-03-29 22:25:59 +0000507
508build = [
509 "TxtStubLibraries.bp",
510]