diff --git a/context.go b/context.go index f55b4b6..e891c23 100644 --- a/context.go +++ b/context.go @@ -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 } diff --git a/module_ctx.go b/module_ctx.go index da07062..dea8d2d 100644 --- a/module_ctx.go +++ b/module_ctx.go @@ -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.