Remove pre singletons
They're no longer used. Test: m nothing --no-skip-soong-tests Change-Id: I8984164cfc1a062c428ea7f1a4dd5b8940bee84b
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"android/soong/shared"
|
"android/soong/shared"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -66,9 +67,6 @@ var moduleTypesForDocs = map[string]reflect.Value{}
|
|||||||
var moduleTypeByFactory = map[reflect.Value]string{}
|
var moduleTypeByFactory = map[reflect.Value]string{}
|
||||||
|
|
||||||
type singleton struct {
|
type singleton struct {
|
||||||
// True if this should be registered as a pre-singleton, false otherwise.
|
|
||||||
pre bool
|
|
||||||
|
|
||||||
// True if this should be registered as a parallel singleton.
|
// True if this should be registered as a parallel singleton.
|
||||||
parallel bool
|
parallel bool
|
||||||
|
|
||||||
@@ -77,11 +75,7 @@ type singleton struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newSingleton(name string, factory SingletonFactory, parallel bool) singleton {
|
func newSingleton(name string, factory SingletonFactory, parallel bool) singleton {
|
||||||
return singleton{pre: false, parallel: parallel, name: name, factory: factory}
|
return singleton{parallel: parallel, name: name, factory: factory}
|
||||||
}
|
|
||||||
|
|
||||||
func newPreSingleton(name string, factory SingletonFactory) singleton {
|
|
||||||
return singleton{pre: true, parallel: false, name: name, factory: factory}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s singleton) componentName() string {
|
func (s singleton) componentName() string {
|
||||||
@@ -90,17 +84,12 @@ func (s singleton) componentName() string {
|
|||||||
|
|
||||||
func (s singleton) register(ctx *Context) {
|
func (s singleton) register(ctx *Context) {
|
||||||
adaptor := SingletonFactoryAdaptor(ctx, s.factory)
|
adaptor := SingletonFactoryAdaptor(ctx, s.factory)
|
||||||
if s.pre {
|
ctx.RegisterSingletonType(s.name, adaptor, s.parallel)
|
||||||
ctx.RegisterPreSingletonType(s.name, adaptor)
|
|
||||||
} else {
|
|
||||||
ctx.RegisterSingletonType(s.name, adaptor, s.parallel)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ sortableComponent = singleton{}
|
var _ sortableComponent = singleton{}
|
||||||
|
|
||||||
var singletons sortableComponents
|
var singletons sortableComponents
|
||||||
var preSingletons sortableComponents
|
|
||||||
|
|
||||||
type mutator struct {
|
type mutator struct {
|
||||||
name string
|
name string
|
||||||
@@ -164,10 +153,6 @@ func RegisterParallelSingletonType(name string, factory SingletonFactory) {
|
|||||||
registerSingletonType(name, factory, true)
|
registerSingletonType(name, factory, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterPreSingletonType(name string, factory SingletonFactory) {
|
|
||||||
preSingletons = append(preSingletons, newPreSingleton(name, factory))
|
|
||||||
}
|
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
*blueprint.Context
|
*blueprint.Context
|
||||||
config Config
|
config Config
|
||||||
@@ -253,8 +238,6 @@ func (c *Context) RegisterExistingBazelTargets(topDir string, existingBazelFiles
|
|||||||
// Register the pipeline of singletons, module types, and mutators for
|
// Register the pipeline of singletons, module types, and mutators for
|
||||||
// generating build.ninja and other files for Kati, from Android.bp files.
|
// generating build.ninja and other files for Kati, from Android.bp files.
|
||||||
func (ctx *Context) Register() {
|
func (ctx *Context) Register() {
|
||||||
preSingletons.registerAll(ctx)
|
|
||||||
|
|
||||||
for _, t := range moduleTypes {
|
for _, t := range moduleTypes {
|
||||||
t.register(ctx)
|
t.register(ctx)
|
||||||
}
|
}
|
||||||
@@ -277,17 +260,17 @@ func (ctx *Context) registerSingletonMakeVarsProvider(makevars SingletonMakeVars
|
|||||||
func collateGloballyRegisteredSingletons() sortableComponents {
|
func collateGloballyRegisteredSingletons() sortableComponents {
|
||||||
allSingletons := append(sortableComponents(nil), singletons...)
|
allSingletons := append(sortableComponents(nil), singletons...)
|
||||||
allSingletons = append(allSingletons,
|
allSingletons = append(allSingletons,
|
||||||
singleton{pre: false, parallel: true, name: "bazeldeps", factory: BazelSingleton},
|
singleton{parallel: true, name: "bazeldeps", factory: BazelSingleton},
|
||||||
|
|
||||||
// Register phony just before makevars so it can write out its phony rules as Make rules
|
// Register phony just before makevars so it can write out its phony rules as Make rules
|
||||||
singleton{pre: false, parallel: false, name: "phony", factory: phonySingletonFactory},
|
singleton{parallel: false, name: "phony", factory: phonySingletonFactory},
|
||||||
|
|
||||||
// Register makevars after other singletons so they can export values through makevars
|
// Register makevars after other singletons so they can export values through makevars
|
||||||
singleton{pre: false, parallel: false, name: "makevars", factory: makeVarsSingletonFunc},
|
singleton{parallel: false, name: "makevars", factory: makeVarsSingletonFunc},
|
||||||
|
|
||||||
// Register env and ninjadeps last so that they can track all used environment variables and
|
// Register env and ninjadeps last so that they can track all used environment variables and
|
||||||
// Ninja file dependencies stored in the config.
|
// Ninja file dependencies stored in the config.
|
||||||
singleton{pre: false, parallel: false, name: "ninjadeps", factory: ninjaDepsSingletonFactory},
|
singleton{parallel: false, name: "ninjadeps", factory: ninjaDepsSingletonFactory},
|
||||||
)
|
)
|
||||||
|
|
||||||
return allSingletons
|
return allSingletons
|
||||||
@@ -317,7 +300,6 @@ type RegistrationContext interface {
|
|||||||
RegisterModuleType(name string, factory ModuleFactory)
|
RegisterModuleType(name string, factory ModuleFactory)
|
||||||
RegisterSingletonModuleType(name string, factory SingletonModuleFactory)
|
RegisterSingletonModuleType(name string, factory SingletonModuleFactory)
|
||||||
RegisterParallelSingletonModuleType(name string, factory SingletonModuleFactory)
|
RegisterParallelSingletonModuleType(name string, factory SingletonModuleFactory)
|
||||||
RegisterPreSingletonType(name string, factory SingletonFactory)
|
|
||||||
RegisterParallelSingletonType(name string, factory SingletonFactory)
|
RegisterParallelSingletonType(name string, factory SingletonFactory)
|
||||||
RegisterSingletonType(name string, factory SingletonFactory)
|
RegisterSingletonType(name string, factory SingletonFactory)
|
||||||
PreArchMutators(f RegisterMutatorFunc)
|
PreArchMutators(f RegisterMutatorFunc)
|
||||||
@@ -349,9 +331,8 @@ type RegistrationContext interface {
|
|||||||
// ctx := android.NewTestContext(config)
|
// ctx := android.NewTestContext(config)
|
||||||
// RegisterBuildComponents(ctx)
|
// RegisterBuildComponents(ctx)
|
||||||
var InitRegistrationContext RegistrationContext = &initRegistrationContext{
|
var InitRegistrationContext RegistrationContext = &initRegistrationContext{
|
||||||
moduleTypes: make(map[string]ModuleFactory),
|
moduleTypes: make(map[string]ModuleFactory),
|
||||||
singletonTypes: make(map[string]SingletonFactory),
|
singletonTypes: make(map[string]SingletonFactory),
|
||||||
preSingletonTypes: make(map[string]SingletonFactory),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the TestContext implements RegistrationContext.
|
// Make sure the TestContext implements RegistrationContext.
|
||||||
@@ -360,7 +341,6 @@ var _ RegistrationContext = (*TestContext)(nil)
|
|||||||
type initRegistrationContext struct {
|
type initRegistrationContext struct {
|
||||||
moduleTypes map[string]ModuleFactory
|
moduleTypes map[string]ModuleFactory
|
||||||
singletonTypes map[string]SingletonFactory
|
singletonTypes map[string]SingletonFactory
|
||||||
preSingletonTypes map[string]SingletonFactory
|
|
||||||
moduleTypesForDocs map[string]reflect.Value
|
moduleTypesForDocs map[string]reflect.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,14 +386,6 @@ func (ctx *initRegistrationContext) RegisterParallelSingletonType(name string, f
|
|||||||
ctx.registerSingletonType(name, factory, true)
|
ctx.registerSingletonType(name, factory, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *initRegistrationContext) RegisterPreSingletonType(name string, factory SingletonFactory) {
|
|
||||||
if _, present := ctx.preSingletonTypes[name]; present {
|
|
||||||
panic(fmt.Sprintf("pre singleton type %q is already registered", name))
|
|
||||||
}
|
|
||||||
ctx.preSingletonTypes[name] = factory
|
|
||||||
RegisterPreSingletonType(name, factory)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ctx *initRegistrationContext) PreArchMutators(f RegisterMutatorFunc) {
|
func (ctx *initRegistrationContext) PreArchMutators(f RegisterMutatorFunc) {
|
||||||
PreArchMutators(f)
|
PreArchMutators(f)
|
||||||
}
|
}
|
||||||
|
@@ -186,12 +186,12 @@ type TestContext struct {
|
|||||||
bp2buildPreArch, bp2buildMutators []RegisterMutatorFunc
|
bp2buildPreArch, bp2buildMutators []RegisterMutatorFunc
|
||||||
NameResolver *NameResolver
|
NameResolver *NameResolver
|
||||||
|
|
||||||
// The list of pre-singletons and singletons registered for the test.
|
// The list of singletons registered for the test.
|
||||||
preSingletons, singletons sortableComponents
|
singletons sortableComponents
|
||||||
|
|
||||||
// The order in which the pre-singletons, mutators and singletons will be run in this test
|
// The order in which the mutators and singletons will be run in this test
|
||||||
// context; for debugging.
|
// context; for debugging.
|
||||||
preSingletonOrder, mutatorOrder, singletonOrder []string
|
mutatorOrder, singletonOrder []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *TestContext) PreArchMutators(f RegisterMutatorFunc) {
|
func (ctx *TestContext) PreArchMutators(f RegisterMutatorFunc) {
|
||||||
@@ -397,9 +397,6 @@ type registrationSorter struct {
|
|||||||
// Used to ensure that this is only created once.
|
// Used to ensure that this is only created once.
|
||||||
once sync.Once
|
once sync.Once
|
||||||
|
|
||||||
// The order of pre-singletons
|
|
||||||
preSingletonOrder registeredComponentOrder
|
|
||||||
|
|
||||||
// The order of mutators
|
// The order of mutators
|
||||||
mutatorOrder registeredComponentOrder
|
mutatorOrder registeredComponentOrder
|
||||||
|
|
||||||
@@ -412,9 +409,6 @@ type registrationSorter struct {
|
|||||||
// Only the first call has any effect.
|
// Only the first call has any effect.
|
||||||
func (s *registrationSorter) populate() {
|
func (s *registrationSorter) populate() {
|
||||||
s.once.Do(func() {
|
s.once.Do(func() {
|
||||||
// Create an ordering from the globally registered pre-singletons.
|
|
||||||
s.preSingletonOrder = registeredComponentOrderFromExistingOrder("pre-singleton", preSingletons)
|
|
||||||
|
|
||||||
// Created an ordering from the globally registered mutators.
|
// Created an ordering from the globally registered mutators.
|
||||||
globallyRegisteredMutators := collateGloballyRegisteredMutators()
|
globallyRegisteredMutators := collateGloballyRegisteredMutators()
|
||||||
s.mutatorOrder = registeredComponentOrderFromExistingOrder("mutator", globallyRegisteredMutators)
|
s.mutatorOrder = registeredComponentOrderFromExistingOrder("mutator", globallyRegisteredMutators)
|
||||||
@@ -441,11 +435,6 @@ func globallyRegisteredComponentsOrder() *registrationSorter {
|
|||||||
func (ctx *TestContext) Register() {
|
func (ctx *TestContext) Register() {
|
||||||
globalOrder := globallyRegisteredComponentsOrder()
|
globalOrder := globallyRegisteredComponentsOrder()
|
||||||
|
|
||||||
// Ensure that the pre-singletons used in the test are in the same order as they are used at
|
|
||||||
// runtime.
|
|
||||||
globalOrder.preSingletonOrder.enforceOrdering(ctx.preSingletons)
|
|
||||||
ctx.preSingletons.registerAll(ctx.Context)
|
|
||||||
|
|
||||||
mutators := collateRegisteredMutators(ctx.preArch, ctx.preDeps, ctx.postDeps, ctx.finalDeps)
|
mutators := collateRegisteredMutators(ctx.preArch, ctx.preDeps, ctx.postDeps, ctx.finalDeps)
|
||||||
// Ensure that the mutators used in the test are in the same order as they are used at runtime.
|
// Ensure that the mutators used in the test are in the same order as they are used at runtime.
|
||||||
globalOrder.mutatorOrder.enforceOrdering(mutators)
|
globalOrder.mutatorOrder.enforceOrdering(mutators)
|
||||||
@@ -456,7 +445,6 @@ func (ctx *TestContext) Register() {
|
|||||||
ctx.singletons.registerAll(ctx.Context)
|
ctx.singletons.registerAll(ctx.Context)
|
||||||
|
|
||||||
// Save the sorted components order away to make them easy to access while debugging.
|
// Save the sorted components order away to make them easy to access while debugging.
|
||||||
ctx.preSingletonOrder = componentsToNames(preSingletons)
|
|
||||||
ctx.mutatorOrder = componentsToNames(mutators)
|
ctx.mutatorOrder = componentsToNames(mutators)
|
||||||
ctx.singletonOrder = componentsToNames(singletons)
|
ctx.singletonOrder = componentsToNames(singletons)
|
||||||
}
|
}
|
||||||
@@ -503,10 +491,6 @@ func (ctx *TestContext) RegisterParallelSingletonType(name string, factory Singl
|
|||||||
ctx.singletons = append(ctx.singletons, newSingleton(name, factory, true))
|
ctx.singletons = append(ctx.singletons, newSingleton(name, factory, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *TestContext) RegisterPreSingletonType(name string, factory SingletonFactory) {
|
|
||||||
ctx.preSingletons = append(ctx.preSingletons, newPreSingleton(name, factory))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ModuleVariantForTests selects a specific variant of the module with the given
|
// ModuleVariantForTests selects a specific variant of the module with the given
|
||||||
// name by matching the variations map against the variations of each module
|
// name by matching the variations map against the variations of each module
|
||||||
// variant. A module variant matches the map if every variation that exists in
|
// variant. A module variant matches the map if every variation that exists in
|
||||||
|
Reference in New Issue
Block a user