Skip packaging cross container cc deps of apk-in-apex
With this change, apk-in-apex will skip packaging a cc library
dependency if the dependency is part of the platform or part of a
different apex.
Bug: 375473764
Test: go test ./java ./apex
Test: presubmits
Change-Id: I91351973c2c941c7531e9f7d4879049eab766a12
diff --git a/cc/cc.go b/cc/cc.go
index 65ab686..03f738f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3345,17 +3345,17 @@
return depPaths
}
-func ShouldUseStubForApex(ctx android.ModuleContext, dep android.Module) bool {
+func ShouldUseStubForApex(ctx android.ModuleContext, parent, dep android.Module) bool {
inVendorOrProduct := false
bootstrap := false
- if linkable, ok := ctx.Module().(LinkableInterface); !ok {
- panic(fmt.Errorf("Not a Linkable module: %q", ctx.ModuleName()))
+ if linkable, ok := parent.(LinkableInterface); !ok {
+ ctx.ModuleErrorf("Not a Linkable module: %q", ctx.ModuleName())
} else {
inVendorOrProduct = linkable.InVendorOrProduct()
bootstrap = linkable.Bootstrap()
}
- apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ apexInfo, _ := android.OtherModuleProvider(ctx, parent, android.ApexInfoProvider)
useStubs := false
@@ -3402,7 +3402,7 @@
if !libDepTag.explicitlyVersioned && len(sharedLibraryStubsInfo.SharedStubLibraries) > 0 {
// when to use (unspecified) stubs, use the latest one.
- if ShouldUseStubForApex(ctx, dep) {
+ if ShouldUseStubForApex(ctx, ctx.Module(), dep) {
stubs := sharedLibraryStubsInfo.SharedStubLibraries
toUse := stubs[len(stubs)-1]
sharedLibraryInfo = toUse.SharedLibraryInfo