Convert GeneratorBuildActions, GeneratorSources,
buildComplianceMetadataInfo to use ModuleProxy.
Bug: 377723687
Test: Unit tests and compare the ninja and mk files generated.
Change-Id: I22520e7dd3ae2ddcfa36dd39658f04c69e9e6012
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index 8c4bfe6..f9c7b8c 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -104,7 +104,7 @@
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) 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 06819d6..8c0e4d2 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -110,6 +110,8 @@
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 @@
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.
diff --git a/cc/cc.go b/cc/cc.go
index 5c6424b..6641182 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2167,7 +2167,7 @@
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 @@
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())