From b614cd441b355e48e59d1f5cd61a800103404151 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Fri, 11 Oct 2024 12:52:21 -0700 Subject: Verify that libraries in apexes don't link to implementations outside the apex As part of removing some of the complexity in Soong around using stub vs. implementations for shared library dependencies a syntax will be added to Soong to allow explicitly selecting stubs vs. implementation. To avoid incorrect use, add a verification pass on apexes that ensure that all transitive implementation libraries used to link native libraries or binaries in the apex are themselves in the apex. Bug: 372543712 Test: TestApexVerifyNativeImplementationLibs Flag: EXEMPT host only Change-Id: I4aeaca00a359ce97e8f9efd2d8bffb8f9d2dc0df --- java/java.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'java/java.go') diff --git a/java/java.go b/java/java.go index 85024e199..ac4f49619 100644 --- a/java/java.go +++ b/java/java.go @@ -1621,6 +1621,8 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, j.data = append(j.data, android.OutputFileForModule(ctx, dep, "")) }) + var directImplementationDeps android.Paths + var transitiveImplementationDeps []depset.DepSet[android.Path] ctx.VisitDirectDepsWithTag(jniLibTag, func(dep android.Module) { sharedLibInfo, _ := android.OtherModuleProvider(ctx, dep, cc.SharedLibraryInfoProvider) if sharedLibInfo.SharedLibrary != nil { @@ -1639,11 +1641,20 @@ func (j *Test) generateAndroidBuildActionsWithConfig(ctx android.ModuleContext, Output: relocatedLib, }) j.data = append(j.data, relocatedLib) + + directImplementationDeps = append(directImplementationDeps, android.OutputFileForModule(ctx, dep, "")) + if info, ok := android.OtherModuleProvider(ctx, dep, cc.ImplementationDepInfoProvider); ok { + transitiveImplementationDeps = append(transitiveImplementationDeps, info.ImplementationDeps) + } } else { ctx.PropertyErrorf("jni_libs", "%q of type %q is not supported", dep.Name(), ctx.OtherModuleType(dep)) } }) + android.SetProvider(ctx, cc.ImplementationDepInfoProvider, &cc.ImplementationDepInfo{ + ImplementationDeps: depset.New(depset.PREORDER, directImplementationDeps, transitiveImplementationDeps), + }) + j.Library.GenerateAndroidBuildActions(ctx) } -- cgit v1.2.3-59-g8ed1b