From 75e139b50ec439c31ffcde4214f8afec6c73621f Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Mon, 28 Nov 2022 20:12:03 +0000 Subject: [PATCH] Register singletons in api_bp2build Singleton modules are not used in this workspace (they do not implement `ConvertWithApiBp2build`). However, we still need to add them since there is a check in `SingletonModuleFactoryAdaptor` that depends on the singletons being registered. We do this for bp2build as well (see `RegisterForBazelConversion`) This was probably always an issue in api_bp2build, but became incompatible as a side-effect of the refactoring in aosp/2287719 that removed ctx.Register() from the newContext function. Test: m api_bp2build --skip-soong-tests Change-Id: I9ba1df2cc1e8ec916635e5280c66f8df68d7e79b --- android/register.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/android/register.go b/android/register.go index 6c69cc5fd..72f8af4a0 100644 --- a/android/register.go +++ b/android/register.go @@ -164,29 +164,30 @@ func NewContext(config Config) *Context { return ctx } -// RegisterForBazelConversion registers an alternate shadow pipeline of -// singletons, module types and mutators to register for converting Blueprint -// files to semantically equivalent BUILD files. -func (ctx *Context) RegisterForBazelConversion() { +// Helper function to register the module types used in bp2build and +// api_bp2build. +func registerModuleTypes(ctx *Context) { for _, t := range moduleTypes { t.register(ctx) } - // Required for SingletonModule types, even though we are not using them. for _, t := range singletons { t.register(ctx) } +} +// RegisterForBazelConversion registers an alternate shadow pipeline of +// singletons, module types and mutators to register for converting Blueprint +// files to semantically equivalent BUILD files. +func (ctx *Context) RegisterForBazelConversion() { + registerModuleTypes(ctx) RegisterMutatorsForBazelConversion(ctx, bp2buildPreArchMutators) } // RegisterForApiBazelConversion is similar to RegisterForBazelConversion except that // it only generates API targets in the generated workspace func (ctx *Context) RegisterForApiBazelConversion() { - for _, t := range moduleTypes { - t.register(ctx) - } - + registerModuleTypes(ctx) RegisterMutatorsForApiBazelConversion(ctx, bp2buildPreArchMutators) }