Snap for 7394644 from a90cba820b6b51ee23a404d048600b4816f8773b to sc-release

Change-Id: I926126ff70dc9c58b6de80a0d3d6d894025d636d
diff --git a/context.go b/context.go
index f55b4b6..e891c23 100644
--- a/context.go
+++ b/context.go
@@ -747,6 +747,7 @@
 
 	type newModuleInfo struct {
 		*moduleInfo
+		deps  []string
 		added chan<- struct{}
 	}
 
@@ -772,12 +773,12 @@
 			// 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 @@
 		doneCh <- struct{}{}
 	}()
 
+	var hookDeps []string
 loop:
 	for {
 		select {
@@ -827,6 +829,7 @@
 			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 @@
 		}
 	}
 
+	deps = append(deps, hookDeps...)
 	return deps, errs
 }
 
diff --git a/module_ctx.go b/module_ctx.go
index 7e8acf6..a074e37 100644
--- a/module_ctx.go
+++ b/module_ctx.go
@@ -1339,7 +1339,7 @@
 }
 
 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)
@@ -1355,14 +1355,15 @@
 		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.