Convert findImplementationLibrary and compilerFlags to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: If1f4a1bf81737c49046cd268a34110a0e38bb2f5
diff --git a/cc/cc.go b/cc/cc.go
index a877f47..18bffb5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -46,9 +46,9 @@
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 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 BinaryDecoratorInfo struct{}
type LibraryDecoratorInfo struct {
- Export_include_dirs proptools.Configurable[[]string]
+ ExportIncludeDirs proptools.Configurable[[]string]
}
type TestBinaryInfo struct {
Gtest bool
@@ -2166,13 +2167,13 @@
}
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 @@
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 @@
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 408aea6..a40b863 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -208,19 +208,19 @@
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 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 91f107c..f2bced1 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -367,7 +367,7 @@
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 2411614..197a4b2 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -296,20 +296,20 @@
}
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 6481b95..18e6f35 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -222,8 +222,8 @@
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.