Add AddNinjaFileDeps to PackageContext

Soong needs to add dependencies during a VariableFunc. (we're doing a glob)

Change-Id: Iec7b7082b89e1c7fa43fe7240888d2dabb097a9a
This commit is contained in:
Dan Willemsen 2015-12-18 15:18:03 -08:00
parent 61686a1077
commit a481ae2018
2 changed files with 26 additions and 9 deletions

View file

@ -1452,8 +1452,9 @@ func (c *Context) updateDependencies() (errs []error) {
// config-specific values.
//
// The returned deps is a list of the ninja files dependencies that were added
// by the modules and singletons via the ModuleContext.AddNinjaFileDeps() and
// SingletonContext.AddNinjaFileDeps() methods.
// by the modules and singletons via the ModuleContext.AddNinjaFileDeps(),
// SingletonContext.AddNinjaFileDeps(), and PackageContext.AddNinjaFileDeps()
// methods.
func (c *Context) PrepareBuildActions(config interface{}) (deps []string, errs []error) {
c.buildActionsReady = false
@ -1484,7 +1485,9 @@ func (c *Context) PrepareBuildActions(config interface{}) (deps []string, errs [
liveGlobals.addNinjaStringDeps(c.ninjaBuildDir)
}
pkgNames := c.makeUniquePackageNames(liveGlobals)
pkgNames, depsPackages := c.makeUniquePackageNames(liveGlobals)
deps = append(deps, depsPackages...)
// This will panic if it finds a problem since it's a programming error.
c.checkForVariableReferenceCycles(liveGlobals.variables, pkgNames)
@ -1978,7 +1981,7 @@ func (c *Context) setNinjaBuildDir(value *ninjaString) {
}
func (c *Context) makeUniquePackageNames(
liveGlobals *liveTracker) map[*packageContext]string {
liveGlobals *liveTracker) (map[*packageContext]string, []string) {
pkgs := make(map[string]*packageContext)
pkgNames := make(map[*packageContext]string)
@ -2027,7 +2030,13 @@ func (c *Context) makeUniquePackageNames(
pkgNames[pctx] = pctx.fullName
}
return pkgNames
// Create deps list from calls to PackageContext.AddNinjaFileDeps
deps := []string{}
for _, pkg := range pkgs {
deps = append(deps, pkg.ninjaFileDeps...)
}
return pkgNames, deps
}
func (c *Context) checkForVariableReferenceCycles(

View file

@ -67,15 +67,19 @@ type PackageContext interface {
StaticRule(name string, params RuleParams, argNames ...string) Rule
RuleFunc(name string, f func(interface{}) (RuleParams, error), argNames ...string) Rule
AddNinjaFileDeps(deps ...string)
getScope() *basicScope
}
type packageContext struct {
fullName string
shortName string
pkgPath string
scope *basicScope
fullName string
shortName string
pkgPath string
scope *basicScope
ninjaFileDeps []string
}
var _ PackageContext = &packageContext{}
func (p *packageContext) getScope() *basicScope {
@ -862,3 +866,7 @@ func (r *builtinRule) isArg(argName string) bool {
func (r *builtinRule) String() string {
return "<builtin>:" + r.name_
}
func (p *packageContext) AddNinjaFileDeps(deps ...string) {
p.ninjaFileDeps = append(p.ninjaFileDeps, deps...)
}