diff options
author | 2024-12-17 00:09:15 +0000 | |
---|---|---|
committer | 2024-12-17 10:21:07 -0800 | |
commit | f432c2ee60020428dea42dc15e07c612fac09d54 (patch) | |
tree | 3394c9cee7a3a186cdba883afeecc6d3c29af4e5 | |
parent | b2b1d2e4f409008d7a83350d066bf26ce08018b1 (diff) |
Convert GeneratorBuildActions, GeneratorSources,
buildComplianceMetadataInfo to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I22520e7dd3ae2ddcfa36dd39658f04c69e9e6012
-rw-r--r-- | aconfig/codegen/cc_aconfig_library.go | 4 | ||||
-rw-r--r-- | android/base_module_context.go | 12 | ||||
-rw-r--r-- | cc/cc.go | 4 |
3 files changed, 16 insertions, 4 deletions
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go index 8c4bfe696..f9c7b8c9a 100644 --- a/aconfig/codegen/cc_aconfig_library.go +++ b/aconfig/codegen/cc_aconfig_library.go @@ -104,7 +104,7 @@ func (this *CcAconfigLibraryCallbacks) GeneratorSources(ctx cc.ModuleContext) cc result := cc.GeneratedSource{} // Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag - declarationsModules := ctx.GetDirectDepsWithTag(ccDeclarationsTag) + declarationsModules := ctx.GetDirectDepsProxyWithTag(ccDeclarationsTag) if len(declarationsModules) != 1 { panic(fmt.Errorf("Exactly one aconfig_declarations property required")) } @@ -134,7 +134,7 @@ func (this *CcAconfigLibraryCallbacks) GeneratorFlags(ctx cc.ModuleContext, flag func (this *CcAconfigLibraryCallbacks) GeneratorBuildActions(ctx cc.ModuleContext, flags cc.Flags, deps cc.PathDeps) { // Get the values that came from the global RELEASE_ACONFIG_VALUE_SETS flag - declarationsModules := ctx.GetDirectDepsWithTag(ccDeclarationsTag) + declarationsModules := ctx.GetDirectDepsProxyWithTag(ccDeclarationsTag) if len(declarationsModules) != 1 { panic(fmt.Errorf("Exactly one aconfig_declarations property required")) } diff --git a/android/base_module_context.go b/android/base_module_context.go index 06819d64a..8c0e4d2c8 100644 --- a/android/base_module_context.go +++ b/android/base_module_context.go @@ -110,6 +110,8 @@ type BaseModuleContext interface { GetDirectDepsWithTag(tag blueprint.DependencyTag) []Module + GetDirectDepsProxyWithTag(tag blueprint.DependencyTag) []ModuleProxy + // GetDirectDepWithTag returns the Module the direct dependency with the specified name, or nil if // none exists. It panics if the dependency does not have the specified tag. It skips any // dependencies that are not an android.Module. @@ -461,6 +463,16 @@ func (b *baseModuleContext) GetDirectDepsWithTag(tag blueprint.DependencyTag) [] return deps } +func (b *baseModuleContext) GetDirectDepsProxyWithTag(tag blueprint.DependencyTag) []ModuleProxy { + var deps []ModuleProxy + b.VisitDirectDepsProxy(func(module ModuleProxy) { + if b.OtherModuleDependencyTag(module) == tag { + deps = append(deps, module) + } + }) + return deps +} + // GetDirectDep returns the Module and DependencyTag for the direct dependency with the specified // name, or nil if none exists. If there are multiple dependencies on the same module it returns the // first DependencyTag. @@ -2167,7 +2167,7 @@ func buildComplianceMetadataInfo(ctx ModuleContext, c *Module, deps PathDeps) { complianceMetadataInfo.SetStringValue(android.ComplianceMetadataProp.BUILT_FILES, c.outputFile.String()) // Static deps - staticDeps := ctx.GetDirectDepsWithTag(StaticDepTag(false)) + staticDeps := ctx.GetDirectDepsProxyWithTag(StaticDepTag(false)) staticDepNames := make([]string, 0, len(staticDeps)) for _, dep := range staticDeps { staticDepNames = append(staticDepNames, dep.Name()) @@ -2181,7 +2181,7 @@ func buildComplianceMetadataInfo(ctx ModuleContext, c *Module, deps PathDeps) { complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEP_FILES, android.FirstUniqueStrings(staticDepPaths)) // Whole static deps - wholeStaticDeps := ctx.GetDirectDepsWithTag(StaticDepTag(true)) + wholeStaticDeps := ctx.GetDirectDepsProxyWithTag(StaticDepTag(true)) wholeStaticDepNames := make([]string, 0, len(wholeStaticDeps)) for _, dep := range wholeStaticDeps { wholeStaticDepNames = append(wholeStaticDepNames, dep.Name()) |