diff options
author | 2025-01-08 22:54:44 +0000 | |
---|---|---|
committer | 2025-01-08 23:29:54 +0000 | |
commit | 68a70b701baca04f5a773b0df49c850cd59a8cfe (patch) | |
tree | 45556ffad81c82bc4753e4a70c0b11637a798f3a | |
parent | 97880e1afa6b8749cb3bb67b85cd5c86a95d3519 (diff) |
Convert getLibsForLinkerConfig to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: Ib8020db0d1cf9e035ace52e2a893bb3df7975127
-rw-r--r-- | android/module.go | 2 | ||||
-rw-r--r-- | cc/cc.go | 9 | ||||
-rw-r--r-- | cc/stub_library.go | 6 | ||||
-rw-r--r-- | filesystem/filesystem.go | 16 | ||||
-rw-r--r-- | linkerconfig/linkerconfig.go | 20 |
5 files changed, 35 insertions, 18 deletions
diff --git a/android/module.go b/android/module.go index 9ccc055c8..508956468 100644 --- a/android/module.go +++ b/android/module.go @@ -1884,6 +1884,7 @@ type CommonModuleInfo struct { HideFromMake bool SkipInstall bool IsStubsModule bool + Host bool } var CommonModuleInfoKey = blueprint.NewProvider[CommonModuleInfo]() @@ -2170,6 +2171,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) UninstallableApexPlatformVariant: m.commonProperties.UninstallableApexPlatformVariant, HideFromMake: m.commonProperties.HideFromMake, SkipInstall: m.commonProperties.SkipInstall, + Host: m.Host(), } if mm, ok := m.module.(interface { MinSdkVersion(ctx EarlyModuleContext) ApiLevel @@ -78,7 +78,8 @@ type LinkerInfo struct { // list of modules that should be dynamically linked into this module. SharedLibs proptools.Configurable[[]string] // list of modules that should only provide headers for this module. - HeaderLibs proptools.Configurable[[]string] + HeaderLibs proptools.Configurable[[]string] + ImplementationModuleName *string BinaryDecoratorInfo *BinaryDecoratorInfo LibraryDecoratorInfo *LibraryDecoratorInfo @@ -115,6 +116,7 @@ type LibraryInfo struct { type CcInfo struct { IsPrebuilt bool CmakeSnapshotSupported bool + HasLlndkStubs bool CompilerInfo *CompilerInfo LinkerInfo *LinkerInfo SnapshotInfo *SnapshotInfo @@ -2237,6 +2239,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { ccInfo := CcInfo{ IsPrebuilt: c.IsPrebuilt(), CmakeSnapshotSupported: proptools.Bool(c.Properties.Cmake_snapshot_supported), + HasLlndkStubs: c.HasLlndkStubs(), } if c.compiler != nil { ccInfo.CompilerInfo = &CompilerInfo{ @@ -2287,6 +2290,10 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { SnapshotAndroidMkSuffix: s.SnapshotAndroidMkSuffix(), } } + if v, ok := c.linker.(versionedInterface); ok { + name := v.implementationModuleName(ctx.OtherModuleName(c)) + ccInfo.LinkerInfo.ImplementationModuleName = &name + } } if c.library != nil { ccInfo.LibraryInfo = &LibraryInfo{ diff --git a/cc/stub_library.go b/cc/stub_library.go index 5911be017..75d649f04 100644 --- a/cc/stub_library.go +++ b/cc/stub_library.go @@ -38,8 +38,8 @@ type stubLibraries struct { } // Check if the module defines stub, or itself is stub -func IsStubTarget(m *Module) bool { - return m.IsStubs() || m.HasStubsVariants() +func IsStubTarget(info *LinkableInfo) bool { + return info != nil && (info.IsStubs || info.HasStubsVariants) } // Get target file name to be installed from this module @@ -59,7 +59,7 @@ func (s *stubLibraries) GenerateBuildActions(ctx android.SingletonContext) { vendorStubLibraryMap := make(map[string]bool) ctx.VisitAllModules(func(module android.Module) { if m, ok := module.(*Module); ok { - if IsStubTarget(m) { + if IsStubTarget(android.OtherModuleProviderOrDefault(ctx, m, LinkableInfoProvider)) { if name := getInstalledFileName(ctx, m); name != "" { stubLibraryMap[name] = true if m.InVendor() { diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go index bd8018b80..9055546d3 100644 --- a/filesystem/filesystem.go +++ b/filesystem/filesystem.go @@ -1075,14 +1075,14 @@ func (f *filesystemDefaults) GenerateAndroidBuildActions(ctx android.ModuleConte // `linkerconfig.BuildLinkerConfig` will convert these two to a linker.config.pb for the filesystem // (1) will be added to --provideLibs if they are C libraries with a stable interface (has stubs) // (2) will be added to --requireLibs if they are C libraries with a stable interface (has stubs) -func (f *filesystem) getLibsForLinkerConfig(ctx android.ModuleContext) ([]android.Module, []android.Module) { +func (f *filesystem) getLibsForLinkerConfig(ctx android.ModuleContext) ([]android.ModuleProxy, []android.ModuleProxy) { // we need "Module"s for packaging items - modulesInPackageByModule := make(map[android.Module]bool) + modulesInPackageByModule := make(map[android.ModuleProxy]bool) modulesInPackageByName := make(map[string]bool) deps := f.gatherFilteredPackagingSpecs(ctx) - ctx.WalkDeps(func(child, _ android.Module) bool { - if !child.Enabled(ctx) { + ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { + if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoKey).Enabled { return false } for _, ps := range android.OtherModuleProviderOrDefault( @@ -1096,14 +1096,14 @@ func (f *filesystem) getLibsForLinkerConfig(ctx android.ModuleContext) ([]androi return true }) - provideModules := make([]android.Module, 0, len(modulesInPackageByModule)) + provideModules := make([]android.ModuleProxy, 0, len(modulesInPackageByModule)) for mod := range modulesInPackageByModule { provideModules = append(provideModules, mod) } - var requireModules []android.Module - ctx.WalkDeps(func(child, parent android.Module) bool { - if !child.Enabled(ctx) { + var requireModules []android.ModuleProxy + ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool { + if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoKey).Enabled { return false } _, parentInPackage := modulesInPackageByModule[parent] diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go index 7684db288..4f1ef9d66 100644 --- a/linkerconfig/linkerconfig.go +++ b/linkerconfig/linkerconfig.go @@ -91,8 +91,8 @@ func (l *linkerConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) { func BuildLinkerConfig( ctx android.ModuleContext, inputs android.Paths, - provideModules []android.Module, - requireModules []android.Module, + provideModules []android.ModuleProxy, + requireModules []android.ModuleProxy, output android.WritablePath, ) { // First, convert the input json to protobuf format @@ -110,9 +110,10 @@ func BuildLinkerConfig( // Secondly, if there's provideLibs gathered from provideModules, append them var provideLibs []string for _, m := range provideModules { - if c, ok := m.(*cc.Module); ok && (cc.IsStubTarget(c) || c.HasLlndkStubs()) { + ccInfo, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider) + if ok && (cc.IsStubTarget(android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider)) || ccInfo.HasLlndkStubs) { for _, ps := range android.OtherModuleProviderOrDefault( - ctx, c, android.InstallFilesProvider).PackagingSpecs { + ctx, m, android.InstallFilesProvider).PackagingSpecs { provideLibs = append(provideLibs, ps.FileName()) } } @@ -122,8 +123,15 @@ func BuildLinkerConfig( var requireLibs []string for _, m := range requireModules { - if c, ok := m.(*cc.Module); ok && c.HasStubsVariants() && !c.Host() { - requireLibs = append(requireLibs, c.ImplementationModuleName(ctx)+".so") + if _, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); ok { + if android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider).HasStubsVariants && + !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoKey).Host { + name := ctx.OtherModuleName(m) + if ccInfo, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); ok && ccInfo.LinkerInfo != nil && ccInfo.LinkerInfo.ImplementationModuleName != nil { + name = *ccInfo.LinkerInfo.ImplementationModuleName + } + requireLibs = append(requireLibs, name+".so") + } } } |