Android.bp 13 KB

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