Generate merged public and system stubs

Eliminate another two enumerations of all modules.

Bug: 169103987
Test: m android_{,system_}stubs_current && diff intermediates (no diffs)
Merged-In: I0d35f1e76320356ee4e5535a40614cf7d8ff4486
Change-Id: I0d35f1e76320356ee4e5535a40614cf7d8ff4486
This commit is contained in:
Anton Hansson 2022-01-25 15:53:43 +00:00
parent a1a71aaae4
commit c6e9d2ffe2
2 changed files with 34 additions and 49 deletions

View File

@ -207,48 +207,6 @@ droidstubs {
// from stub sources
/////////////////////////////////////////////////////////////////////
modules_public_stubs = [
"android.net.ipsec.ike.stubs",
"art.module.public.api.stubs",
"conscrypt.module.public.api.stubs",
"framework-appsearch.stubs",
"framework-bluetooth.stubs",
"framework-connectivity.stubs",
"framework-connectivity-tiramisu.stubs",
"framework-graphics.stubs",
"framework-media.stubs",
"framework-mediaprovider.stubs",
"framework-permission.stubs",
"framework-permission-s.stubs",
"framework-scheduling.stubs",
"framework-sdkextensions.stubs",
"framework-statsd.stubs",
"framework-tethering.stubs",
"framework-wifi.stubs",
"i18n.module.public.api.stubs",
]
modules_system_stubs = [
"android.net.ipsec.ike.stubs.system",
"art.module.public.api.stubs.system",
"conscrypt.module.public.api.stubs", // Only has public stubs
"framework-appsearch.stubs.system",
"framework-bluetooth.stubs.system",
"framework-connectivity.stubs.system",
"framework-connectivity-tiramisu.stubs.system",
"framework-graphics.stubs.system",
"framework-media.stubs.system",
"framework-mediaprovider.stubs.system",
"framework-permission.stubs.system",
"framework-permission-s.stubs.system",
"framework-scheduling.stubs.system",
"framework-sdkextensions.stubs.system",
"framework-statsd.stubs.system",
"framework-tethering.stubs.system",
"framework-wifi.stubs.system",
"i18n.module.public.api.stubs", // Only has public stubs
]
java_defaults {
name: "android-non-updatable_defaults_stubs_current",
libs: ["stub-annotations"],
@ -270,7 +228,7 @@ java_library {
name: "android-non-updatable.stubs",
defaults: ["android-non-updatable_defaults_stubs_current"],
srcs: [":api-stubs-docs-non-updatable"],
libs: modules_public_stubs,
libs: ["all-modules-public-stubs"],
dist: {
dir: "apistubs/android/public",
},
@ -280,7 +238,7 @@ java_library {
name: "android-non-updatable.stubs.system",
defaults: ["android-non-updatable_defaults_stubs_current"],
srcs: [":system-api-stubs-docs-non-updatable"],
libs: modules_system_stubs,
libs: ["all-modules-system-stubs"],
dist: {
dir: "apistubs/android/system",
},
@ -307,7 +265,7 @@ java_library {
name: "android-non-updatable.stubs.test",
defaults: ["android-non-updatable_defaults_stubs_current"],
srcs: [":test-api-stubs-docs-non-updatable"],
libs: modules_system_stubs,
libs: ["all-modules-system-stubs"],
dist: {
dir: "apistubs/android/test",
},
@ -325,7 +283,8 @@ java_defaults {
java_library {
name: "android_stubs_current",
static_libs: modules_public_stubs + [
static_libs: [
"all-modules-public-stubs",
"android-non-updatable.stubs",
"private-stub-annotations-jar",
],
@ -334,7 +293,8 @@ java_library {
java_library {
name: "android_system_stubs_current",
static_libs: modules_system_stubs + [
static_libs: [
"all-modules-system-stubs",
"android-non-updatable.stubs.system",
"private-stub-annotations-jar",
],
@ -359,7 +319,8 @@ java_library {
name: "android_test_stubs_current",
// Modules do not have test APIs, but we want to include their SystemApis, like we include
// the SystemApi of framework-non-updatable-sources.
static_libs: modules_system_stubs + [
static_libs: [
"all-modules-system-stubs",
"android-non-updatable.stubs.test",
"private-stub-annotations-jar",
],

View File

@ -27,6 +27,7 @@ import (
const art = "art.module.public.api"
const conscrypt = "conscrypt.module.public.api"
const i18n = "i18n.module.public.api"
var modules_with_only_public_scope = []string{i18n, conscrypt}
// The intention behind this soong plugin is to generate a number of "merged"
// API-related modules that would otherwise require a large amount of very
@ -183,6 +184,27 @@ func createFilteredApiVersions(ctx android.LoadHookContext, modules []string) {
ctx.CreateModule(genrule.GenRuleFactory, &props)
}
func createMergedPublicStubs(ctx android.LoadHookContext, modules []string) {
props := libraryProps{}
props.Name = proptools.StringPtr("all-modules-public-stubs")
props.Static_libs = transformArray(modules, "", ".stubs")
props.Sdk_version = proptools.StringPtr("module_current")
props.Visibility = []string{"//frameworks/base"}
ctx.CreateModule(java.LibraryFactory, &props)
}
func createMergedSystemStubs(ctx android.LoadHookContext, modules []string) {
props := libraryProps{}
modules_with_system_stubs := removeAll(modules, modules_with_only_public_scope)
props.Name = proptools.StringPtr("all-modules-system-stubs")
props.Static_libs = append(
transformArray(modules_with_only_public_scope, "", ".stubs"),
transformArray(modules_with_system_stubs, "", ".stubs.system")...)
props.Sdk_version = proptools.StringPtr("module_current")
props.Visibility = []string{"//frameworks/base"}
ctx.CreateModule(java.LibraryFactory, &props)
}
func createMergedModuleLibStubs(ctx android.LoadHookContext, modules []string) {
// The user of this module compiles against the "core" SDK, so remove core libraries to avoid dupes.
modules = removeAll(modules, []string{art, conscrypt, i18n})
@ -205,7 +227,7 @@ func createPublicStubsSourceFilegroup(ctx android.LoadHookContext, modules []str
func createMergedTxts(ctx android.LoadHookContext, bootclasspath, system_server_classpath []string) {
var textFiles []MergedTxtDefinition
// Two module libraries currently do not support @SystemApi so only have the public scope.
bcpWithSystemApi := removeAll(bootclasspath, []string{conscrypt, i18n})
bcpWithSystemApi := removeAll(bootclasspath, modules_with_only_public_scope)
tagSuffix := []string{".api.txt}", ".removed-api.txt}"}
for i, f := range []string{"current.txt", "removed.txt"} {
@ -253,6 +275,8 @@ func (a *CombinedApis) createInternalModules(ctx android.LoadHookContext) {
createMergedStubsSrcjar(ctx, bootclasspath)
createMergedPublicStubs(ctx, bootclasspath)
createMergedSystemStubs(ctx, bootclasspath)
createMergedModuleLibStubs(ctx, bootclasspath)
createMergedAnnotations(ctx, bootclasspath)