aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Light <allight@google.com>2019-02-28 09:17:01 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-02-28 09:17:01 -0800
commit8cb211b3cee8bb4907636d25fc026024546e5325 (patch)
tree9d7560f581e9e4601c7f265c3cb5f8dc57552906
parentee10093dbb91cb9ca311a5091f4c23580b9a5e27 (diff)
parent2255c706d47ab499dbdb6ce1e90da222c4050ec5 (diff)
downloadandroid_build_blueprint-8cb211b3cee8bb4907636d25fc026024546e5325.tar.gz
android_build_blueprint-8cb211b3cee8bb4907636d25fc026024546e5325.tar.bz2
android_build_blueprint-8cb211b3cee8bb4907636d25fc026024546e5325.zip
Merge remote-tracking branch 'aosp/upstream' into master
am: 2255c706d4 Change-Id: I5c58efe3c8a7e085882b18a08647eea74f7b1f24
-rw-r--r--context.go20
-rw-r--r--module_ctx.go12
-rw-r--r--singleton_ctx.go7
3 files changed, 35 insertions, 4 deletions
diff --git a/context.go b/context.go
index 8d43c6c..3cd165a 100644
--- a/context.go
+++ b/context.go
@@ -2347,6 +2347,7 @@ func (c *Context) generateSingletonBuildActions(config interface{},
scope := newLocalScope(nil, singletonNamespacePrefix(info.name))
sctx := &singletonContext{
+ name: info.name,
context: c,
config: config,
scope: scope,
@@ -2977,6 +2978,25 @@ func (c *Context) VisitAllModuleVariants(module Module,
c.visitAllModuleVariants(c.moduleInfo[module], visit)
}
+// Singletons returns a list of all registered Singletons.
+func (c *Context) Singletons() []Singleton {
+ var ret []Singleton
+ for _, s := range c.singletonInfo {
+ ret = append(ret, s.singleton)
+ }
+ return ret
+}
+
+// SingletonName returns the name that the given singleton was registered with.
+func (c *Context) SingletonName(singleton Singleton) string {
+ for _, s := range c.singletonInfo {
+ if s.singleton == singleton {
+ return s.name
+ }
+ }
+ return ""
+}
+
// WriteBuildFile writes the Ninja manifeset text for the generated build
// actions to w. If this is called before PrepareBuildActions successfully
// completes then ErrBuildActionsNotReady is returned.
diff --git a/module_ctx.go b/module_ctx.go
index 62646f1..9dbf43d 100644
--- a/module_ctx.go
+++ b/module_ctx.go
@@ -338,16 +338,20 @@ func (m *baseModuleContext) GetDirectDep(name string) (Module, DependencyTag) {
// GetDirectDepWithTag returns the Module the direct dependency with the specified name, or nil if
// none exists. It panics if the dependency does not have the specified tag.
func (m *baseModuleContext) GetDirectDepWithTag(name string, tag DependencyTag) Module {
+ var deps []depInfo
for _, dep := range m.module.directDeps {
if dep.module.Name() == name {
- if dep.tag != tag {
- panic(fmt.Errorf("found dependency %q with tag %#v, expected tag %#v",
- dep.module, dep.tag, tag))
+ if dep.tag == tag {
+ return dep.module.logicModule
}
- return dep.module.logicModule
+ deps = append(deps, dep)
}
}
+ if len(deps) != 0 {
+ panic(fmt.Errorf("Unable to find dependency %q with requested tag %#v. Found: %#v", deps[0].module, tag, deps))
+ }
+
return nil
}
diff --git a/singleton_ctx.go b/singleton_ctx.go
index 1b044fa..5ca8ee6 100644
--- a/singleton_ctx.go
+++ b/singleton_ctx.go
@@ -27,6 +27,8 @@ type Singleton interface {
type SingletonContext interface {
Config() interface{}
+ Name() string
+
ModuleName(module Module) string
ModuleDir(module Module) string
ModuleSubDir(module Module) string
@@ -83,6 +85,7 @@ type SingletonContext interface {
var _ SingletonContext = (*singletonContext)(nil)
type singletonContext struct {
+ name string
context *Context
config interface{}
scope *localScope
@@ -98,6 +101,10 @@ func (s *singletonContext) Config() interface{} {
return s.config
}
+func (s *singletonContext) Name() string {
+ return s.name
+}
+
func (s *singletonContext) ModuleName(logicModule Module) string {
return s.context.ModuleName(logicModule)
}