From 91f638f69203d215de7a03174e6974970f621bc6 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Tue, 10 May 2022 13:46:40 -0400 Subject: [PATCH] Support pre-build-action hook in blueprint This allows for a bazel-invocation hook in mixed builds, which allows for mixed builds to take place in only a single pass, greatly improving its performance and complexity. Test: Conjunction with build/soong CL Change-Id: If89fb56830b4eb06d3263d6ca6da7b285e7ba315 --- bootstrap/command.go | 7 +++++++ context.go | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/bootstrap/command.go b/bootstrap/command.go index 8c045b4..3342bbe 100644 --- a/bootstrap/command.go +++ b/bootstrap/command.go @@ -113,6 +113,13 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf return ninjaDeps } + if ctx.BeforePrepareBuildActionsHook != nil { + err := ctx.BeforePrepareBuildActionsHook() + if err != nil { + fatalErrors([]error{err}) + } + } + extraDeps, errs = ctx.PrepareBuildActions(config) if len(errs) > 0 { fatalErrors(errs) diff --git a/context.go b/context.go index 47b31ae..5d7ba32 100644 --- a/context.go +++ b/context.go @@ -75,6 +75,8 @@ type Context struct { // Used for metrics-related event logging. EventHandler *metrics.EventHandler + BeforePrepareBuildActionsHook func() error + moduleFactories map[string]ModuleFactory nameInterface NameInterface moduleGroups []*moduleGroup @@ -4095,6 +4097,10 @@ func (c *Context) EndEvent(name string) { c.EventHandler.End(name) } +func (c *Context) SetBeforePrepareBuildActionsHook(hookFn func() error) { + c.BeforePrepareBuildActionsHook = hookFn +} + func (c *Context) writeLocalBuildActions(nw *ninjaWriter, defs *localBuildActions) error {