Make *Context.Config return a Config instead of a interface{}
In Soong, a Config() method will always return a Config. Make
ModuleContext, SingletonContext, TopDownMutatorContext and
BottomUpMutatorContext's Config() methods explictly return
a Config to avoid having to type-assert everywhere. Overriding
the Config method requires duplicating the list of methods in
blueprint.BaseModuleContext and blueprint.BottomUpMutatorContext,
following the same pattern used by the other *Contexts.
Config() obsoletes the AConfig() method used in some places, which
will be cleaned up in the next patch.
Test: m checkbuild
Change-Id: Ibe21efde933959811d52443496967ab8ce71215e
diff --git a/android/singleton.go b/android/singleton.go
index f2f575f..87910fd 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -21,8 +21,7 @@
// SingletonContext
type SingletonContext interface {
- // TODO(ccross): make this return an android.Config
- Config() interface{}
+ Config() Config
ModuleName(module blueprint.Module) string
ModuleDir(module blueprint.Module) string
@@ -87,6 +86,10 @@
blueprint.SingletonContext
}
+func (s singletonContextAdaptor) Config() Config {
+ return s.SingletonContext.Config().(Config)
+}
+
func (s singletonContextAdaptor) Variable(pctx PackageContext, name, value string) {
s.SingletonContext.Variable(pctx.PackageContext, name, value)
}