Documentation
¶
Overview ¶
Package ninjautil provides utilitites for ninja.
Index ¶
- Variables
- func OpenNinjaLog(ctx context.Context) (*os.File, error)
- func WriteNinjaLogEntries(ctx context.Context, w io.Writer, start, end int64, mtime time.Time, ...)
- type DepsLog
- func (d *DepsLog) Close() error
- func (d *DepsLog) Get(ctx context.Context, output string) ([]string, time.Time, error)
- func (d *DepsLog) NeedsRecompact() bool
- func (d *DepsLog) Recompact(ctx context.Context) error
- func (d *DepsLog) Record(ctx context.Context, output string, mtime time.Time, deps []string) (bool, error)
- func (d *DepsLog) RecordedTargets() []string
- func (d *DepsLog) Reset()
- type Edge
- func (e *Edge) Binding(name string) string
- func (e *Edge) BindingBool(name string) bool
- func (e *Edge) Inputs() []*Node
- func (e *Edge) Ins() []*Node
- func (e *Edge) IsPhony() bool
- func (e *Edge) Outputs() []*Node
- func (e *Edge) Pool() *Pool
- func (e *Edge) Print(w io.Writer)
- func (e *Edge) RawBinding(name string) string
- func (e *Edge) RuleName() string
- func (e *Edge) TriggerInputs() []*Node
- func (e *Edge) UnescapedBinding(name string) string
- func (e *Edge) Validations() []*Node
- type ManifestParser
- type Node
- type Pool
- type State
- func (s *State) AddBinding(name, value string)
- func (s *State) AllNodes() []*Node
- func (s *State) DefaultNodes() ([]*Node, error)
- func (s *State) Filenames() []string
- func (s *State) LookupNode(id int) (*Node, bool)
- func (s *State) LookupNodeByPath(path string) (*Node, bool)
- func (s *State) LookupPool(poolName string) (*Pool, bool)
- func (s *State) NumNodes() int
- func (s *State) PhonyNodes() []*Node
- func (s *State) Pools() map[string]*Pool
- func (s *State) RootNodes() ([]*Node, error)
- func (s *State) SpellcheckTarget(t string) (string, error)
- func (s *State) Targets(args []string) ([]*Node, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNoDepsLog = errors.New("deps not found")
Functions ¶
func OpenNinjaLog ¶
OpenNinjaLog opens ninja log file or creates a new file with a version header.
func WriteNinjaLogEntries ¶
func WriteNinjaLogEntries(ctx context.Context, w io.Writer, start, end int64, mtime time.Time, outputs, command []string)
WriteNinjaLogEntries writes ninja log entries for a command. Note that the log entries are not compatible with Ninja, yet. TODO: b/298594790
- Implement MurmurHash64A as Ninja.
- Make mtime compatible on Windows.
Types ¶
type DepsLog ¶
type DepsLog struct {
// contains filtered or unexported fields
}
DepsLog is an in-memory representation of ninja's depslog. It supports creating new depslog files and reading existing depslog files, as well as adding new records to open depslog files. Format: https://github.com/ninja-build/ninja/blob/87111bff382655075f2577c591745a335f0103c7/src/deps_log.h
func NewDepsLog ¶
NewDepsLog reads or creates a new deps log. If there are read errors, returns a truncated deps log.
func (*DepsLog) NeedsRecompact ¶
NeedsRecompact reports whether it needs recompact or not.
func (*DepsLog) Recompact ¶
Recompact recompacts deps log file, i.e. rewrites the known log entries, throwing away old data.
func (*DepsLog) Record ¶
func (d *DepsLog) Record(ctx context.Context, output string, mtime time.Time, deps []string) (bool, error)
Record records deps log for the output. This will write to disk. Returns whether any deps were updated.
func (*DepsLog) RecordedTargets ¶
RecordedTargets returns a list of targets that have deps log.
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
Edge represents an edge (action) in build graph. TODO(b/267409605): Add tests for Edge methods.
func (*Edge) BindingBool ¶
BindingBool returns true if binding is defined in the edge.
func (*Edge) RawBinding ¶
RawBinding returns raw eval string of binding value in the edge.
func (*Edge) TriggerInputs ¶
TriggerInputs returns inputs nodes of the edge that would trigger the edge command. i.e. not including order_only inputs.
func (*Edge) UnescapedBinding ¶
UnescapedBinding returns binding value without shell escape.
func (*Edge) Validations ¶
Validations returns validations node of the edge.
type ManifestParser ¶
type ManifestParser struct {
// contains filtered or unexported fields
}
ManifestParser parses Ninja manifests. (i.e. .ninja files)
func NewManifestParser ¶
func NewManifestParser(state *State) *ManifestParser
NewManifestParser creates a new manifest parser.
func (*ManifestParser) Load ¶
func (p *ManifestParser) Load(ctx context.Context, fname string) error
Load loads the Ninja manifest given an fname.
func (*ManifestParser) SetWd ¶
func (p *ManifestParser) SetWd(wd string)
SetWd sets working directory to use for loading files.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a node (target file) in build graph.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
A Pool limits the number of concurrently running actions.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State contains all information in a scope about Ninja primitives relevant during execution time, such as pools, edges (= actions) and variable bindings.
func (*State) DefaultNodes ¶
DefaultNodes returns default nodes.
func (*State) Filenames ¶
Filenames returns files parsed by the parser (e.g. build.ninja and its subninja etc.)
func (*State) LookupNode ¶
LookupNode returns a node.
func (*State) LookupNodeByPath ¶
LookupNodeByPath returns a node.
func (*State) LookupPool ¶
LookupPool looks up pool.
func (*State) PhonyNodes ¶
PhonyNodes returns phony's output nodes.
func (*State) RootNodes ¶
RootNodes returns root nodes, that are nodes without output actions. (Hence can be considered final artifacts, i.e. other nodes will not use root nodes as inputs.)
func (*State) SpellcheckTarget ¶
SpellcheckTarget returns the most similar target from given target.