From c5db2df2130f805c45434e090012bcb84fb76291 Mon Sep 17 00:00:00 2001 From: Spandan Das Date: Thu, 8 Jun 2023 00:02:05 +0000 Subject: [PATCH] Helper function to register go module types in tests These two module types will be special-cased in bp2build generation logic in build/soong. To write bp2build tests, create a helper function to register these two module types Test: go build ./bootstrap Change-Id: If6abd8c8911a525bf6841b199d8ce204941d7bcb --- bootstrap/command.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bootstrap/command.go b/bootstrap/command.go index 08a0e43..05dbbc0 100644 --- a/bootstrap/command.go +++ b/bootstrap/command.go @@ -40,6 +40,12 @@ type Args struct { TraceFile string } +// RegisterGoModuleTypes adds module types to build tools written in golang +func RegisterGoModuleTypes(ctx *blueprint.Context) { + ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory()) + ctx.RegisterModuleType("blueprint_go_binary", newGoBinaryModuleFactory()) +} + // RunBlueprint emits `args.OutFile` (a Ninja file) and returns the list of // its dependencies. These can be written to a `${args.OutFile}.d` file // so that it is correctly rebuilt when needed in case Blueprint is itself @@ -89,9 +95,8 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf ctx.EndEvent("list_modules") ctx.RegisterBottomUpMutator("bootstrap_plugin_deps", pluginDeps) - ctx.RegisterModuleType("bootstrap_go_package", newGoPackageModuleFactory()) - ctx.RegisterModuleType("blueprint_go_binary", newGoBinaryModuleFactory()) ctx.RegisterSingletonType("bootstrap", newSingletonFactory(), false) + RegisterGoModuleTypes(ctx) blueprint.RegisterPackageIncludesModuleType(ctx) ctx.BeginEvent("parse_bp")