blob: de9a82d092cc93283b5bcbbbecefac48a5dd551b [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
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400149java_defaults {
150 name: "core.module_lib.stubs.defaults",
151 visibility: ["//visibility:private"],
152 sdk_version: "none",
153 system_modules: "none",
154}
155
156
Paul Duffinbb360c32021-07-10 23:31:50 +0100157// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API
158// provided by the core libraries.
159//
160// Don't use this directly, use "sdk_version: module_current".
161java_library {
162 name: "core.module_lib.stubs",
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400163 defaults: [
164 "core.module_lib.stubs.defaults",
165 ],
166 static_libs: [
167 "core.module_lib.stubs.from-source",
168 ],
169 product_variables: {
170 build_from_text_stub: {
171 static_libs: [
172 "core.module_lib.stubs.from-text",
173 ],
174 exclude_static_libs: [
175 "core.module_lib.stubs.from-source",
176 ],
177 },
178 },
179}
180
181java_library {
182 name: "core.module_lib.stubs.from-source",
183 defaults: [
184 "core.module_lib.stubs.defaults",
185 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100186 static_libs: [
187 "art.module.public.api.stubs.module_lib",
188
189 // Replace the following with the module-lib correspondence when Conscrypt or i18N module
190 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides
191 // @SystemApi(MODULE_LIBRARIES).
192 "conscrypt.module.public.api.stubs",
193 "i18n.module.public.api.stubs",
194 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100195}
196
Paul Duffinbce9f082021-10-28 12:34:41 +0100197// Produces a dist file that is used by the
198// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk
199// directory.
200java_library {
201 name: "core-module-lib-stubs-for-system-modules",
202 visibility: ["//visibility:private"],
203 static_libs: [
Paul Duffinbb360c32021-07-10 23:31:50 +0100204 "core.module_lib.stubs",
205 // This one is not on device but it's needed when javac compiles code
206 // containing lambdas.
207 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100208 ],
Paul Duffinbce9f082021-10-28 12:34:41 +0100209 sdk_version: "none",
210 system_modules: "none",
211 dist: {
212 dest: "system-modules/module-lib/core-for-system-modules.jar",
213 targets: dist_targets,
214 },
215}
216
Sorin Basca69f4b082022-05-09 13:55:11 +0100217// Same as core-module-lib-stubs-for-system-modules, but android annotations are
218// stripped. This is used by the Java toolchain, while the annotated stub is to
219// be used by Kotlin one.
220java_library {
221 name: "core-module-lib-stubs-for-system-modules-no-annotations",
222 visibility: ["//visibility:private"],
Spandan Dasb0f3d422023-03-29 20:59:47 +0000223 defaults: [
224 "system-modules-no-annotations",
225 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100226 static_libs: [
227 "core-module-lib-stubs-for-system-modules",
228 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100229 dist: {
230 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar",
231 targets: dist_targets,
232 },
Sorin Basca69f4b082022-05-09 13:55:11 +0100233}
234
Paul Duffinbce9f082021-10-28 12:34:41 +0100235// Used when compiling higher-level code with sdk_version "module_current"
236java_system_modules {
237 name: "core-module-lib-stubs-system-modules",
238 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100239 "core-module-lib-stubs-for-system-modules-no-annotations",
Paul Duffinbce9f082021-10-28 12:34:41 +0100240 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100241 visibility: ["//visibility:public"],
242}
243
244// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on
245// this.
246// TODO(http://b/134561230) - limit the number of dependents on this.
247core_platform_visibility = ["//visibility:public"]
248
249// Libraries containing the core platform API stubs for the core libraries.
250//
251// Although this stubs library is primarily used by the Java compiler / build to indicate
252// the core platform API surface area, compile_dex: true is used so that the Core Platform
253// API annotations are available to the dex tools that enable enforcement of runtime
254// accessibility. b/119068555
255java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000256 name: "legacy.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100257 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000258 defaults: [
259 "core.platform.api.stubs.defaults",
260 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100261 static_libs: [
262 "art.module.public.api.stubs.module_lib",
263 "conscrypt.module.platform.api.stubs",
264 "legacy.i18n.module.platform.api.stubs",
265 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000266}
267
268java_library {
269 name: "legacy.core.platform.api.stubs",
270 visibility: core_platform_visibility,
271 defaults: [
272 "core.platform.api.stubs.defaults",
273 ],
274 static_libs: [
275 "legacy.core.platform.api.stubs.from-source",
276 ],
277 product_variables: {
278 build_from_text_stub: {
279 static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400280 "legacy.core.platform.api.stubs.from-text",
Jihoon Kang67b64432023-05-31 22:25:21 +0000281 ],
282 exclude_static_libs: [
Romain Jobredeaux9d54fda2023-07-28 10:32:50 -0400283 "legacy.core.platform.api.stubs.from-source",
Jihoon Kang67b64432023-05-31 22:25:21 +0000284 ],
285 },
286 },
287}
288
289java_defaults {
290 name: "core.platform.api.stubs.defaults",
291 hostdex: true,
292 compile_dex: true,
293
294 sdk_version: "none",
295 system_modules: "none",
Paul Duffinbb360c32021-07-10 23:31:50 +0100296 patch_module: "java.base",
297}
298
Sorin Basca69f4b082022-05-09 13:55:11 +0100299// Same as legacy.core.platform.api.stubs, but android annotations are
300// stripped. This is used by the Java toolchain, while the annotated stub is to
301// be used by Kotlin one.
302java_library {
303 name: "legacy.core.platform.api.no.annotations.stubs",
304 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000305 defaults: [
306 "system-modules-no-annotations",
307 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100308 hostdex: true,
309 compile_dex: true,
310
Sorin Basca69f4b082022-05-09 13:55:11 +0100311 static_libs: [
312 "legacy.core.platform.api.stubs",
313 ],
314 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100315}
316
Paul Duffinbb360c32021-07-10 23:31:50 +0100317java_library {
Jihoon Kang67b64432023-05-31 22:25:21 +0000318 name: "stable.core.platform.api.stubs.from-source",
Paul Duffinbb360c32021-07-10 23:31:50 +0100319 visibility: core_platform_visibility,
Jihoon Kang67b64432023-05-31 22:25:21 +0000320 defaults: [
321 "core.platform.api.stubs.defaults",
322 ],
Paul Duffinbb360c32021-07-10 23:31:50 +0100323 static_libs: [
324 "art.module.public.api.stubs.module_lib",
325 // conscrypt only has a stable version, so it is okay to depend on it here:
326 "conscrypt.module.platform.api.stubs",
327 "stable.i18n.module.platform.api.stubs",
328 ],
Jihoon Kang67b64432023-05-31 22:25:21 +0000329}
330
331java_library {
332 name: "stable.core.platform.api.stubs",
333 visibility: core_platform_visibility,
334 defaults: [
335 "core.platform.api.stubs.defaults",
336 ],
337 static_libs: [
338 "stable.core.platform.api.stubs.from-source",
339 ],
340 product_variables: {
341 build_from_text_stub: {
342 static_libs: [
343 "stable.core.platform.api.stubs.from-text",
344 ],
345 exclude_static_libs: [
346 "stable.core.platform.api.stubs.from-source",
347 ],
348 },
349 },
Paul Duffinbb360c32021-07-10 23:31:50 +0100350}
351
Sorin Basca69f4b082022-05-09 13:55:11 +0100352// Same as stable.core.platform.api.stubs, but android annotations are
353// stripped. This is used by the Java toolchain, while the annotated stub is to
354// be used by Kotlin one.
355java_library {
356 name: "stable.core.platform.api.no.annotations.stubs",
357 visibility: core_platform_visibility,
Spandan Dasb0f3d422023-03-29 20:59:47 +0000358 defaults: [
359 "system-modules-no-annotations",
360 ],
Sorin Basca69f4b082022-05-09 13:55:11 +0100361 hostdex: true,
362 compile_dex: true,
363
Sorin Basca69f4b082022-05-09 13:55:11 +0100364 static_libs: [
365 "stable.core.platform.api.stubs",
366 ],
367 patch_module: "java.base",
Sorin Basca69f4b082022-05-09 13:55:11 +0100368}
369
Paul Duffinbb360c32021-07-10 23:31:50 +0100370// Used when compiling higher-level code against *.core.platform.api.stubs.
371java_system_modules {
372 name: "legacy-core-platform-api-stubs-system-modules",
373 visibility: core_platform_visibility,
374 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100375 "legacy.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100376 // This one is not on device but it's needed when javac compiles code
377 // containing lambdas.
378 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100379 ],
380}
381
382java_system_modules {
383 name: "stable-core-platform-api-stubs-system-modules",
384 visibility: core_platform_visibility,
385 libs: [
Sorin Basca69f4b082022-05-09 13:55:11 +0100386 "stable.core.platform.api.no.annotations.stubs",
Paul Duffinbb360c32021-07-10 23:31:50 +0100387 // This one is not on device but it's needed when javac compiles code
388 // containing lambdas.
389 "core-lambda-stubs-for-system-modules",
Paul Duffinbb360c32021-07-10 23:31:50 +0100390 ],
391}
Spandan Dasfe85ca22022-12-08 02:42:25 +0000392
393// Used when compiling higher-level code against art.module.public.api.stubs.
394// This abstraction should come from the inner tree linking against the stubs
395// and not from an "sdk", since parts of this abstraction do not belong to an
396// official API (e.g. stub-annotations).
397//
398// This is only intended for use within core libraries and must not be used
399// from outside.
400java_system_modules {
401 name: "art-module-public-api-stubs-system-modules",
402 visibility: [
403 "//art/build/sdk",
404 "//external/conscrypt",
405 "//external/icu/android_icu4j",
406 "//external/wycheproof",
407 ],
408 libs: [
409 "art.module.public.api.stubs",
410 // This one is not on device but it's needed when javac compiles code
411 // containing lambdas.
412 "core-lambda-stubs-for-system-modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000413
414 // Ensure that core libraries that depend on the public API can access
415 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi
416 // annotations.
417 "art.module.api.annotations.for.system.modules",
Spandan Dasfe85ca22022-12-08 02:42:25 +0000418 ],
419}
420
421// Used when compiling higher-level code against art.module.public.api.stubs.module_lib.
422//
423// This is only intended for use within core libraries and must not be used
424// from outside.
425java_system_modules {
426 name: "art-module-lib-api-stubs-system-modules",
427 visibility: [
428 "//art/build/sdk",
429 "//external/conscrypt",
430 "//external/icu/android_icu4j",
431 ],
432 libs: [
433 "art.module.public.api.stubs.module_lib",
434 ],
435}
436
437// Used when compiling against art.module.intra.core.api.stubs.
438java_system_modules {
439 name: "art-module-intra-core-api-stubs-system-modules",
440 visibility: [
441 "//art/build/sdk",
442 "//external/bouncycastle",
443 "//external/conscrypt",
444 "//external/icu/android_icu4j",
445 ],
446 libs: [
447 // The intra core API stubs library.
448 "art.module.intra.core.api.stubs",
449
450 // Additional classes needed by javac but which are not present in the stubs.
451 "art-module-intra-core-api-stubs-system-modules-lib",
452 ],
453}
Spandan Das4f771f12023-03-29 22:25:59 +0000454
455build = [
456 "TxtStubLibraries.bp",
457]