Wrap PackageContext and SingletonContext

Wrap blueprint.PackageContext so that the *Func methods can provide
an android.Config instead of an interface{}.  The modified signatures
means that every method in ModuleContext and SingletonContext
that takes a blueprint.PackageContext now needs to be wrapped to
take an android.PackageContext.

SingletonContext wasn't previously wrapped at all, but as long
as it is, wrap everything like ModuleContext does.  This requires
updating every Singleton to use the android-specific methods.

Test: builds, all Soong tests pass
Change-Id: I4f22085ebca7def6c5cde49e8210b59d994ba625
This commit is contained in:
Colin Cross
2017-11-28 17:34:01 -08:00
parent f2a56f0e0d
commit 0875c52de7
21 changed files with 479 additions and 243 deletions

View File

@@ -44,7 +44,7 @@ var mutators []*mutator
type ModuleFactory func() Module
// ModuleFactoryAdaptor Wraps a ModuleFactory into a blueprint.ModuleFactory by converting an Module
// ModuleFactoryAdaptor wraps a ModuleFactory into a blueprint.ModuleFactory by converting a Module
// into a blueprint.Module and a list of property structs
func ModuleFactoryAdaptor(factory ModuleFactory) blueprint.ModuleFactory {
return func() (blueprint.Module, []interface{}) {
@@ -53,16 +53,27 @@ func ModuleFactoryAdaptor(factory ModuleFactory) blueprint.ModuleFactory {
}
}
type SingletonFactory func() Singleton
// SingletonFactoryAdaptor wraps a SingletonFactory into a blueprint.SingletonFactory by converting
// a Singleton into a blueprint.Singleton
func SingletonFactoryAdaptor(factory SingletonFactory) blueprint.SingletonFactory {
return func() blueprint.Singleton {
singleton := factory()
return singletonAdaptor{singleton}
}
}
func RegisterModuleType(name string, factory ModuleFactory) {
moduleTypes = append(moduleTypes, moduleType{name, ModuleFactoryAdaptor(factory)})
}
func RegisterSingletonType(name string, factory blueprint.SingletonFactory) {
singletons = append(singletons, singleton{name, factory})
func RegisterSingletonType(name string, factory SingletonFactory) {
singletons = append(singletons, singleton{name, SingletonFactoryAdaptor(factory)})
}
func RegisterPreSingletonType(name string, factory blueprint.SingletonFactory) {
preSingletons = append(preSingletons, singleton{name, factory})
func RegisterPreSingletonType(name string, factory SingletonFactory) {
preSingletons = append(preSingletons, singleton{name, SingletonFactoryAdaptor(factory)})
}
type Context struct {