Merge changes Ib29ede45,I1b2bfdfb

* changes:
  Create LLNDK vendor variants when DeviceVndkVersion is not set
  Add a new SingletonModule type
This commit is contained in:
Colin Cross
2021-01-12 20:43:39 +00:00
committed by Gerrit Code Review
10 changed files with 385 additions and 50 deletions

View File

@@ -16,6 +16,7 @@ package android
import (
"fmt"
"reflect"
"github.com/google/blueprint"
)
@@ -26,6 +27,7 @@ type moduleType struct {
}
var moduleTypes []moduleType
var moduleTypesForDocs = map[string]reflect.Value{}
type singleton struct {
name string
@@ -72,6 +74,16 @@ func SingletonFactoryAdaptor(ctx *Context, factory SingletonFactory) blueprint.S
func RegisterModuleType(name string, factory ModuleFactory) {
moduleTypes = append(moduleTypes, moduleType{name, factory})
RegisterModuleTypeForDocs(name, reflect.ValueOf(factory))
}
// RegisterModuleTypeForDocs associates a module type name with a reflect.Value of the factory
// function that has documentation for the module type. It is normally called automatically
// by RegisterModuleType, but can be called manually after RegisterModuleType in order to
// override the factory method used for documentation, for example if the method passed to
// RegisterModuleType was a lambda.
func RegisterModuleTypeForDocs(name string, factory reflect.Value) {
moduleTypesForDocs[name] = factory
}
func RegisterSingletonType(name string, factory SingletonFactory) {
@@ -157,12 +169,17 @@ func ModuleTypeFactories() map[string]ModuleFactory {
return ret
}
func ModuleTypeFactoriesForDocs() map[string]reflect.Value {
return moduleTypesForDocs
}
// Interface for registering build components.
//
// Provided to allow registration of build components to be shared between the runtime
// and test environments.
type RegistrationContext interface {
RegisterModuleType(name string, factory ModuleFactory)
RegisterSingletonModuleType(name string, factory SingletonModuleFactory)
RegisterSingletonType(name string, factory SingletonFactory)
PreArchMutators(f RegisterMutatorFunc)
@@ -201,8 +218,9 @@ var InitRegistrationContext RegistrationContext = &initRegistrationContext{
var _ RegistrationContext = (*TestContext)(nil)
type initRegistrationContext struct {
moduleTypes map[string]ModuleFactory
singletonTypes map[string]SingletonFactory
moduleTypes map[string]ModuleFactory
singletonTypes map[string]SingletonFactory
moduleTypesForDocs map[string]reflect.Value
}
func (ctx *initRegistrationContext) RegisterModuleType(name string, factory ModuleFactory) {
@@ -211,6 +229,17 @@ func (ctx *initRegistrationContext) RegisterModuleType(name string, factory Modu
}
ctx.moduleTypes[name] = factory
RegisterModuleType(name, factory)
RegisterModuleTypeForDocs(name, reflect.ValueOf(factory))
}
func (ctx *initRegistrationContext) RegisterSingletonModuleType(name string, factory SingletonModuleFactory) {
s, m := SingletonModuleFactoryAdaptor(name, factory)
ctx.RegisterSingletonType(name, s)
ctx.RegisterModuleType(name, m)
// Overwrite moduleTypesForDocs with the original factory instead of the lambda returned by
// SingletonModuleFactoryAdaptor so that docs can find the module type documentation on the
// factory method.
RegisterModuleTypeForDocs(name, reflect.ValueOf(factory))
}
func (ctx *initRegistrationContext) RegisterSingletonType(name string, factory SingletonFactory) {