diff options
| -rw-r--r-- | android/module.go | 2 | ||||
| -rw-r--r-- | apex/apex.go | 10 | ||||
| -rw-r--r-- | java/base.go | 29 | ||||
| -rw-r--r-- | java/java.go | 2 |
4 files changed, 24 insertions, 19 deletions
diff --git a/android/module.go b/android/module.go index e4967d81c..d703c1927 100644 --- a/android/module.go +++ b/android/module.go @@ -1869,6 +1869,7 @@ type CommonModuleInfo struct { // The Target of artifacts that this module variant is responsible for creating. CompileTarget Target SkipAndroidMkProcessing bool + BaseModuleName string } var CommonModuleInfoKey = blueprint.NewProvider[CommonModuleInfo]() @@ -2137,6 +2138,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt, CompileTarget: m.commonProperties.CompileTarget, SkipAndroidMkProcessing: shouldSkipAndroidMkProcessing(ctx, m), + BaseModuleName: m.BaseModuleName(), } if m.commonProperties.ForcedDisabled { commonData.Enabled = false diff --git a/apex/apex.go b/apex/apex.go index 72a045525..1a598e507 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -2647,16 +2647,12 @@ func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) { func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) { // Visit direct deps only. As long as we guarantee top-level deps are using stable SDKs, // java's checkLinkType guarantees correct usage for transitive deps - ctx.VisitDirectDeps(func(module android.Module) { + ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { tag := ctx.OtherModuleDependencyTag(module) switch tag { case javaLibTag, androidAppTag: - if m, ok := module.(interface { - CheckStableSdkVersion(ctx android.BaseModuleContext) error - }); ok { - if err := m.CheckStableSdkVersion(ctx); err != nil { - ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err) - } + if err := java.CheckStableSdkVersion(ctx, module); err != nil { + ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err) } } }) diff --git a/java/base.go b/java/base.go index 3bf2e23d8..c0ac4ab99 100644 --- a/java/base.go +++ b/java/base.go @@ -612,21 +612,24 @@ func (j *Module) IsStubsModule() bool { return proptools.Bool(j.properties.Is_stubs_module) } -func (j *Module) CheckStableSdkVersion(ctx android.BaseModuleContext) error { - sdkVersion := j.SdkVersion(ctx) - if sdkVersion.Stable() { - return nil - } - if sdkVersion.Kind == android.SdkCorePlatform { - if useLegacyCorePlatformApi(ctx, j.BaseModuleName()) { - return fmt.Errorf("non stable SDK %v - uses legacy core platform", sdkVersion) - } else { - // Treat stable core platform as stable. +func CheckStableSdkVersion(ctx android.BaseModuleContext, module android.ModuleProxy) error { + if info, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok { + if info.SdkVersion.Stable() { return nil } - } else { - return fmt.Errorf("non stable SDK %v", sdkVersion) + if info.SdkVersion.Kind == android.SdkCorePlatform { + if useLegacyCorePlatformApi(ctx, android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).BaseModuleName) { + return fmt.Errorf("non stable SDK %v - uses legacy core platform", info.SdkVersion) + } else { + // Treat stable core platform as stable. + return nil + } + } else { + return fmt.Errorf("non stable SDK %v", info.SdkVersion) + } } + + return nil } // checkSdkVersions enforces restrictions around SDK dependencies. @@ -1300,6 +1303,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath ExportedPluginDisableTurbine: j.exportedDisableTurbine, StubsLinkType: j.stubsLinkType, AconfigIntermediateCacheOutputPaths: deps.aconfigProtoFiles, + SdkVersion: j.SdkVersion(ctx), }) j.outputFile = j.headerJarFile @@ -1929,6 +1933,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath JacocoReportClassesFile: j.jacocoReportClassesFile, StubsLinkType: j.stubsLinkType, AconfigIntermediateCacheOutputPaths: j.aconfigCacheFiles, + SdkVersion: j.SdkVersion(ctx), }) // Save the output file with no relative path so that it doesn't end up in a subdirectory when used as a resource diff --git a/java/java.go b/java/java.go index 260d33610..ee112c1da 100644 --- a/java/java.go +++ b/java/java.go @@ -326,6 +326,8 @@ type JavaInfo struct { // AconfigIntermediateCacheOutputPaths is a path to the cache files collected from the // java_aconfig_library modules that are statically linked to this module. AconfigIntermediateCacheOutputPaths android.Paths + + SdkVersion android.SdkSpec } var JavaInfoProvider = blueprint.NewProvider[*JavaInfo]() |