diff options
author | 2025-03-10 09:41:18 -0700 | |
---|---|---|
committer | 2025-03-10 09:41:18 -0700 | |
commit | 3ff67e8a6335d6ead04f4689a6d43803f8561448 (patch) | |
tree | 86d92230f7f56da17ebfe276fe5b8367ce82bf3a /cc | |
parent | 3639838f5e5700774f251ef8a2324015d3b1ad77 (diff) | |
parent | 8840812f9dfa3ba5ceecd75e582836a3c673d54b (diff) |
Merge "Convert singletonModuleSingletonAdaptor, rustdocSingleton, sizesSingleton, movedToApexLlndkLibraries and allBuildFlagDeclarationsSingleton to use ModuleProxy." into main
Diffstat (limited to 'cc')
-rw-r--r-- | cc/cc.go | 48 | ||||
-rw-r--r-- | cc/llndk_library.go | 39 |
2 files changed, 63 insertions, 24 deletions
@@ -81,12 +81,13 @@ type LinkerInfo struct { HeaderLibs []string ImplementationModuleName *string - BinaryDecoratorInfo *BinaryDecoratorInfo - LibraryDecoratorInfo *LibraryDecoratorInfo - TestBinaryInfo *TestBinaryInfo - BenchmarkDecoratorInfo *BenchmarkDecoratorInfo - ObjectLinkerInfo *ObjectLinkerInfo - StubDecoratorInfo *StubDecoratorInfo + BinaryDecoratorInfo *BinaryDecoratorInfo + LibraryDecoratorInfo *LibraryDecoratorInfo + TestBinaryInfo *TestBinaryInfo + BenchmarkDecoratorInfo *BenchmarkDecoratorInfo + ObjectLinkerInfo *ObjectLinkerInfo + StubDecoratorInfo *StubDecoratorInfo + PrebuiltLibraryLinkerInfo *PrebuiltLibraryLinkerInfo } type BinaryDecoratorInfo struct{} @@ -96,6 +97,7 @@ type LibraryDecoratorInfo struct { // Location of the static library in the sysroot. Empty if the library is // not included in the NDK. NdkSysrootPath android.Path + VndkFileName string } type SnapshotInfo struct { @@ -120,6 +122,10 @@ type ObjectLinkerInfo struct { NdkSysrootPath android.Path } +type PrebuiltLibraryLinkerInfo struct { + VndkFileName string +} + type LibraryInfo struct { BuildStubs bool } @@ -128,6 +134,13 @@ type InstallerInfo struct { StubDecoratorInfo *StubDecoratorInfo } +type LocalOrGlobalFlagsInfo struct { + CommonFlags []string // Flags that apply to C, C++, and assembly source files + CFlags []string // Flags that apply to C and C++ source files + ConlyFlags []string // Flags that apply to C source files + CppFlags []string // Flags that apply to C++ source files +} + // Common info about the cc module. type CcInfo struct { IsPrebuilt bool @@ -148,6 +161,7 @@ type LinkableInfo struct { StaticExecutable bool Static bool Shared bool + Header bool HasStubsVariants bool StubsVersion string IsStubs bool @@ -195,7 +209,11 @@ type LinkableInfo struct { APIListCoverageXMLPath android.ModuleOutPath // FuzzSharedLibraries returns the shared library dependencies for this module. // Expects that IsFuzzModule returns true. - FuzzSharedLibraries android.RuleBuilderInstalls + FuzzSharedLibraries android.RuleBuilderInstalls + IsVndkPrebuiltLibrary bool + HasLLNDKStubs bool + IsLLNDKMovedToApex bool + ImplementationModuleName string } var LinkableInfoProvider = blueprint.NewProvider[*LinkableInfo]() @@ -2356,9 +2374,11 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { case *binaryDecorator: ccInfo.LinkerInfo.BinaryDecoratorInfo = &BinaryDecoratorInfo{} case *libraryDecorator: + lk := c.linker.(*libraryDecorator) ccInfo.LinkerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{ - InjectBsslHash: Bool(c.linker.(*libraryDecorator).Properties.Inject_bssl_hash), - NdkSysrootPath: c.linker.(*libraryDecorator).ndkSysrootPath, + InjectBsslHash: Bool(lk.Properties.Inject_bssl_hash), + NdkSysrootPath: lk.ndkSysrootPath, + VndkFileName: lk.getLibNameHelper(c.BaseModuleName(), true, false) + ".so", } case *testBinary: ccInfo.LinkerInfo.TestBinaryInfo = &TestBinaryInfo{ @@ -2372,6 +2392,11 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } case *stubDecorator: ccInfo.LinkerInfo.StubDecoratorInfo = &StubDecoratorInfo{} + case *prebuiltLibraryLinker: + ccInfo.LinkerInfo.PrebuiltLibraryLinkerInfo = &PrebuiltLibraryLinkerInfo{ + VndkFileName: c.linker.(*prebuiltLibraryLinker).getLibNameHelper( + c.BaseModuleName(), true, false) + ".so", + } } if s, ok := c.linker.(SnapshotInterface); ok { @@ -2441,12 +2466,17 @@ func CreateCommonLinkableInfo(ctx android.ModuleContext, mod VersionedLinkableIn Multilib: mod.Multilib(), ImplementationModuleNameForMake: mod.ImplementationModuleNameForMake(), Symlinks: mod.Symlinks(), + Header: mod.Header(), + IsVndkPrebuiltLibrary: mod.IsVndkPrebuiltLibrary(), } vi := mod.VersionedInterface() if vi != nil { info.IsStubsImplementationRequired = vi.IsStubsImplementationRequired() info.APIListCoverageXMLPath = vi.GetAPIListCoverageXMLPath() + info.HasLLNDKStubs = vi.HasLLNDKStubs() + info.IsLLNDKMovedToApex = vi.IsLLNDKMovedToApex() + info.ImplementationModuleName = vi.ImplementationModuleName(mod.BaseModuleName()) } if !mod.PreventInstall() && fuzz.IsValid(ctx, mod.FuzzModuleStruct()) && mod.IsFuzzModule() { diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 8ca3ca184..b119fdac1 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -82,11 +82,10 @@ type movedToApexLlndkLibraries struct { func (s *movedToApexLlndkLibraries) GenerateBuildActions(ctx android.SingletonContext) { // Make uses LLNDK_MOVED_TO_APEX_LIBRARIES to generate the linker config. movedToApexLlndkLibrariesMap := make(map[string]bool) - ctx.VisitAllModules(func(module android.Module) { - if library := moduleVersionedInterface(module); library != nil && library.HasLLNDKStubs() { - if library.IsLLNDKMovedToApex() { - name := library.ImplementationModuleName(module.(*Module).BaseModuleName()) - movedToApexLlndkLibrariesMap[name] = true + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + if library, ok := android.OtherModuleProvider(ctx, module, LinkableInfoProvider); ok { + if library.HasLLNDKStubs && library.IsLLNDKMovedToApex { + movedToApexLlndkLibrariesMap[library.ImplementationModuleName] = true } } }) @@ -151,14 +150,16 @@ func (txt *llndkLibrariesTxtModule) GenerateAndroidBuildActions(ctx android.Modu etc.SetCommonPrebuiltEtcInfo(ctx, txt) } -func getVndkFileName(m *Module) (string, error) { - if library, ok := m.linker.(*libraryDecorator); ok { - return library.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil - } - if prebuilt, ok := m.linker.(*prebuiltLibraryLinker); ok { - return prebuilt.libraryDecorator.getLibNameHelper(m.BaseModuleName(), true, false) + ".so", nil +func getVndkFileName(info *LinkerInfo) (string, error) { + if info != nil { + if info.LibraryDecoratorInfo != nil { + return info.LibraryDecoratorInfo.VndkFileName, nil + } + if info.PrebuiltLibraryLinkerInfo != nil { + return info.PrebuiltLibraryLinkerInfo.VndkFileName, nil + } } - return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", m.linker) + return "", fmt.Errorf("VNDK library should have libraryDecorator or prebuiltLibraryLinker as linker: %T", info) } func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.SingletonContext) { @@ -167,9 +168,17 @@ func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.Si return } - ctx.VisitAllModules(func(m android.Module) { - if c, ok := m.(*Module); ok && c.VendorProperties.IsLLNDK && !c.Header() && !c.IsVndkPrebuiltLibrary() { - filename, err := getVndkFileName(c) + ctx.VisitAllModuleProxies(func(m android.ModuleProxy) { + ccInfo, ok := android.OtherModuleProvider(ctx, m, CcInfoProvider) + if !ok { + return + } + linkableInfo, ok := android.OtherModuleProvider(ctx, m, LinkableInfoProvider) + if !ok { + return + } + if linkableInfo.IsLlndk && !linkableInfo.Header && !linkableInfo.IsVndkPrebuiltLibrary { + filename, err := getVndkFileName(ccInfo.LinkerInfo) if err != nil { ctx.ModuleErrorf(m, "%s", err) } |