Convert collectJniDeps to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I36f8b339f70ab47be84c598231cb971145fc4ef7
diff --git a/cc/cc.go b/cc/cc.go
index 57b5e3c..16aa4a7 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -136,7 +136,11 @@
UnstrippedOutputFile android.Path
OutputFile android.OptionalPath
CoverageFiles android.Paths
- SAbiDumpFiles android.Paths
+ // CoverageOutputFile returns the output archive of gcno coverage information files.
+ CoverageOutputFile android.OptionalPath
+ SAbiDumpFiles android.Paths
+ // Partition returns the partition string for this module.
+ Partition string
CcLibrary bool
CcLibraryInterface bool
RustLibraryInterface bool
@@ -148,7 +152,9 @@
BaseModuleName string
HasNonSystemVariants bool
IsLlndk bool
- InVendorOrProduct bool
+ // True if the library is in the configs known NDK list.
+ IsNdk bool
+ InVendorOrProduct bool
// SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName string
InRamdisk bool
@@ -162,6 +168,8 @@
RelativeInstallPath string
// TODO(b/362509506): remove this once all apex_exclude uses are switched to stubs.
RustApexExclude bool
+ // Bootstrap tests if this module is allowed to use non-APEX version of libraries.
+ Bootstrap bool
}
var LinkableInfoProvider = blueprint.NewProvider[*LinkableInfo]()
@@ -2261,7 +2269,7 @@
android.SetProvider(ctx, CcObjectInfoProvider, ccObjectInfo)
}
- linkableInfo := CreateCommonLinkableInfo(c)
+ linkableInfo := CreateCommonLinkableInfo(ctx, c)
if lib, ok := c.linker.(VersionedInterface); ok {
linkableInfo.StubsVersion = lib.StubsVersion()
}
@@ -2348,18 +2356,21 @@
}
}
-func CreateCommonLinkableInfo(mod VersionedLinkableInterface) *LinkableInfo {
+func CreateCommonLinkableInfo(ctx android.ModuleContext, mod VersionedLinkableInterface) *LinkableInfo {
return &LinkableInfo{
StaticExecutable: mod.StaticExecutable(),
HasStubsVariants: mod.HasStubsVariants(),
OutputFile: mod.OutputFile(),
UnstrippedOutputFile: mod.UnstrippedOutputFile(),
+ CoverageOutputFile: mod.CoverageOutputFile(),
+ Partition: mod.Partition(),
IsStubs: mod.IsStubs(),
CcLibrary: mod.CcLibrary(),
CcLibraryInterface: mod.CcLibraryInterface(),
RustLibraryInterface: mod.RustLibraryInterface(),
BaseModuleName: mod.BaseModuleName(),
IsLlndk: mod.IsLlndk(),
+ IsNdk: mod.IsNdk(ctx.Config()),
HasNonSystemVariants: mod.HasNonSystemVariants(),
SubName: mod.SubName(),
InVendorOrProduct: mod.InVendorOrProduct(),
@@ -2373,6 +2384,7 @@
RelativeInstallPath: mod.RelativeInstallPath(),
// TODO(b/362509506): remove this once all apex_exclude uses are switched to stubs.
RustApexExclude: mod.RustApexExclude(),
+ Bootstrap: mod.Bootstrap(),
}
}
@@ -3601,14 +3613,23 @@
return depPaths
}
-func ShouldUseStubForApex(ctx android.ModuleContext, parent, dep android.Module) bool {
+func ShouldUseStubForApex(ctx android.ModuleContext, parent android.Module, dep android.ModuleProxy) bool {
inVendorOrProduct := false
bootstrap := false
- if linkable, ok := parent.(LinkableInterface); !ok {
- ctx.ModuleErrorf("Not a Linkable module: %q", ctx.ModuleName())
+ if ctx.EqualModules(ctx.Module(), parent) {
+ if linkable, ok := parent.(LinkableInterface); !ok {
+ ctx.ModuleErrorf("Not a Linkable module: %q", ctx.ModuleName())
+ } else {
+ inVendorOrProduct = linkable.InVendorOrProduct()
+ bootstrap = linkable.Bootstrap()
+ }
} else {
- inVendorOrProduct = linkable.InVendorOrProduct()
- bootstrap = linkable.Bootstrap()
+ if linkable, ok := android.OtherModuleProvider(ctx, parent, LinkableInfoProvider); !ok {
+ ctx.ModuleErrorf("Not a Linkable module: %q", ctx.ModuleName())
+ } else {
+ inVendorOrProduct = linkable.InVendorOrProduct
+ bootstrap = linkable.Bootstrap
+ }
}
apexInfo, _ := android.OtherModuleProvider(ctx, parent, android.ApexInfoProvider)
@@ -3645,7 +3666,7 @@
// library bar which provides stable interface and exists in the platform, foo uses the stub variant
// of bar. If bar doesn't provide a stable interface (i.e. buildStubs() == false) or is in the
// same APEX as foo, the non-stub variant of bar is used.
-func ChooseStubOrImpl(ctx android.ModuleContext, dep android.Module) (SharedLibraryInfo, FlagExporterInfo) {
+func ChooseStubOrImpl(ctx android.ModuleContext, dep android.ModuleProxy) (SharedLibraryInfo, FlagExporterInfo) {
depTag := ctx.OtherModuleDependencyTag(dep)
libDepTag, ok := depTag.(libraryDependencyTag)
if !ok || !libDepTag.shared() {