Documentation
¶
Overview ¶
Package build schedules and executes the build steps in a Ninja graph, tracking per-step state and delegating command execution and on-disk effects to a pluggable BuildBackend.
Index ¶
- type BuildBackend
- type BuildState
- type Engine
- type ExecResult
- type ExecutionCallback
- type Pressure
- type PressureItem
- type SchedMonitor
- type Scheduler
- type Step
- func (s *Step) ClearCommand()
- func (s *Step) CmdHash() uint64
- func (s *Step) Command() string
- func (s *Step) IsCommandLoaded() bool
- func (s *Step) IsConsole() bool
- func (s *Step) IsGenerator() bool
- func (s *Step) IsPhony() bool
- func (s *Step) IsPhonyOutput() bool
- func (s *Step) LoadCommand()
- func (s *Step) RSPContent() string
- func (s *Step) RSPFile() string
- func (s *Step) Restat() bool
- func (s *Step) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuildBackend ¶
type BuildBackend interface {
BuildInit(engine *Engine) error
IsClean(step *Step) (bool, error)
ApplyIfCached(step *Step) (bool, error)
IsRemotable(step *Step) bool
ExecRemote(ctx context.Context, step *Step) ExecResult
CreateDirs(step *Step) error
CreateRSP(step *Step) error
ExecLocal(ctx context.Context, step *Step) ExecResult
FinalizeStep(step *Step)
FinalizeBuild(err error) error
}
BuildBackend is implemented by execution backends used by the build engine.
type BuildState ¶
type BuildState int
BuildState identifies a step's position in the build state machine.
const ( StateInit BuildState = iota StateBlocked StateCleanCheck StateClean StateCacheCheck StateCached StateRemoteQueued StateRemoteRunning StateLocalQueued StateLocalRunning StateFailed StateDone MaxState )
BuildState values, in roughly the order steps move through them.
func (BuildState) IsFinal ¶
func (s BuildState) IsFinal() bool
IsFinal reports whether s is a terminal state.
func (BuildState) IsSuccess ¶
func (s BuildState) IsSuccess() bool
IsSuccess reports whether s is a terminal state that indicates success.
func (BuildState) String ¶
func (s BuildState) String() string
String returns a human-readable name for s.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine drives the build: it owns the build state machine, dispatches work to schedulers, and invokes the backend for clean checks, cache lookups, and command execution.
func NewEngine ¶
NewEngine constructs an Engine for graph using the backend and parameters stored on ctx.
func (*Engine) Build ¶
Build runs the configured backend and engine to completion, returning a non-nil error if any step failed.
func (*Engine) Pools ¶
Pools returns all build pools, including the implicit "default" pool sized according to the configured concurrency level.
func (*Engine) StateCounts ¶
func (e *Engine) StateCounts() map[BuildState]int64
StateCounts returns a snapshot of the number of steps in each BuildState.
type ExecResult ¶
ExecResult holds the outcome of running a build step.
type ExecutionCallback ¶
type ExecutionCallback func(s *Step)
ExecutionCallback is invoked by the scheduler to run a step.
type Pressure ¶
type Pressure struct {
Some PressureItem
Full PressureItem
}
Pressure holds the "some" and "full" lines reported by /proc/pressure/*.
type PressureItem ¶
PressureItem holds the four values reported on each line of a PSI file.
type SchedMonitor ¶
type SchedMonitor struct {
// contains filtered or unexported fields
}
SchedMonitor watches Linux pressure-stall information (PSI) and pauses scheduling when CPU, IO, or memory pressure exceeds the configured limits.
func (*SchedMonitor) MayI ¶
func (m *SchedMonitor) MayI() bool
MayI blocks while any monitored resource is above its configured threshold, returning true once it is safe to schedule a new job.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler dispatches ready steps to a fixed pool of worker goroutines.
func NewScheduler ¶
func NewScheduler(pool *ninja.Pool, maxCount int, callback ExecutionCallback, monitor *SchedMonitor) *Scheduler
NewScheduler returns a Scheduler bound to pool, sized for at most maxCount queued steps and using callback to execute them.
type Step ¶
type Step struct {
ID int
// Node is the graph node that this step is associated with.
Node *graph.Node
// Pool is the scheduler that owns this step once it has been queued locally.
Pool *Scheduler
// contains filtered or unexported fields
}
Step represents the build information for a given node.
func (*Step) ClearCommand ¶
func (s *Step) ClearCommand()
ClearCommand discards the command and response-file fields so they can be garbage collected after execution.
func (*Step) CmdHash ¶
CmdHash returns the hash of the command and response-file contents. It panics if no command is loaded.
func (*Step) IsCommandLoaded ¶
IsCommandLoaded reports whether LoadCommand has been called and ClearCommand has not.
func (*Step) IsGenerator ¶
IsGenerator reports whether s sets the generator attribute.
func (*Step) IsPhonyOutput ¶
IsPhonyOutput reports whether s declares phony_output.
func (*Step) LoadCommand ¶
func (s *Step) LoadCommand()
LoadCommand expands the command, response file, and command hash and stores them on s in preparation for execution.
func (*Step) RSPContent ¶
RSPContent returns the response-file contents, if any. It panics if no command is loaded.
func (*Step) RSPFile ¶
RSPFile returns the path of the response file, if any. It panics if no command is loaded.