Merge "Cleanup hardcoded references to android_*stubs_current" am: ef5b7e4e36 am: 91d512df2c

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2497416

Change-Id: I2d0c6eb6e4da29b7cc10193e19064ea119c124f7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Spandan Das
2023-03-21 18:51:23 +00:00
committed by Automerger Merge Worker
4 changed files with 50 additions and 20 deletions

View File

@@ -84,6 +84,40 @@ func (k SdkKind) String() string {
} }
} }
// JavaLibraryName returns the soong module containing the Java APIs of that API surface.
func (k SdkKind) JavaLibraryName(c Config) string {
name := k.defaultJavaLibraryName()
return JavaLibraryNameFromText(c, name)
}
// JavaLibraryNameFromText returns the name of .txt equivalent of a java_library, but does
// not check if either module exists.
// TODO: Return .txt (single-tree or multi-tree equivalents) based on config
func JavaLibraryNameFromText(c Config, name string) string {
// This returns the default for now.
// TODO: Implement this
return name
}
func (k SdkKind) defaultJavaLibraryName() string {
switch k {
case SdkPublic:
return "android_stubs_current"
case SdkSystem:
return "android_system_stubs_current"
case SdkTest:
return "android_test_stubs_current"
case SdkCore:
return "core.current.stubs"
case SdkModule:
return "android_module_lib_stubs_current"
case SdkSystemServer:
return "android_system_server_stubs_current"
default:
panic(fmt.Errorf("APIs of API surface %v cannot be provided by a single Soong module\n", k))
}
}
// SdkSpec represents the kind and the version of an SDK for a module to build against // SdkSpec represents the kind and the version of an SDK for a module to build against
type SdkSpec struct { type SdkSpec struct {
Kind SdkKind Kind SdkKind

View File

@@ -1924,15 +1924,15 @@ func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret
"stub-annotations", "private-stub-annotations-jar", "stub-annotations", "private-stub-annotations-jar",
"core-lambda-stubs", "core-generated-annotation-stubs": "core-lambda-stubs", "core-generated-annotation-stubs":
return javaCore, true return javaCore, true
case "android_stubs_current": case android.SdkPublic.JavaLibraryName(ctx.Config()):
return javaSdk, true return javaSdk, true
case "android_system_stubs_current": case android.SdkSystem.JavaLibraryName(ctx.Config()):
return javaSystem, true return javaSystem, true
case "android_module_lib_stubs_current": case android.SdkModule.JavaLibraryName(ctx.Config()):
return javaModule, true return javaModule, true
case "android_system_server_stubs_current": case android.SdkSystemServer.JavaLibraryName(ctx.Config()):
return javaSystemServer, true return javaSystemServer, true
case "android_test_stubs_current": case android.SdkTest.JavaLibraryName(ctx.Config()):
return javaSystem, true return javaSystem, true
} }

View File

@@ -236,9 +236,9 @@ func hiddenAPIComputeMonolithicStubLibModules(config android.Config) map[*Hidden
testStubModules = append(testStubModules, "sdk_test_current_android") testStubModules = append(testStubModules, "sdk_test_current_android")
} else { } else {
// Use stub modules built from source // Use stub modules built from source
publicStubModules = append(publicStubModules, "android_stubs_current") publicStubModules = append(publicStubModules, android.SdkPublic.JavaLibraryName(config))
systemStubModules = append(systemStubModules, "android_system_stubs_current") systemStubModules = append(systemStubModules, android.SdkSystem.JavaLibraryName(config))
testStubModules = append(testStubModules, "android_test_stubs_current") testStubModules = append(testStubModules, android.SdkTest.JavaLibraryName(config))
} }
// We do not have prebuilts of the core platform api yet // We do not have prebuilts of the core platform api yet
corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs") corePlatformStubModules = append(corePlatformStubModules, "legacy.core.platform.api.stubs")

View File

@@ -191,12 +191,8 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
bootclasspath: corePlatformBootclasspathLibraries(ctx), bootclasspath: corePlatformBootclasspathLibraries(ctx),
noFrameworksLibs: true, noFrameworksLibs: true,
} }
case android.SdkPublic: case android.SdkPublic, android.SdkSystem, android.SdkTest:
return toModule("android_stubs_current", sdkFrameworkAidlPath(ctx)) return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx))
case android.SdkSystem:
return toModule("android_system_stubs_current", sdkFrameworkAidlPath(ctx))
case android.SdkTest:
return toModule("android_test_stubs_current", sdkFrameworkAidlPath(ctx))
case android.SdkCore: case android.SdkCore:
return sdkDep{ return sdkDep{
useModule: true, useModule: true,
@@ -206,10 +202,10 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext android.SdkContext)
} }
case android.SdkModule: case android.SdkModule:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules // TODO(146757305): provide .apk and .aidl that have more APIs for modules
return toModule("android_module_lib_stubs_current", nonUpdatableFrameworkAidlPath(ctx)) return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), nonUpdatableFrameworkAidlPath(ctx))
case android.SdkSystemServer: case android.SdkSystemServer:
// TODO(146757305): provide .apk and .aidl that have more APIs for modules // TODO(146757305): provide .apk and .aidl that have more APIs for modules
return toModule("android_system_server_stubs_current", sdkFrameworkAidlPath(ctx)) return toModule(sdkVersion.Kind.JavaLibraryName(ctx.Config()), sdkFrameworkAidlPath(ctx))
default: default:
panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw)) panic(fmt.Errorf("invalid sdk %q", sdkVersion.Raw))
} }
@@ -272,9 +268,9 @@ func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
// Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules. // Create framework.aidl by extracting anything that implements android.os.Parcelable from the SDK stubs modules.
func createSdkFrameworkAidl(ctx android.SingletonContext) { func createSdkFrameworkAidl(ctx android.SingletonContext) {
stubsModules := []string{ stubsModules := []string{
"android_stubs_current", android.SdkPublic.JavaLibraryName(ctx.Config()),
"android_test_stubs_current", android.SdkTest.JavaLibraryName(ctx.Config()),
"android_system_stubs_current", android.SdkSystem.JavaLibraryName(ctx.Config()),
} }
combinedAidl := sdkFrameworkAidlPath(ctx) combinedAidl := sdkFrameworkAidlPath(ctx)
@@ -289,7 +285,7 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) {
// Creates a version of framework.aidl for the non-updatable part of the platform. // Creates a version of framework.aidl for the non-updatable part of the platform.
func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) { func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) {
stubsModules := []string{"android_module_lib_stubs_current"} stubsModules := []string{android.SdkModule.JavaLibraryName(ctx.Config())}
combinedAidl := nonUpdatableFrameworkAidlPath(ctx) combinedAidl := nonUpdatableFrameworkAidlPath(ctx)
tempPath := tempPathForRestat(ctx, combinedAidl) tempPath := tempPathForRestat(ctx, combinedAidl)