1// 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". 27package { 28 default_applicable_licenses: ["Android-Apache-2.0"], 29} 30 31dist_targets = [ 32 "sdk", 33 "win_sdk", 34] 35 36java_library { 37 name: "core.current.stubs", 38 visibility: ["//visibility:public"], 39 static_libs: [ 40 "art.module.public.api.stubs", 41 "conscrypt.module.public.api.stubs", 42 "i18n.module.public.api.stubs", 43 ], 44 sdk_version: "none", 45 system_modules: "none", 46 47 dist: { 48 targets: dist_targets, 49 }, 50} 51 52// Distributed with the SDK for turning into system modules to compile apps 53// against. 54// 55// Also, produces dist files that are used by the 56// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk 57// directory. 58java_library { 59 name: "core-current-stubs-for-system-modules", 60 visibility: ["//development/sdk"], 61 static_libs: [ 62 "core.current.stubs", 63 // This one is not on device but it's needed when javac compiles code 64 // containing lambdas. 65 "core-lambda-stubs-for-system-modules", 66 ], 67 sdk_version: "none", 68 system_modules: "none", 69 dists: [ 70 { 71 // Legacy dist location for the public file. 72 dest: "core-for-system-modules.jar", 73 targets: dist_targets, 74 }, 75 { 76 dest: "system-modules/public/core-for-system-modules.jar", 77 targets: dist_targets, 78 }, 79 ], 80} 81 82// Defaults module to strip out android annotations 83java_defaults { 84 name: "system-modules-no-annotations", 85 sdk_version: "none", 86 system_modules: "none", 87 jarjar_rules: "jarjar-strip-annotations-rules.txt", 88} 89 90// Same as core-current-stubs-for-system-modules, but android annotations are 91// stripped. 92java_library { 93 name: "core-current-stubs-for-system-modules-no-annotations", 94 visibility: ["//development/sdk"], 95 defaults: [ 96 "system-modules-no-annotations", 97 ], 98 static_libs: [ 99 "core-current-stubs-for-system-modules", 100 ], 101 dists: [ 102 { 103 // Legacy dist location for the public file. 104 dest: "core-for-system-modules-no-annotations.jar", 105 targets: dist_targets, 106 }, 107 { 108 dest: "system-modules/public/core-for-system-modules-no-annotations.jar", 109 targets: dist_targets, 110 }, 111 ], 112} 113 114// Used when compiling higher-level code against core.current.stubs. 115java_system_modules { 116 name: "core-public-stubs-system-modules", 117 visibility: ["//visibility:public"], 118 libs: [ 119 "core-current-stubs-for-system-modules-no-annotations", 120 ], 121} 122 123// A stubs target containing the parts of the public SDK & @SystemApi(MODULE_LIBRARIES) API 124// provided by the core libraries. 125// 126// Don't use this directly, use "sdk_version: module_current". 127java_library { 128 name: "core.module_lib.stubs", 129 static_libs: [ 130 "art.module.public.api.stubs.module_lib", 131 132 // Replace the following with the module-lib correspondence when Conscrypt or i18N module 133 // provides @SystemApi(MODULE_LIBRARIES). Currently, assume that only ART module provides 134 // @SystemApi(MODULE_LIBRARIES). 135 "conscrypt.module.public.api.stubs", 136 "i18n.module.public.api.stubs", 137 ], 138 sdk_version: "none", 139 system_modules: "none", 140 visibility: ["//visibility:private"], 141} 142 143// Produces a dist file that is used by the 144// prebuilts/sdk/update_prebuilts.py script to update the prebuilts/sdk 145// directory. 146java_library { 147 name: "core-module-lib-stubs-for-system-modules", 148 visibility: ["//visibility:private"], 149 static_libs: [ 150 "core.module_lib.stubs", 151 // This one is not on device but it's needed when javac compiles code 152 // containing lambdas. 153 "core-lambda-stubs-for-system-modules", 154 ], 155 sdk_version: "none", 156 system_modules: "none", 157 dist: { 158 dest: "system-modules/module-lib/core-for-system-modules.jar", 159 targets: dist_targets, 160 }, 161} 162 163// Same as core-module-lib-stubs-for-system-modules, but android annotations are 164// stripped. This is used by the Java toolchain, while the annotated stub is to 165// be used by Kotlin one. 166java_library { 167 name: "core-module-lib-stubs-for-system-modules-no-annotations", 168 visibility: ["//visibility:private"], 169 defaults: [ 170 "system-modules-no-annotations", 171 ], 172 static_libs: [ 173 "core-module-lib-stubs-for-system-modules", 174 ], 175 dist: { 176 dest: "system-modules/module-lib/core-for-system-modules-no-annotations.jar", 177 targets: dist_targets, 178 }, 179} 180 181// Used when compiling higher-level code with sdk_version "module_current" 182java_system_modules { 183 name: "core-module-lib-stubs-system-modules", 184 libs: [ 185 "core-module-lib-stubs-for-system-modules-no-annotations", 186 ], 187 visibility: ["//visibility:public"], 188} 189 190// Ideally this should be a restricted allowlist but there are hundreds of modules that depend on 191// this. 192// TODO(http://b/134561230) - limit the number of dependents on this. 193core_platform_visibility = ["//visibility:public"] 194 195// Libraries containing the core platform API stubs for the core libraries. 196// 197// Although this stubs library is primarily used by the Java compiler / build to indicate 198// the core platform API surface area, compile_dex: true is used so that the Core Platform 199// API annotations are available to the dex tools that enable enforcement of runtime 200// accessibility. b/119068555 201java_library { 202 name: "legacy.core.platform.api.stubs", 203 visibility: core_platform_visibility, 204 hostdex: true, 205 compile_dex: true, 206 207 sdk_version: "none", 208 system_modules: "none", 209 static_libs: [ 210 "art.module.public.api.stubs.module_lib", 211 "conscrypt.module.platform.api.stubs", 212 "legacy.i18n.module.platform.api.stubs", 213 ], 214 patch_module: "java.base", 215} 216 217// Same as legacy.core.platform.api.stubs, 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: "legacy.core.platform.api.no.annotations.stubs", 222 visibility: core_platform_visibility, 223 defaults: [ 224 "system-modules-no-annotations", 225 ], 226 hostdex: true, 227 compile_dex: true, 228 229 static_libs: [ 230 "legacy.core.platform.api.stubs", 231 ], 232 patch_module: "java.base", 233} 234 235java_library { 236 name: "stable.core.platform.api.stubs", 237 visibility: core_platform_visibility, 238 hostdex: true, 239 compile_dex: true, 240 241 sdk_version: "none", 242 system_modules: "none", 243 static_libs: [ 244 "art.module.public.api.stubs.module_lib", 245 // conscrypt only has a stable version, so it is okay to depend on it here: 246 "conscrypt.module.platform.api.stubs", 247 "stable.i18n.module.platform.api.stubs", 248 ], 249 patch_module: "java.base", 250} 251 252// Same as stable.core.platform.api.stubs, but android annotations are 253// stripped. This is used by the Java toolchain, while the annotated stub is to 254// be used by Kotlin one. 255java_library { 256 name: "stable.core.platform.api.no.annotations.stubs", 257 visibility: core_platform_visibility, 258 defaults: [ 259 "system-modules-no-annotations", 260 ], 261 hostdex: true, 262 compile_dex: true, 263 264 static_libs: [ 265 "stable.core.platform.api.stubs", 266 ], 267 patch_module: "java.base", 268} 269 270// Used when compiling higher-level code against *.core.platform.api.stubs. 271java_system_modules { 272 name: "legacy-core-platform-api-stubs-system-modules", 273 visibility: core_platform_visibility, 274 libs: [ 275 "legacy.core.platform.api.no.annotations.stubs", 276 // This one is not on device but it's needed when javac compiles code 277 // containing lambdas. 278 "core-lambda-stubs-for-system-modules", 279 ], 280} 281 282java_system_modules { 283 name: "stable-core-platform-api-stubs-system-modules", 284 visibility: core_platform_visibility, 285 libs: [ 286 "stable.core.platform.api.no.annotations.stubs", 287 // This one is not on device but it's needed when javac compiles code 288 // containing lambdas. 289 "core-lambda-stubs-for-system-modules", 290 ], 291} 292 293// Used when compiling higher-level code against art.module.public.api.stubs. 294// This abstraction should come from the inner tree linking against the stubs 295// and not from an "sdk", since parts of this abstraction do not belong to an 296// official API (e.g. stub-annotations). 297// 298// This is only intended for use within core libraries and must not be used 299// from outside. 300java_system_modules { 301 name: "art-module-public-api-stubs-system-modules", 302 visibility: [ 303 "//art/build/sdk", 304 "//external/conscrypt", 305 "//external/icu/android_icu4j", 306 "//external/wycheproof", 307 ], 308 libs: [ 309 "art.module.public.api.stubs", 310 // This one is not on device but it's needed when javac compiles code 311 // containing lambdas. 312 "core-lambda-stubs-for-system-modules", 313 314 // Ensure that core libraries that depend on the public API can access 315 // the UnsupportedAppUsage, CorePlatformApi and IntraCoreApi 316 // annotations. 317 "art.module.api.annotations.for.system.modules", 318 ], 319} 320 321// Used when compiling higher-level code against art.module.public.api.stubs.module_lib. 322// 323// This is only intended for use within core libraries and must not be used 324// from outside. 325java_system_modules { 326 name: "art-module-lib-api-stubs-system-modules", 327 visibility: [ 328 "//art/build/sdk", 329 "//external/conscrypt", 330 "//external/icu/android_icu4j", 331 ], 332 libs: [ 333 "art.module.public.api.stubs.module_lib", 334 ], 335} 336 337// Used when compiling against art.module.intra.core.api.stubs. 338java_system_modules { 339 name: "art-module-intra-core-api-stubs-system-modules", 340 visibility: [ 341 "//art/build/sdk", 342 "//external/bouncycastle", 343 "//external/conscrypt", 344 "//external/icu/android_icu4j", 345 ], 346 libs: [ 347 // The intra core API stubs library. 348 "art.module.intra.core.api.stubs", 349 350 // Additional classes needed by javac but which are not present in the stubs. 351 "art-module-intra-core-api-stubs-system-modules-lib", 352 ], 353} 354 355build = [ 356 "TxtStubLibraries.bp", 357] 358