Remove suffix based stub matching logic
This change prevents non-stub modules with stub suffix from being
determined as the stub module, and instead makes the check more robust
by determining the condition based on the user-hidden
`Stub_contributing_api` property, which is only set for the stub
submodules generated by `java_sdk_library`.
Test: m nothing --no-skip-soong-tests
Bug: 361179822
Change-Id: I28a599c5b4fe1e8460e60580c0535aaf19e39ba3
diff --git a/java/base.go b/java/base.go
index 4ab82c5..9101457 100644
--- a/java/base.go
+++ b/java/base.go
@@ -229,6 +229,10 @@
Ravenizer struct {
Enabled *bool
}
+
+ // Contributing api surface of the stub module. Is not visible to bp modules, and should
+ // only be set for stub submodules generated by the java_sdk_library
+ Stub_contributing_api *string `blueprint:"mutated"`
}
// Properties that are specific to device modules. Host module factories should not add these when
@@ -1541,7 +1545,7 @@
// outputFile should be agnostic to the build configuration,
// thus "combine" the single static lib in order to prevent the static lib from being exposed
// to the copy rules.
- stub, _ := moduleStubLinkType(ctx.ModuleName())
+ stub, _ := moduleStubLinkType(j)
if stub {
combinedJar := android.PathForModuleOut(ctx, "combined", jarName)
@@ -2169,6 +2173,25 @@
getSdkLinkType(ctx android.BaseModuleContext, name string) (ret sdkLinkType, stubs bool)
}
+func sdkLinkTypeFromSdkKind(k android.SdkKind) sdkLinkType {
+ switch k {
+ case android.SdkCore:
+ return javaCore
+ case android.SdkSystem:
+ return javaSystem
+ case android.SdkPublic:
+ return javaSdk
+ case android.SdkModule:
+ return javaModule
+ case android.SdkSystemServer:
+ return javaSystemServer
+ case android.SdkPrivate, android.SdkNone, android.SdkCorePlatform, android.SdkTest:
+ return javaPlatform
+ default:
+ return javaSdk
+ }
+}
+
func (m *Module) getSdkLinkType(ctx android.BaseModuleContext, name string) (ret sdkLinkType, stubs bool) {
switch name {
case android.SdkCore.DefaultJavaLibraryName(),
@@ -2190,30 +2213,16 @@
return javaSystem, true
}
- if stub, linkType := moduleStubLinkType(name); stub {
+ if stub, linkType := moduleStubLinkType(m); stub {
return linkType, true
}
ver := m.SdkVersion(ctx)
- switch ver.Kind {
- case android.SdkCore:
- return javaCore, false
- case android.SdkSystem:
- return javaSystem, false
- case android.SdkPublic:
- return javaSdk, false
- case android.SdkModule:
- return javaModule, false
- case android.SdkSystemServer:
- return javaSystemServer, false
- case android.SdkPrivate, android.SdkNone, android.SdkCorePlatform, android.SdkTest:
- return javaPlatform, false
- }
-
if !ver.Valid() {
panic(fmt.Errorf("sdk_version is invalid. got %q", ver.Raw))
}
- return javaSdk, false
+
+ return sdkLinkTypeFromSdkKind(ver.Kind), false
}
// checkSdkLinkType make sures the given dependency doesn't have a lower SDK link type rank than