blob: eadd9c697ef9272261e79f8cc95aa9ddb889a582 [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 Kang67b64432023-05-31 22:25:21 +000058java_library {
59 name: "core.current.stubs",
60 defaults: [
61 "core.current.stubs.defaults",
62 ],
63 static_libs: [
64 "core.current.stubs.from-source",
65 ],
66 product_variables: {
67 build_from_text_stub: {
68 static_libs: [
69 "core.current.stubs.from-text",
70 ],
71 exclude_static_libs: [
72 "core.current.stubs.from-source",
73 ],
74 },
Paul Duffinbb360c32021-07-10 23:31:50 +010075 },
76}
77
78// Distributed with the SDK for turning into system modules to compile apps
79// against.
Paul Duffinbce9f082021-10-28 12:34:41 +010080//
81// Also, produces dist files that are used by the
82// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
83// directory.
Paul Duffinbb360c32021-07-10 23:31:50 +010084java_library {
85 name: "core-current-stubs-for-system-modules",
86 visibility: ["//development/sdk"],
87 static_libs: [
88 "core.current.stubs",
89 // This one is not on device but it's needed when javac compiles code
90 // containing lambdas.
91 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +010092 ],
93 sdk_version: "none",
94 system_modules: "none",
Paul Duffinbce9f082021-10-28 12:34:41 +010095 dists: [
96 {
97 // Legacy dist location for the public file.
98 dest: "core-for-system-modules.jar",
99 targets: dist_targets,
100 },
101 {
102 dest: "system-modules/public/core-for-system-modules.jar",
103 targets: dist_targets,
104 },
105 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100106}
107
Spandan Dasb0f3d422023-03-29 20:59:47 +0000108// Defaults module to strip out android annotations
109java_defaults {
110 name: "system-modules-no-annotations",
111 sdk_version: "none",
112 system_modules: "none",
113 jarjar_rules: "jarjar-strip-annotations-rules.txt",
114}
115
Sorin Bascabdbae602022-07-26 15:24:15 +0100116// Same as core-current-stubs-for-system-modules, but android annotations are
117// stripped.
118java_library {
119 name: "core-current-stubs-for-system-modules-no-annotations",
120 visibility: ["//development/sdk"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000121 defaults: [
122 "system-modules-no-annotations",
123 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100124 static_libs: [
125 "core-current-stubs-for-system-modules",
126 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100127 dists: [
128 {
129 // Legacy dist location for the public file.
130 dest: "core-for-system-modules-no-annotations.jar",
131 targets: dist_targets,
132 },
133 {
134 dest: "system-modules/public/core-for-system-modules-no-annotations.jar",
135 targets: dist_targets,
136 },
137 ],
Sorin Bascabdbae602022-07-26 15:24:15 +0100138}
139
Paul Duffinbb360c32021-07-10 23:31:50 +0100140// Used when compiling higher-level code against core.current.stubs.
141java_system_modules {
Paul Duffin10fb76f2021-11-03 16:53:31 +0000142 name: "core-public-stubs-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100143 visibility: ["//visibility:public"],
144 libs: [
Sorin Bascabdbae602022-07-26 15:24:15 +0100145 "core-current-stubs-for-system-modules-no-annotations",
Paul Duffinbb360c32021-07-10 23:31:50 +0100146 ],
147}
148
149// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
150// provided by the core libraries.
151//
152// Don't use this directly, use "sdk_version: module_current".
153java_library {
154 name: "core.module_lib.stubs",
155 static_libs: [
156 "art.module.public.api.stubs.module_lib",
157
158 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
159 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
160 // @SystemApi(MODULE_LIBRARIES).
161 "conscrypt.module.public.api.stubs",
162 "i18n.module.public.api.stubs",
163 ],
164 sdk_version: "none",
165 system_modules: "none",
166 visibility: ["//visibility:private"],
167}
168
Paul Duffinbce9f082021-10-28 12:34:41 +0100169// Produces a dist file that is used by the
170// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
171// directory.
172java_library {
173 name: "core-module-lib-stubs-for-system-modules",
174 visibility: ["//visibility:private"],
175 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100176 "core.module_lib.stubs",
177 // This one is not on device but it's needed when javac compiles code
178 // containing lambdas.
179 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100180 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100181 sdk_version: "none",
182 system_modules: "none",
183 dist: {
184 dest: "system-modules/module-lib/core-for-system-modules.jar",
185 targets: dist_targets,
186 },
187}
188
Sorin Basca69f4b082022-05-09 13:55:11 +0100189// Same as core-module-lib-stubs-for-system-modules, but android annotations are
190// stripped. This is used by the Java toolchain, while the annotated stub is to
191// be used by Kotlin one.
192java_library {
193 name: "core-module-lib-stubs-for-system-modules-no-annotations",
194 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000195 defaults: [
196 "system-modules-no-annotations",
197 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100198 static_libs: [
199 "core-module-lib-stubs-for-system-modules",
200 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100201 dist: {
202 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
203 targets: dist_targets,
204 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100205}
206
Paul Duffinbce9f082021-10-28 12:34:41 +0100207// Used when compiling higher-level code with sdk_version "module_current"
208java_system_modules {
209 name: "core-module-lib-stubs-system-modules",
210 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100211 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100212 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100213 visibility: ["//visibility:public"],
214}
215
216// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
217// this.
218// TODO(http://b/134561230) - limit the number of dependents on this.
219core_platform_visibility = ["//visibility:public"]
220
221// Libraries containing the core platform API stubs for the core libraries.
222//
223// Although this stubs library is primarily used by the Java compiler / build to indicate
224// the core platform API surface area, compile_dex: true is used so that the Core Platform
225// API annotations are available to the dex tools that enable enforcement of runtime
226// accessibility. b/119068555
227java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000228 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100229 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000230 defaults: [
231 "core.platform.api.stubs.defaults",
232 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100233 static_libs: [
234 "art.module.public.api.stubs.module_lib",
235 "conscrypt.module.platform.api.stubs",
236 "legacy.i18n.module.platform.api.stubs",
237 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000238}
239
240java_library {
241 name: "legacy.core.platform.api.stubs",
242 visibility: core_platform_visibility,
243 defaults: [
244 "core.platform.api.stubs.defaults",
245 ],
246 static_libs: [
247 "legacy.core.platform.api.stubs.from-source",
248 ],
249 product_variables: {
250 build_from_text_stub: {
251 static_libs: [
252 "stable.core.platform.api.stubs.from-text",
253 ],
254 exclude_static_libs: [
255 "stable.core.platform.api.stubs.from-source",
256 ],
257 },
258 },
259}
260
261java_defaults {
262 name: "core.platform.api.stubs.defaults",
263 hostdex: true,
264 compile_dex: true,
265
266 sdk_version: "none",
267 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100268 patch_module: "java.base",
269}
270
Sorin Basca69f4b082022-05-09 13:55:11 +0100271// Same as legacy.core.platform.api.stubs, but android annotations are
272// stripped. This is used by the Java toolchain, while the annotated stub is to
273// be used by Kotlin one.
274java_library {
275 name: "legacy.core.platform.api.no.annotations.stubs",
276 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000277 defaults: [
278 "system-modules-no-annotations",
279 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100280 hostdex: true,
281 compile_dex: true,
282
Sorin Basca69f4b082022-05-09 13:55:11 +0100283 static_libs: [
284 "legacy.core.platform.api.stubs",
285 ],
286 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100287}
288
Paul Duffinbb360c32021-07-10 23:31:50 +0100289java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000290 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100291 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000292 defaults: [
293 "core.platform.api.stubs.defaults",
294 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100295 static_libs: [
296 "art.module.public.api.stubs.module_lib",
297 // conscrypt only has a stable version, so it is okay to depend on it here:
298 "conscrypt.module.platform.api.stubs",
299 "stable.i18n.module.platform.api.stubs",
300 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000301}
302
303java_library {
304 name: "stable.core.platform.api.stubs",
305 visibility: core_platform_visibility,
306 defaults: [
307 "core.platform.api.stubs.defaults",
308 ],
309 static_libs: [
310 "stable.core.platform.api.stubs.from-source",
311 ],
312 product_variables: {
313 build_from_text_stub: {
314 static_libs: [
315 "stable.core.platform.api.stubs.from-text",
316 ],
317 exclude_static_libs: [
318 "stable.core.platform.api.stubs.from-source",
319 ],
320 },
321 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100322}
323
Sorin Basca69f4b082022-05-09 13:55:11 +0100324// Same as stable.core.platform.api.stubs, but android annotations are
325// stripped. This is used by the Java toolchain, while the annotated stub is to
326// be used by Kotlin one.
327java_library {
328 name: "stable.core.platform.api.no.annotations.stubs",
329 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000330 defaults: [
331 "system-modules-no-annotations",
332 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100333 hostdex: true,
334 compile_dex: true,
335
Sorin Basca69f4b082022-05-09 13:55:11 +0100336 static_libs: [
337 "stable.core.platform.api.stubs",
338 ],
339 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100340}
341
Paul Duffinbb360c32021-07-10 23:31:50 +0100342// Used when compiling higher-level code against *.core.platform.api.stubs.
343java_system_modules {
344 name: "legacy-core-platform-api-stubs-system-modules",
345 visibility: core_platform_visibility,
346 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100347 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100348 // This one is not on device but it's needed when javac compiles code
349 // containing lambdas.
350 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100351 ],
352}
353
354java_system_modules {
355 name: "stable-core-platform-api-stubs-system-modules",
356 visibility: core_platform_visibility,
357 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100358 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100359 // This one is not on device but it's needed when javac compiles code
360 // containing lambdas.
361 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100362 ],
363}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000364
365// Used when compiling higher-level code against art.module.public.api.stubs.
366// This abstraction should come from the inner tree linking against the stubs
367// and not from an "sdk", since parts of this abstraction do not belong to an
368// official API (e.g. stub-annotations).
369//
370// This is only intended for use within core libraries and must not be used
371// from outside.
372java_system_modules {
373 name: "art-module-public-api-stubs-system-modules",
374 visibility: [
375 "//art/build/sdk",
376 "//external/conscrypt",
377 "//external/icu/android_icu4j",
378 "//external/wycheproof",
379 ],
380 libs: [
381 "art.module.public.api.stubs",
382 // This one is not on device but it's needed when javac compiles code
383 // containing lambdas.
384 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000385
386 // Ensure that core libraries that depend on the public API can access
387 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
388 // annotations.
389 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000390 ],
391}
392
393// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
394//
395// This is only intended for use within core libraries and must not be used
396// from outside.
397java_system_modules {
398 name: "art-module-lib-api-stubs-system-modules",
399 visibility: [
400 "//art/build/sdk",
401 "//external/conscrypt",
402 "//external/icu/android_icu4j",
403 ],
404 libs: [
405 "art.module.public.api.stubs.module_lib",
406 ],
407}
408
409// Used when compiling against art.module.intra.core.api.stubs.
410java_system_modules {
411 name: "art-module-intra-core-api-stubs-system-modules",
412 visibility: [
413 "//art/build/sdk",
414 "//external/bouncycastle",
415 "//external/conscrypt",
416 "//external/icu/android_icu4j",
417 ],
418 libs: [
419 // The intra core API stubs library.
420 "art.module.intra.core.api.stubs",
421
422 // Additional classes needed by javac but which are not present in the stubs.
423 "art-module-intra-core-api-stubs-system-modules-lib",
424 ],
425}
Spandan Das4f771f12023-03-29 22:25:59 +0000426
427build = [
428 "TxtStubLibraries.bp",
429]