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
This commit is contained in:
Chris Parsons 2022-05-10 13:46:40 -04:00
parent c6d80893cb
commit 91f638f692
2 changed files with 13 additions and 0 deletions

View file

@ -113,6 +113,13 @@ func RunBlueprint(args Args, stopBefore StopBefore, ctx *blueprint.Context, conf
return ninjaDeps return ninjaDeps
} }
if ctx.BeforePrepareBuildActionsHook != nil {
err := ctx.BeforePrepareBuildActionsHook()
if err != nil {
fatalErrors([]error{err})
}
}
extraDeps, errs = ctx.PrepareBuildActions(config) extraDeps, errs = ctx.PrepareBuildActions(config)
if len(errs) > 0 { if len(errs) > 0 {
fatalErrors(errs) fatalErrors(errs)

View file

@ -75,6 +75,8 @@ type Context struct {
// Used for metrics-related event logging. // Used for metrics-related event logging.
EventHandler *metrics.EventHandler EventHandler *metrics.EventHandler
BeforePrepareBuildActionsHook func() error
moduleFactories map[string]ModuleFactory moduleFactories map[string]ModuleFactory
nameInterface NameInterface nameInterface NameInterface
moduleGroups []*moduleGroup moduleGroups []*moduleGroup
@ -4095,6 +4097,10 @@ func (c *Context) EndEvent(name string) {
c.EventHandler.End(name) c.EventHandler.End(name)
} }
func (c *Context) SetBeforePrepareBuildActionsHook(hookFn func() error) {
c.BeforePrepareBuildActionsHook = hookFn
}
func (c *Context) writeLocalBuildActions(nw *ninjaWriter, func (c *Context) writeLocalBuildActions(nw *ninjaWriter,
defs *localBuildActions) error { defs *localBuildActions) error {