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
This commit is contained in:
parent
82b7d51dfd
commit
80ad04d5f8
2 changed files with 15 additions and 5 deletions
|
@ -1205,7 +1205,6 @@ func (c *Context) generateModuleBuildActions(config interface{},
|
||||||
group: group,
|
group: group,
|
||||||
},
|
},
|
||||||
module: module,
|
module: module,
|
||||||
primaryModule: group.modules[0],
|
|
||||||
},
|
},
|
||||||
scope: scope,
|
scope: scope,
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,8 @@ type ModuleContext interface {
|
||||||
AddNinjaFileDeps(deps ...string)
|
AddNinjaFileDeps(deps ...string)
|
||||||
|
|
||||||
PrimaryModule() Module
|
PrimaryModule() Module
|
||||||
|
FinalModule() Module
|
||||||
|
VisitAllModuleVariants(visit func(Module))
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ BaseModuleContext = (*baseModuleContext)(nil)
|
var _ BaseModuleContext = (*baseModuleContext)(nil)
|
||||||
|
@ -197,7 +199,6 @@ var _ PreModuleContext = (*preModuleContext)(nil)
|
||||||
type preModuleContext struct {
|
type preModuleContext struct {
|
||||||
baseModuleContext
|
baseModuleContext
|
||||||
module *moduleInfo
|
module *moduleInfo
|
||||||
primaryModule *moduleInfo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *preModuleContext) OtherModuleName(module Module) string {
|
func (m *preModuleContext) OtherModuleName(module Module) string {
|
||||||
|
@ -280,7 +281,17 @@ func (m *moduleContext) AddNinjaFileDeps(deps ...string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *moduleContext) PrimaryModule() Module {
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue