Fix AddNinjaFileDeps in a LoadHook
Propagate the ninja file deps from a LoadHook to the build.ninja.d
file.
Bug: 188547846
Test: next CL
Merged-In: If8176474b5094ee40d07df12f5da79a906ce7290
Change-Id: If8176474b5094ee40d07df12f5da79a906ce7290
(cherry picked from commit 13b5befc5c
)
This commit is contained in:
parent
6ec1dbf6d4
commit
8266ace31a
2 changed files with 10 additions and 5 deletions
|
@ -747,6 +747,7 @@ func (c *Context) ParseFileList(rootDir string, filePaths []string,
|
|||
|
||||
type newModuleInfo struct {
|
||||
*moduleInfo
|
||||
deps []string
|
||||
added chan<- struct{}
|
||||
}
|
||||
|
||||
|
@ -772,12 +773,12 @@ func (c *Context) ParseFileList(rootDir string, filePaths []string,
|
|||
// registered by name. This allows load hooks to set and/or modify any aspect
|
||||
// of the module (including names) using information that is not available when
|
||||
// the module factory is called.
|
||||
newModules, errs := runAndRemoveLoadHooks(c, config, module, &scopedModuleFactories)
|
||||
newModules, newDeps, errs := runAndRemoveLoadHooks(c, config, module, &scopedModuleFactories)
|
||||
if len(errs) > 0 {
|
||||
return errs
|
||||
}
|
||||
|
||||
moduleCh <- newModuleInfo{module, addedCh}
|
||||
moduleCh <- newModuleInfo{module, newDeps, addedCh}
|
||||
<-addedCh
|
||||
for _, n := range newModules {
|
||||
errs = addModule(n)
|
||||
|
@ -820,6 +821,7 @@ func (c *Context) ParseFileList(rootDir string, filePaths []string,
|
|||
doneCh <- struct{}{}
|
||||
}()
|
||||
|
||||
var hookDeps []string
|
||||
loop:
|
||||
for {
|
||||
select {
|
||||
|
@ -827,6 +829,7 @@ loop:
|
|||
errs = append(errs, newErrs...)
|
||||
case module := <-moduleCh:
|
||||
newErrs := c.addModule(module.moduleInfo)
|
||||
hookDeps = append(hookDeps, module.deps...)
|
||||
if module.added != nil {
|
||||
module.added <- struct{}{}
|
||||
}
|
||||
|
@ -841,6 +844,7 @@ loop:
|
|||
}
|
||||
}
|
||||
|
||||
deps = append(deps, hookDeps...)
|
||||
return deps, errs
|
||||
}
|
||||
|
||||
|
|
|
@ -1323,7 +1323,7 @@ func AddLoadHook(module Module, hook LoadHook) {
|
|||
}
|
||||
|
||||
func runAndRemoveLoadHooks(ctx *Context, config interface{}, module *moduleInfo,
|
||||
scopedModuleFactories *map[string]ModuleFactory) (newModules []*moduleInfo, errs []error) {
|
||||
scopedModuleFactories *map[string]ModuleFactory) (newModules []*moduleInfo, deps []string, errs []error) {
|
||||
|
||||
if v, exists := pendingHooks.Load(module.logicModule); exists {
|
||||
hooks := v.(*[]LoadHook)
|
||||
|
@ -1339,14 +1339,15 @@ func runAndRemoveLoadHooks(ctx *Context, config interface{}, module *moduleInfo,
|
|||
for _, hook := range *hooks {
|
||||
hook(mctx)
|
||||
newModules = append(newModules, mctx.newModules...)
|
||||
deps = append(deps, mctx.ninjaFileDeps...)
|
||||
errs = append(errs, mctx.errs...)
|
||||
}
|
||||
pendingHooks.Delete(module.logicModule)
|
||||
|
||||
return newModules, errs
|
||||
return newModules, deps, errs
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
// Check the syntax of a generated blueprint file.
|
||||
|
|
Loading…
Reference in a new issue