Merge "Implement code-generation step for bp2build."

This commit is contained in:
Treehugger Robot
2021-01-19 17:41:59 +00:00
committed by Gerrit Code Review
7 changed files with 68 additions and 135 deletions

View File

@@ -37,9 +37,6 @@ type singleton struct {
var singletons []singleton
var preSingletons []singleton
var bazelConverterSingletons []singleton
var bazelConverterPreSingletons []singleton
type mutator struct {
name string
bottomUpMutator blueprint.BottomUpMutator
@@ -94,14 +91,6 @@ func RegisterPreSingletonType(name string, factory SingletonFactory) {
preSingletons = append(preSingletons, singleton{name, factory})
}
func RegisterBazelConverterSingletonType(name string, factory SingletonFactory) {
bazelConverterSingletons = append(bazelConverterSingletons, singleton{name, factory})
}
func RegisterBazelConverterPreSingletonType(name string, factory SingletonFactory) {
bazelConverterPreSingletons = append(bazelConverterPreSingletons, singleton{name, factory})
}
type Context struct {
*blueprint.Context
config Config
@@ -117,21 +106,20 @@ func NewContext(config Config) *Context {
// singletons, module types and mutators to register for converting Blueprint
// files to semantically equivalent BUILD files.
func (ctx *Context) RegisterForBazelConversion() {
for _, t := range bazelConverterPreSingletons {
ctx.RegisterPreSingletonType(t.name, SingletonFactoryAdaptor(ctx, t.factory))
}
for _, t := range moduleTypes {
ctx.RegisterModuleType(t.name, ModuleFactoryAdaptor(t.factory))
}
for _, t := range bazelConverterSingletons {
// Required for SingletonModule types, even though we are not using them.
for _, t := range singletons {
ctx.RegisterSingletonType(t.name, SingletonFactoryAdaptor(ctx, t.factory))
}
registerMutatorsForBazelConversion(ctx.Context)
}
// Register the pipeline of singletons, module types, and mutators for
// generating build.ninja and other files for Kati, from Android.bp files.
func (ctx *Context) Register() {
for _, t := range preSingletons {
ctx.RegisterPreSingletonType(t.name, SingletonFactoryAdaptor(ctx, t.factory))