diff options
author | 2024-12-18 00:35:39 +0000 | |
---|---|---|
committer | 2024-12-18 00:37:10 +0000 | |
commit | 4f82513b09679c53bfd918318b5ec852f3425ba2 (patch) | |
tree | c0a819328926c16b304eb8913b03c3b12be13bb9 | |
parent | 3ae96651e532564eb5910bb352345df7f081f0fe (diff) |
Convert findImplementationLibrary and compilerFlags to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: If1f4a1bf81737c49046cd268a34110a0e38bb2f5
-rw-r--r-- | cc/cc.go | 38 | ||||
-rw-r--r-- | cc/cmake_snapshot.go | 10 | ||||
-rw-r--r-- | cc/compiler.go | 2 | ||||
-rw-r--r-- | cc/ndk_library.go | 10 | ||||
-rw-r--r-- | cc/tidy.go | 4 |
5 files changed, 33 insertions, 31 deletions
@@ -46,9 +46,9 @@ type CcMakeVarsInfo struct { var CcMakeVarsInfoProvider = blueprint.NewProvider[*CcMakeVarsInfo]() type CcObjectInfo struct { - objFiles android.Paths - tidyFiles android.Paths - kytheFiles android.Paths + ObjFiles android.Paths + TidyFiles android.Paths + KytheFiles android.Paths } var CcObjectInfoProvider = blueprint.NewProvider[CcObjectInfo]() @@ -73,13 +73,14 @@ type CompilerInfo struct { } type LinkerInfo struct { - Whole_static_libs proptools.Configurable[[]string] + WholeStaticLibs proptools.Configurable[[]string] // list of modules that should be statically linked into this module. - Static_libs proptools.Configurable[[]string] + StaticLibs proptools.Configurable[[]string] // list of modules that should be dynamically linked into this module. - Shared_libs proptools.Configurable[[]string] + SharedLibs proptools.Configurable[[]string] // list of modules that should only provide headers for this module. - Header_libs proptools.Configurable[[]string] + HeaderLibs proptools.Configurable[[]string] + UnstrippedOutputFile android.Path BinaryDecoratorInfo *BinaryDecoratorInfo LibraryDecoratorInfo *LibraryDecoratorInfo @@ -90,7 +91,7 @@ type LinkerInfo struct { type BinaryDecoratorInfo struct{} type LibraryDecoratorInfo struct { - Export_include_dirs proptools.Configurable[[]string] + ExportIncludeDirs proptools.Configurable[[]string] } type TestBinaryInfo struct { Gtest bool @@ -2166,13 +2167,13 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } ccObjectInfo := CcObjectInfo{ - kytheFiles: objs.kytheFiles, + KytheFiles: objs.kytheFiles, } if !ctx.Config().KatiEnabled() || !android.ShouldSkipAndroidMkProcessing(ctx, c) { - ccObjectInfo.objFiles = objs.objFiles - ccObjectInfo.tidyFiles = objs.tidyFiles + ccObjectInfo.ObjFiles = objs.objFiles + ccObjectInfo.TidyFiles = objs.tidyFiles } - if len(ccObjectInfo.kytheFiles)+len(ccObjectInfo.objFiles)+len(ccObjectInfo.tidyFiles) > 0 { + if len(ccObjectInfo.KytheFiles)+len(ccObjectInfo.ObjFiles)+len(ccObjectInfo.TidyFiles) > 0 { android.SetProvider(ctx, CcObjectInfoProvider, ccObjectInfo) } @@ -2199,16 +2200,17 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { switch decorator := c.compiler.(type) { case *libraryDecorator: ccInfo.CompilerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{ - Export_include_dirs: decorator.flagExporter.Properties.Export_include_dirs, + ExportIncludeDirs: decorator.flagExporter.Properties.Export_include_dirs, } } } if c.linker != nil { ccInfo.LinkerInfo = &LinkerInfo{ - Whole_static_libs: c.linker.baseLinkerProps().Whole_static_libs, - Static_libs: c.linker.baseLinkerProps().Static_libs, - Shared_libs: c.linker.baseLinkerProps().Shared_libs, - Header_libs: c.linker.baseLinkerProps().Header_libs, + WholeStaticLibs: c.linker.baseLinkerProps().Whole_static_libs, + StaticLibs: c.linker.baseLinkerProps().Static_libs, + SharedLibs: c.linker.baseLinkerProps().Shared_libs, + HeaderLibs: c.linker.baseLinkerProps().Header_libs, + UnstrippedOutputFile: c.UnstrippedOutputFile(), } switch decorator := c.linker.(type) { case *binaryDecorator: @@ -4080,7 +4082,7 @@ type kytheExtractAllSingleton struct { func (ks *kytheExtractAllSingleton) GenerateBuildActions(ctx android.SingletonContext) { var xrefTargets android.Paths ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { - files := android.OtherModuleProviderOrDefault(ctx, module, CcObjectInfoProvider).kytheFiles + files := android.OtherModuleProviderOrDefault(ctx, module, CcObjectInfoProvider).KytheFiles if len(files) > 0 { xrefTargets = append(xrefTargets, files...) } diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go index 408aea6bf..a40b863f9 100644 --- a/cc/cmake_snapshot.go +++ b/cc/cmake_snapshot.go @@ -208,19 +208,19 @@ func parseTemplate(templateContents string) *template.Template { return prop.GetOrDefault(ctx, nil) }, "getWholeStaticLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string { - prop := info.LinkerInfo.Whole_static_libs + prop := info.LinkerInfo.WholeStaticLibs return prop.GetOrDefault(ctx, nil) }, "getStaticLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string { - prop := info.LinkerInfo.Static_libs + prop := info.LinkerInfo.StaticLibs return prop.GetOrDefault(ctx, nil) }, "getSharedLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string { - prop := info.LinkerInfo.Shared_libs + prop := info.LinkerInfo.SharedLibs return prop.GetOrDefault(ctx, nil) }, "getHeaderLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string { - prop := info.LinkerInfo.Header_libs + prop := info.LinkerInfo.HeaderLibs return prop.GetOrDefault(ctx, nil) }, "getExtraLibs": getExtraLibs, @@ -552,7 +552,7 @@ func getExtraLibs(info *CcInfo) []string { func getIncludeDirs(ctx android.ModuleContext, m android.ModuleProxy, info *CcInfo) []string { moduleDir := ctx.OtherModuleDir(m) + string(filepath.Separator) if info.CompilerInfo.LibraryDecoratorInfo != nil { - return sliceWithPrefix(moduleDir, info.CompilerInfo.LibraryDecoratorInfo.Export_include_dirs.GetOrDefault(ctx, nil)) + return sliceWithPrefix(moduleDir, info.CompilerInfo.LibraryDecoratorInfo.ExportIncludeDirs.GetOrDefault(ctx, nil)) } return nil } diff --git a/cc/compiler.go b/cc/compiler.go index 91f107c29..f2bced10a 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -367,7 +367,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps modulePath := ctx.ModuleDir() reuseObjs := false - if len(ctx.GetDirectDepsWithTag(reuseObjTag)) > 0 { + if len(ctx.GetDirectDepsProxyWithTag(reuseObjTag)) > 0 { reuseObjs = true } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 2411614a4..197a4b252 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -296,20 +296,20 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, src android.Path) Object } func (this *stubDecorator) findImplementationLibrary(ctx ModuleContext) android.Path { - dep := ctx.GetDirectDepWithTag(strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix), + dep := ctx.GetDirectDepProxyWithTag(strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix), stubImplementation) if dep == nil { - ctx.ModuleErrorf("Could not find implementation for stub") + ctx.ModuleErrorf("Could not find implementation for stub: ") return nil } - impl, ok := dep.(*Module) + info, ok := android.OtherModuleProvider(ctx, *dep, CcInfoProvider) if !ok { ctx.ModuleErrorf("Implementation for stub is not correct module type") return nil } - output := impl.UnstrippedOutputFile() + output := info.LinkerInfo.UnstrippedOutputFile if output == nil { - ctx.ModuleErrorf("implementation module (%s) has no output", impl) + ctx.ModuleErrorf("implementation module (%s) has no output", *dep) return nil } diff --git a/cc/tidy.go b/cc/tidy.go index 6481b9537..18e6f3575 100644 --- a/cc/tidy.go +++ b/cc/tidy.go @@ -222,8 +222,8 @@ func collectTidyObjModuleTargets(ctx android.SingletonContext, module android.Mo ctx.VisitAllModuleVariantProxies(module, func(variant android.ModuleProxy) { osName := android.OtherModuleProviderOrDefault(ctx, variant, android.CommonModuleInfoKey).CompileTarget.Os.Name info := android.OtherModuleProviderOrDefault(ctx, variant, CcObjectInfoProvider) - addToOSGroup(osName, info.objFiles, allObjFileGroups, subsetObjFileGroups) - addToOSGroup(osName, info.tidyFiles, allTidyFileGroups, subsetTidyFileGroups) + addToOSGroup(osName, info.ObjFiles, allObjFileGroups, subsetObjFileGroups) + addToOSGroup(osName, info.TidyFiles, allTidyFileGroups, subsetTidyFileGroups) }) // (2) Add an all-OS group, with "" or "subset" name, to include all os-specific phony targets. |