Add FinalModule and VisitAllModuleVariants to ModuleContext
Allows modules to determine if they are the last of their variants
to build, and to visit each variant to collect shared information.
Change-Id: I396f0c9d43e0e9b1901822d6dd9c6ad6380ad582
diff --git a/blueprint/context.go b/blueprint/context.go
index d43c3af..7a508cb 100644
--- a/blueprint/context.go
+++ b/blueprint/context.go
@@ -1204,8 +1204,7 @@
config: config,
group: group,
},
- module: module,
- primaryModule: group.modules[0],
+ module: module,
},
scope: scope,
}
diff --git a/blueprint/module_ctx.go b/blueprint/module_ctx.go
index fd89a86..6faff01 100644
--- a/blueprint/module_ctx.go
+++ b/blueprint/module_ctx.go
@@ -128,6 +128,8 @@
AddNinjaFileDeps(deps ...string)
PrimaryModule() Module
+ FinalModule() Module
+ VisitAllModuleVariants(visit func(Module))
}
var _ BaseModuleContext = (*baseModuleContext)(nil)
@@ -196,8 +198,7 @@
type preModuleContext struct {
baseModuleContext
- module *moduleInfo
- primaryModule *moduleInfo
+ module *moduleInfo
}
func (m *preModuleContext) OtherModuleName(module Module) string {
@@ -280,7 +281,17 @@
}
func (m *moduleContext) PrimaryModule() Module {
- return m.primaryModule.logicModule
+ return m.module.group.modules[0].logicModule
+}
+
+func (m *moduleContext) FinalModule() Module {
+ return m.module.group.modules[len(m.module.group.modules)-1].logicModule
+}
+
+func (m *moduleContext) VisitAllModuleVariants(visit func(Module)) {
+ for _, module := range m.module.group.modules {
+ visit(module.logicModule)
+ }
}
//