Pass ModulePath to NameInterface

To allow it to validate that the filename equals Android.bp

Bug: 65683273
Test: m -j nothing # which runs tests
Change-Id: I171dddd102590df558053b615d39c75c00b6ac6e
This commit is contained in:
Jeff Gaston 2017-11-30 17:30:42 -08:00
parent 656870fbca
commit 3c8c3346d2
3 changed files with 15 additions and 9 deletions

View file

@ -1284,7 +1284,7 @@ func (c *Context) addModule(module *moduleInfo) []error {
}
module.group = group
namespace, errs := c.nameInterface.NewModule(
&moduleCreationContextImpl{c.ModuleDir(module.logicModule)},
&namespaceContextImpl{c.ModulePath(module.logicModule)},
ModuleGroup{moduleGroup: group},
module.logicModule)
if len(errs) > 0 {
@ -2733,9 +2733,13 @@ func (c *Context) ModuleName(logicModule Module) string {
return module.Name()
}
func (c *Context) ModuleDir(logicModule Module) string {
func (c *Context) ModulePath(logicModule Module) string {
module := c.moduleInfo[logicModule]
return filepath.Dir(module.relBlueprintsFile)
return module.relBlueprintsFile
}
func (c *Context) ModuleDir(logicModule Module) string {
return filepath.Dir(c.ModulePath(logicModule))
}
func (c *Context) ModuleSubDir(logicModule Module) string {

View file

@ -272,7 +272,9 @@ func (d *baseModuleContext) Fs() pathtools.FileSystem {
}
func (d *baseModuleContext) Namespace() Namespace {
return d.context.nameInterface.GetNamespace(d)
nsctx := &namespaceContextImpl{d.context.ModulePath(d.module.logicModule)}
return d.context.nameInterface.GetNamespace(nsctx)
}
var _ ModuleContext = (*moduleContext)(nil)

View file

@ -74,15 +74,15 @@ type NameInterface interface {
// A NamespaceContext stores the information given to a NameInterface to enable the NameInterface
// to choose the namespace for any given module
type NamespaceContext interface {
ModuleDir() string
ModulePath() string
}
type moduleCreationContextImpl struct {
moduleDir string
type namespaceContextImpl struct {
modulePath string
}
func (ctx *moduleCreationContextImpl) ModuleDir() string {
return ctx.moduleDir
func (ctx *namespaceContextImpl) ModulePath() string {
return ctx.modulePath
}
// a SimpleNameInterface just stores all modules in a map based on name