diff options
author | Colin Cross <ccross@android.com> | 2019-02-25 18:07:44 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-02-26 10:15:40 -0800 |
commit | 9226d6c9f5c112afa678fbfdcb9528d82ef6b408 (patch) | |
tree | fb3a8e104fbd8e3fe4839267d0fda59a61258723 /context.go | |
parent | d444506bf6383850531162839d09d854a4bba6e1 (diff) | |
download | android_build_blueprint-9226d6c9f5c112afa678fbfdcb9528d82ef6b408.tar.gz android_build_blueprint-9226d6c9f5c112afa678fbfdcb9528d82ef6b408.tar.bz2 android_build_blueprint-9226d6c9f5c112afa678fbfdcb9528d82ef6b408.zip |
Allow Context to query Singletons
Add Context.Singletons and Context.SingletonName to allow primary
builders to query Singletons returned by all registered
SingletonFactories.
Change-Id: Iee85643dd47f7472e6bb5ae8004374bd6ea0419e
Diffstat (limited to 'context.go')
-rw-r--r-- | context.go | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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. |