diff options
author | 2025-01-09 00:19:06 +0000 | |
---|---|---|
committer | 2025-01-09 00:19:06 +0000 | |
commit | fc8d5c13f7764f1094a37b2a99ffdf7c813387df (patch) | |
tree | 6cc5515d10212ce1b33fed4792692ea5d7343685 /java/app.go | |
parent | 68a70b701baca04f5a773b0df49c850cd59a8cfe (diff) |
Convert validatePartitionType and checkJniLibsSdkVersion to use
ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I74e6ebef7d7fb87e338cb99bd4a867a8bd7e64c9
Diffstat (limited to 'java/app.go')
-rw-r--r-- | java/app.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/java/app.go b/java/app.go index a4e84e097..0abeaf486 100644 --- a/java/app.go +++ b/java/app.go @@ -495,18 +495,24 @@ func (a *AndroidApp) checkEmbedJnis(ctx android.BaseModuleContext) { // This check is enforced for "updatable" APKs (including APK-in-APEX). func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVersion android.ApiLevel) { // It's enough to check direct JNI deps' sdk_version because all transitive deps from JNI deps are checked in cc.checkLinkType() - ctx.VisitDirectDeps(func(m android.Module) { + ctx.VisitDirectDepsProxy(func(m android.ModuleProxy) { if !IsJniDepTag(ctx.OtherModuleDependencyTag(m)) { return } - dep, _ := m.(*cc.Module) + if _, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); !ok { + panic(fmt.Errorf("jni dependency is not a cc module: %v", m)) + } + commonInfo, ok := android.OtherModuleProvider(ctx, m, android.CommonModuleInfoKey) + if !ok { + panic(fmt.Errorf("jni dependency doesn't have CommonModuleInfo provider: %v", m)) + } // The domain of cc.sdk_version is "current" and <number> // We can rely on android.SdkSpec to convert it to <number> so that "current" is // handled properly regardless of sdk finalization. - jniSdkVersion, err := android.SdkSpecFrom(ctx, dep.MinSdkVersion()).EffectiveVersion(ctx) + jniSdkVersion, err := android.SdkSpecFrom(ctx, commonInfo.MinSdkVersion).EffectiveVersion(ctx) if err != nil || minSdkVersion.LessThan(jniSdkVersion) { - ctx.OtherModuleErrorf(dep, "min_sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)", - dep.MinSdkVersion(), minSdkVersion, ctx.ModuleName()) + ctx.OtherModuleErrorf(m, "min_sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)", + commonInfo.MinSdkVersion, minSdkVersion, ctx.ModuleName()) return } |