blob: 4380f4f5ca96fae0b065af4f543e26593a4056ff [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 ],
69}
70
Jihoon Kang67b64432023-05-31 22:25:21 +000071java_library {
72 name: "core.current.stubs",
73 defaults: [
74 "core.current.stubs.defaults",
75 ],
76 static_libs: [
77 "core.current.stubs.from-source",
78 ],
79 product_variables: {
80 build_from_text_stub: {
81 static_libs: [
82 "core.current.stubs.from-text",
83 ],
84 exclude_static_libs: [
85 "core.current.stubs.from-source",
86 ],
87 },
Paul Duffinbb360c32021-07-10 23:31:50 +010088 },
89}
90
91// Distributed with the SDK for turning into system modules to compile apps
92// against.
Paul Duffinbce9f082021-10-28 12:34:41 +010093//
94// Also, produces dist files that are used by the
95// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
96// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +010097java_library {
98 name: "core-current-stubs-for-system-modules",
99 visibility: ["//development/sdk"],
100 static_libs: [
101 "core.current.stubs",
102 // This one is not on device but it's needed when javac compiles code
103 // containing lambdas.
104 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100105 ],
106 sdk_version: "none",
107 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +0100108 dists: [
109 {
110 // Legacy dist location for the public file.
111 dest: "core-for-system-modules.jar",
112 targets: dist_targets,
113 },
114 {
115 dest: "system-modules/public/core-for-system-modules.jar",
116 targets: dist_targets,
117 },
118 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100119}
120
Spandan Dasb0f3d422023-03-29 20:59:47 +0000121// Defaults module to strip out android annotations
122java_defaults {
123 name: "system-modules-no-annotations",
124 sdk_version: "none",
125 system_modules: "none",
126 jarjar_rules: "jarjar-strip-annotations-rules.txt",
127}
128
Sorin Bascabdbae602022-07-26 15:24:15 +0100129// Same as core-current-stubs-for-system-modules, but android annotations are
130// stripped.
131java_library {
132 name: "core-current-stubs-for-system-modules-no-annotations",
133 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000134 defaults: [
135 "system-modules-no-annotations",
136 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100137 static_libs: [
138 "core-current-stubs-for-system-modules",
139 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100140 dists: [
141 {
142 // Legacy dist location for the public file.
143 dest: "core-for-system-modules-no-annotations.jar",
144 targets: dist_targets,
145 },
146 {
147 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
148 targets: dist_targets,
149 },
150 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100151}
152
Paul Duffinbb360c32021-07-10 23:31:50 +0100153// Used when compiling higher-level code against core.current.stubs.
154java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000155 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100156 visibility: ["//visibility:public"],
157 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100158 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100159 ],
160}
161
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400162java_defaults {
163 name: "core.module_lib.stubs.defaults",
164 visibility: ["//visibility:private"],
165 sdk_version: "none",
166 system_modules: "none",
167}
168
Paul Duffinbb360c32021-07-10 23:31:50 +0100169// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
170// provided by the core libraries.
171//
172// Don't use this directly, use "sdk_version: module_current".
173java_library {
174 name: "core.module_lib.stubs",
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400175 defaults: [
176 "core.module_lib.stubs.defaults",
177 ],
178 static_libs: [
179 "core.module_lib.stubs.from-source",
180 ],
181 product_variables: {
182 build_from_text_stub: {
183 static_libs: [
184 "core.module_lib.stubs.from-text",
185 ],
186 exclude_static_libs: [
187 "core.module_lib.stubs.from-source",
188 ],
189 },
190 },
191}
192
193java_library {
194 name: "core.module_lib.stubs.from-source",
195 defaults: [
196 "core.module_lib.stubs.defaults",
197 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100198 static_libs: [
199 "art.module.public.api.stubs.module_lib",
200
201 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
202 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
203 // @SystemApi(MODULE_LIBRARIES).
204 "conscrypt.module.public.api.stubs",
205 "i18n.module.public.api.stubs",
206 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100207}
208
Paul Duffinbce9f082021-10-28 12:34:41 +0100209// Produces a dist file that is used by the
210// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
211// directory.
212java_library {
213 name: "core-module-lib-stubs-for-system-modules",
214 visibility: ["//visibility:private"],
215 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100216 "core.module_lib.stubs",
217 // This one is not on device but it's needed when javac compiles code
218 // containing lambdas.
219 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100220 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100221 sdk_version: "none",
222 system_modules: "none",
223 dist: {
224 dest: "system-modules/module-lib/core-for-system-modules.jar",
225 targets: dist_targets,
226 },
227}
228
Sorin Basca69f4b082022-05-09 13:55:11 +0100229// Same as core-module-lib-stubs-for-system-modules, but android annotations are
230// stripped. This is used by the Java toolchain, while the annotated stub is to
231// be used by Kotlin one.
232java_library {
233 name: "core-module-lib-stubs-for-system-modules-no-annotations",
234 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000235 defaults: [
236 "system-modules-no-annotations",
237 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100238 static_libs: [
239 "core-module-lib-stubs-for-system-modules",
240 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100241 dist: {
242 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
243 targets: dist_targets,
244 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100245}
246
Paul Duffinbce9f082021-10-28 12:34:41 +0100247// Used when compiling higher-level code with sdk_version "module_current"
248java_system_modules {
249 name: "core-module-lib-stubs-system-modules",
250 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100251 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100252 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100253 visibility: ["//visibility:public"],
254}
255
256// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
257// this.
258// TODO(http://b/134561230) - limit the number of dependents on this.
259core_platform_visibility = ["//visibility:public"]
260
261// Libraries containing the core platform API stubs for the core libraries.
262//
263// Although this stubs library is primarily used by the Java compiler / build to indicate
264// the core platform API surface area, compile_dex: true is used so that the Core Platform
265// API annotations are available to the dex tools that enable enforcement of runtime
266// accessibility. b/119068555
267java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000268 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100269 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000270 defaults: [
271 "core.platform.api.stubs.defaults",
272 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100273 static_libs: [
274 "art.module.public.api.stubs.module_lib",
275 "conscrypt.module.platform.api.stubs",
276 "legacy.i18n.module.platform.api.stubs",
277 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000278}
279
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000280java_defaults {
281 name: "android_core_platform_stubs_current_contributions",
282 api_surface: "core_platform",
283 api_contributions: [
284 "art.module.public.api.stubs.source.api.contribution",
285 "art.module.public.api.stubs.source.system.api.contribution",
286 "art.module.public.api.stubs.source.module_lib.api.contribution",
287 "conscrypt.module.platform.api.stubs.source.api.contribution",
288 "i18n.module.public.api.stubs.source.api.contribution",
289 ],
290}
291
292java_api_library {
293 name: "legacy.core.platform.api.stubs.from-text",
294 api_surface: "core_platform",
295 defaults: [
296 "android_core_platform_stubs_current_contributions",
297 ],
298 api_contributions: [
299 "legacy.i18n.module.platform.api.stubs.source.api.contribution",
300 ],
301 libs: [
302 "stub-annotations",
303 ],
304}
305
Jihoon Kang67b64432023-05-31 22:25:21 +0000306java_library {
307 name: "legacy.core.platform.api.stubs",
308 visibility: core_platform_visibility,
309 defaults: [
310 "core.platform.api.stubs.defaults",
311 ],
312 static_libs: [
313 "legacy.core.platform.api.stubs.from-source",
314 ],
315 product_variables: {
316 build_from_text_stub: {
317 static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400318 "legacy.core.platform.api.stubs.from-text",
Jihoon Kang67b64432023-05-31 22:25:21 +0000319 ],
320 exclude_static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400321 "legacy.core.platform.api.stubs.from-source",
Jihoon Kang67b64432023-05-31 22:25:21 +0000322 ],
323 },
324 },
325}
326
327java_defaults {
328 name: "core.platform.api.stubs.defaults",
329 hostdex: true,
330 compile_dex: true,
331
332 sdk_version: "none",
333 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100334 patch_module: "java.base",
335}
336
Sorin Basca69f4b082022-05-09 13:55:11 +0100337// Same as legacy.core.platform.api.stubs, but android annotations are
338// stripped. This is used by the Java toolchain, while the annotated stub is to
339// be used by Kotlin one.
340java_library {
341 name: "legacy.core.platform.api.no.annotations.stubs",
342 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000343 defaults: [
344 "system-modules-no-annotations",
345 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100346 hostdex: true,
347 compile_dex: true,
348
Sorin Basca69f4b082022-05-09 13:55:11 +0100349 static_libs: [
350 "legacy.core.platform.api.stubs",
351 ],
352 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100353}
354
Paul Duffinbb360c32021-07-10 23:31:50 +0100355java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000356 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100357 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000358 defaults: [
359 "core.platform.api.stubs.defaults",
360 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100361 static_libs: [
362 "art.module.public.api.stubs.module_lib",
363 // conscrypt only has a stable version, so it is okay to depend on it here:
364 "conscrypt.module.platform.api.stubs",
365 "stable.i18n.module.platform.api.stubs",
366 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000367}
368
Jihoon Kangb281ddc2023-08-17 18:14:35 +0000369java_api_library {
370 name: "stable.core.platform.api.stubs.from-text",
371 api_surface: "core_platform",
372 defaults: [
373 "android_core_platform_stubs_current_contributions",
374 ],
375 api_contributions: [
376 "stable.i18n.module.platform.api.stubs.source.api.contribution",
377 ],
378 libs: [
379 "stub-annotations",
380 ],
381}
382
Jihoon Kang67b64432023-05-31 22:25:21 +0000383java_library {
384 name: "stable.core.platform.api.stubs",
385 visibility: core_platform_visibility,
386 defaults: [
387 "core.platform.api.stubs.defaults",
388 ],
389 static_libs: [
390 "stable.core.platform.api.stubs.from-source",
391 ],
392 product_variables: {
393 build_from_text_stub: {
394 static_libs: [
395 "stable.core.platform.api.stubs.from-text",
396 ],
397 exclude_static_libs: [
398 "stable.core.platform.api.stubs.from-source",
399 ],
400 },
401 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100402}
403
Sorin Basca69f4b082022-05-09 13:55:11 +0100404// Same as stable.core.platform.api.stubs, but android annotations are
405// stripped. This is used by the Java toolchain, while the annotated stub is to
406// be used by Kotlin one.
407java_library {
408 name: "stable.core.platform.api.no.annotations.stubs",
409 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000410 defaults: [
411 "system-modules-no-annotations",
412 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100413 hostdex: true,
414 compile_dex: true,
415
Sorin Basca69f4b082022-05-09 13:55:11 +0100416 static_libs: [
417 "stable.core.platform.api.stubs",
418 ],
419 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100420}
421
Paul Duffinbb360c32021-07-10 23:31:50 +0100422// Used when compiling higher-level code against *.core.platform.api.stubs.
423java_system_modules {
424 name: "legacy-core-platform-api-stubs-system-modules",
425 visibility: core_platform_visibility,
426 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100427 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100428 // This one is not on device but it's needed when javac compiles code
429 // containing lambdas.
430 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100431 ],
432}
433
434java_system_modules {
435 name: "stable-core-platform-api-stubs-system-modules",
436 visibility: core_platform_visibility,
437 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100438 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100439 // This one is not on device but it's needed when javac compiles code
440 // containing lambdas.
441 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100442 ],
443}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000444
445// Used when compiling higher-level code against art.module.public.api.stubs.
446// This abstraction should come from the inner tree linking against the stubs
447// and not from an "sdk", since parts of this abstraction do not belong to an
448// official API (e.g. stub-annotations).
449//
450// This is only intended for use within core libraries and must not be used
451// from outside.
452java_system_modules {
453 name: "art-module-public-api-stubs-system-modules",
454 visibility: [
455 "//art/build/sdk",
456 "//external/conscrypt",
457 "//external/icu/android_icu4j",
458 "//external/wycheproof",
459 ],
460 libs: [
461 "art.module.public.api.stubs",
462 // This one is not on device but it's needed when javac compiles code
463 // containing lambdas.
464 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000465
466 // Ensure that core libraries that depend on the public API can access
467 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
468 // annotations.
469 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000470 ],
471}
472
473// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
474//
475// This is only intended for use within core libraries and must not be used
476// from outside.
477java_system_modules {
478 name: "art-module-lib-api-stubs-system-modules",
479 visibility: [
480 "//art/build/sdk",
481 "//external/conscrypt",
482 "//external/icu/android_icu4j",
483 ],
484 libs: [
485 "art.module.public.api.stubs.module_lib",
486 ],
487}
488
489// Used when compiling against art.module.intra.core.api.stubs.
490java_system_modules {
491 name: "art-module-intra-core-api-stubs-system-modules",
492 visibility: [
493 "//art/build/sdk",
494 "//external/bouncycastle",
495 "//external/conscrypt",
496 "//external/icu/android_icu4j",
497 ],
498 libs: [
499 // The intra core API stubs library.
500 "art.module.intra.core.api.stubs",
501
502 // Additional classes needed by javac but which are not present in the stubs.
503 "art-module-intra-core-api-stubs-system-modules-lib",
504 ],
505}
Spandan Das4f771f12023-03-29 22:25:59 +0000506
507build = [
508 "TxtStubLibraries.bp",
509]