Documentation
¶
Overview ¶
Package ninjabuild provides build steps by ninja.
Index ¶
- func Load(ctx context.Context, fname string, buildPath *build.Path) (*ninjautil.State, error)
- type Graph
- func (g *Graph) CleanDead(ctx context.Context) (int, int, error)
- func (g *Graph) ConfigProperties() map[string]string
- func (g *Graph) Filename() string
- func (g *Graph) Filenames() []string
- func (g *Graph) InputDeps(ctx context.Context) map[string][]string
- func (g *Graph) NumTargets() int
- func (g *Graph) Reload(ctx context.Context) error
- func (g *Graph) Reset(ctx context.Context) error
- func (g *Graph) SpellcheckTarget(t string) (string, error)
- func (g *Graph) StepDef(ctx context.Context, target build.Target, next build.StepDef) (build.StepDef, []build.Target, []build.Target, []build.Target, error)
- func (g *Graph) StepLimits(ctx context.Context) map[string]int
- func (g *Graph) TargetPath(ctx context.Context, target build.Target) (string, error)
- func (g *Graph) Targets(ctx context.Context, args ...string) ([]build.Target, error)
- func (g *Graph) Validations() []build.Target
- type IndirectInputs
- type StepConfig
- func (sc StepConfig) ExpandInputs(ctx context.Context, p *build.Path, hashFS *hashfs.HashFS, paths []string) []string
- func (sc StepConfig) Init(ctx context.Context) error
- func (sc StepConfig) Lookup(ctx context.Context, bpath *build.Path, edge *ninjautil.Edge) (StepRule, bool)
- func (sc StepConfig) UpdateFilegroups(ctx context.Context, filegroups map[string][]string) error
- type StepDef
- func (s *StepDef) ActionName() string
- func (s *StepDef) Args(ctx context.Context) []string
- func (s *StepDef) Binding(name string) string
- func (s *StepDef) CheckInputDeps(ctx context.Context, depInputs []string) (bool, error)
- func (s *StepDef) DepInputs(ctx context.Context) (func(yield func(string) bool), error)
- func (s *StepDef) Depfile(ctx context.Context) string
- func (s *StepDef) EnsureRule(ctx context.Context)
- func (s StepDef) ExpandedCaseSensitives(ctx context.Context, inputs []string) []string
- func (s *StepDef) ExpandedInputs(ctx context.Context) []string
- func (s *StepDef) Handle(ctx context.Context, cmd *execute.Cmd) error
- func (s *StepDef) Inputs(ctx context.Context) []string
- func (s *StepDef) IsPhony() bool
- func (s *StepDef) LocalOutputs(ctx context.Context) []string
- func (s *StepDef) Next() build.StepDef
- func (s *StepDef) Outputs(ctx context.Context) []string
- func (s *StepDef) Platform() map[string]string
- func (s *StepDef) Pure() bool
- func (s *StepDef) REProxyConfig() *execute.REProxyConfig
- func (s *StepDef) RecordDeps(ctx context.Context, output string, t time.Time, deps []string) (bool, error)
- func (s *StepDef) RemoteInputs() map[string]string
- func (s *StepDef) Rspfile(ctx context.Context) string
- func (s *StepDef) RuleFix(ctx context.Context, inadds, outadds []string) []byte
- func (s *StepDef) RuleName() string
- func (s *StepDef) String() string
- func (s *StepDef) ToolInputs(ctx context.Context) []string
- func (s *StepDef) TriggerInputs(ctx context.Context) []string
- type StepDeps
- type StepRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph holds build graph, i.e. all step defs described in build.ninja.
func NewGraph ¶
func NewGraph(ctx context.Context, fname string, nstate *ninjautil.State, config *buildconfig.Config, p *build.Path, hashFS *hashfs.HashFS, stepConfig *StepConfig, depsLog *ninjautil.DepsLog) *Graph
NewGraph creates new Graph from fname (usually "build.ninja") with stepConfig.
func (*Graph) CleanDead ¶
CleanDead cleans dead generated files, and returns number of removed files and number of last generated files.
func (*Graph) ConfigProperties ¶
ConfigProperties returns configuration properties.
func (*Graph) Filenames ¶
Filenames returns filenames of build manifest (all files loaded by build.ninja).
func (*Graph) NumTargets ¶
func (*Graph) SpellcheckTarget ¶
SpellcheckTarget finds closest target name from t.
func (*Graph) StepDef ¶
func (g *Graph) StepDef(ctx context.Context, target build.Target, next build.StepDef) (build.StepDef, []build.Target, []build.Target, []build.Target, error)
StepDef creates new StepDef to build target (exec-root relative), needed for next. top-level target will use nil for next. It returns a StepDef for the target and inputs/orderOnly/outputs targets.
func (*Graph) StepLimits ¶
StepLimits returns a map of maximum number of concurrent steps by pool name.
func (*Graph) TargetPath ¶
TargetPath returns exec-root relative path of the target.
func (*Graph) Targets ¶
Targets returns targets for ninja args. If args is not given, returns default build targets.
func (*Graph) Validations ¶
Validations returns validation targets detected by past StepDef calls.
type IndirectInputs ¶
type IndirectInputs struct { // glob pattern to use as action inputs from indirect inputs. Includes []string `json:"includes,omitempty"` }
IndirectInputs specifies what indirect inputs are used as action inputs.
type StepConfig ¶
type StepConfig struct { // Properties are config properties. // Used for resultstore if enabled. Properties map[string]string `json:"properties,omitempty"` // Platforms specifies platform properties. Platforms map[string]map[string]string `json:"platforms,omitempty"` // InputDeps specifies additional input files for a input file. // If key contains ":", it is considered as label, and // label itself is removed from expanded input list, but // label's values are added to expanded input list. InputDeps map[string][]string `json:"input_deps,omitempty"` // CaseSensitiveInputs lists case sensitive input filenames. // use these case sensitive filename. apply only for deps? CaseSensitiveInputs []string `json:"case_sensitive_inputs,omitempty"` // Rules lists step rules. Rules []*StepRule `json:"rules,omitempty"` // BadDeps specifies known targets with bad deps, // i.e. target has other generated targets not in direct/indirect // dependencies in depfile. // This target won't cause error with bad deps even with // `SISO_EXPERIMENTS=fail-on-bad-deps` to make it easy to // detect new bad deps. // key is output target known to have bad deps. // value is annotation (usually bug link). BadDeps map[string]string `json:"bad_deps,omitempty"` // Executables are files that need to have executable bit on Linux worker. // This field is used to upload Linux executables from Windows host. Executables []string `json:"executables,omitempty"` }
StepConfig is a config for ninja build manifest.
func NewStepConfig ¶
func NewStepConfig(ctx context.Context, config *buildconfig.Config, p *build.Path, hashFS *hashfs.HashFS, fname string) (*StepConfig, error)
NewStepConfig creates new *StepConfig and stores it in .siso_config and .siso_filegroups.
func (StepConfig) ExpandInputs ¶
func (sc StepConfig) ExpandInputs(ctx context.Context, p *build.Path, hashFS *hashfs.HashFS, paths []string) []string
ExpandInputs expands inputs, and returns paths separated by slash.
func (StepConfig) Init ¶
func (sc StepConfig) Init(ctx context.Context) error
Init initializes StepConfig.
func (StepConfig) Lookup ¶
func (sc StepConfig) Lookup(ctx context.Context, bpath *build.Path, edge *ninjautil.Edge) (StepRule, bool)
Lookup returns a step rule for the edge.
func (StepConfig) UpdateFilegroups ¶
UpdateFilegroups updates filegroups (input_deps) in the step config.
type StepDef ¶
type StepDef struct {
// contains filtered or unexported fields
}
StepDef is a ninja build step definition.
func (*StepDef) ActionName ¶
ActionName returns action name of the step.
func (*StepDef) Binding ¶
Binding returns a binding of the step.
Ninja bindings are explained in https://ninja-build.org/manual.html#ref_rule:~:text=bindings StepDef may overwrites Ninja bindings. e.g. deps, restat. StepDef also has custom bindings. e.g. remote_wrapper, remote_command.
func (*StepDef) CheckInputDeps ¶
CheckInputDeps checks dep can be found in its direct/indirect inputs. Returns true if it is unknown bad deps, false otherwise.
func (*StepDef) EnsureRule ¶
EnsureRule ensures siso rule for StepDef when it needs to run. It may not be called when skipped.
func (StepDef) ExpandedCaseSensitives ¶
ExpandedCaseSensitives returns expanded filenames if platform is case-sensitive.
func (*StepDef) ExpandedInputs ¶
ExpandedInputs returns expanded inputs
- Include indirect inputs.
- Add solibs for input (to execute the executable).
- Add the inputs from accumulate steps.
- Replace the inputs from replace steps.
- Exclude by ExcludeInputPatterns. etc
func (*StepDef) LocalOutputs ¶
LocalOutputs returns outputs of the step that should be written to local disk.
func (*StepDef) REProxyConfig ¶
func (s *StepDef) REProxyConfig() *execute.REProxyConfig
REProxyConfig returns configuration options for using reproxy.
func (*StepDef) RecordDeps ¶
func (s *StepDef) RecordDeps(ctx context.Context, output string, t time.Time, deps []string) (bool, error)
RecordDeps records deps of the step.
func (*StepDef) RemoteInputs ¶
RemoteInputs returns remote input mappings.
func (*StepDef) ToolInputs ¶
ToolInputs returns tool inputs of the step.
type StepDeps ¶
type StepDeps struct { Inputs []string `json:"inputs,omitempty"` Outputs []string `json:"outputs,omitempty"` Platform map[string]string `json:"platform,omitempty"` PlatformRef string `json:"platform_ref,omitempty"` }
StepDeps is a dependency of a step.
type StepRule ¶
type StepRule struct { // Name is a step rule label. required. // must be unique to identify the step rule to make it easy // to maintain rules. Name string `json:"name"` // ActionName is a regexp to match with rule name. ActionName string `json:"action,omitempty"` // ActionOuts matches with outputs of the step. ActionOuts []string `json:"action_outs,omitempty"` // CommandPreifx matches with command prefix of the step. // If argv[0] is absolute path outside of execroot, // it is compared with basename of argv[0]. // Note: it doesn't support space in argv[0] for such case. CommandPrefix string `json:"command_prefix,omitempty"` // Inputs are inputs to add to the step. Inputs []string `json:"inputs,omitempty"` // ExcludeInputPatterns are path glob patterns to exclude from the expanded inputs. ExcludeInputPatterns []string `json:"exclude_input_patterns,omitempty"` // IndirectInputs enables indirect (transitive, recursive) inputs // as action input of the step. IndirectInputs *IndirectInputs `json:"indirect_inputs,omitempty"` // Outputs are outputs to add to the step. Outputs []string `json:"outputs,omitempty"` // OutputsMap is a map to fix inputs/outputs per outputs. OutputsMap map[string]StepDeps `json:"outputs_map,omitempty"` // Restat means the step command will read its output // and may not write output when no update needed. // Output will be considered as clean if output mtime // is not changed by the command execution. // https://ninja-build.org/manual.html#ref_rule:~:text=appears%20in%20commands.-,restat,-if%20present%2C%20causes Restat bool `json:"restat,omitempty"` // RestatContent means output will be considered as clean // if output content is the same as before. RestatContent bool `json:"restat_content,omitempty"` // PlatformRef is reference to platform properties. PlatformRef string `json:"platform_ref,omitempty"` // Platform is platform properties. // TODO: siso: prefix will not send to remote backend. Platform map[string]string `json:"platform,omitempty"` // Remote marks the step is remote executable. Remote bool `json:"remote,omitempty"` // RemoteWrapper is a wrapper used in remote execution. // TODO: put RemoteWrapper in Platform["siso:remote_wrapper"] RemoteWrapper string `json:"remote_wrapper,omitempty"` // RemoteCommand is a command used in the first argument. RemoteCommand string `json:"remote_command,omitempty"` // RemoteInputs is a map for remote execution. // path in remote action -> local path RemoteInputs map[string]string `json:"remote_inputs,omitempty"` // InputRootAbsolutePath indicates the step requires absolute path for the input root, i.e. not relocatable. InputRootAbsolutePath bool `json:"input_root_absolute_path,omitempty"` // CanonicalizeDir indicates the step can canonicalize the working dir. CanonicalizeDir bool `json:"canonicalize_dir,omitempty"` // UseSystemInput indicates to allow extra inputs outside exec root. UseSystemInput bool `json:"use_system_input,omitempty"` // UseRemoteExecWrapper indicates the command uses remote exec wrapper // (e.g. gomacc, rewrapper), so // - no need to run `clang -M` // - run locally but more parallelism // - no file access trace UseRemoteExecWrapper bool `json:"use_remote_exec_wrapper,omitempty"` // REProxyConfig specifies configuration options for using reproxy. REProxyConfig *execute.REProxyConfig `json:"reproxy_config,omitempty"` // Timeout specifies time duration for the remote execution call of the step. // Timeout*2 will be set to remote action's timeout to // expect cache hit for long command execution. Timeout string `json:"timeout,omitempty"` // duration format // Handler name. Handler string `json:"handler,omitempty"` // Deps specifies deps type. // // deps="gcc": Use `gcc -M` or deps log. // deps="msvc": Use `clang-cl /showIncludes` or deps log. // deps="depfile": Use `depfile` if `depfile` is specified. // deps="none": ignore deps of the step. Deps string `json:"deps,omitempty"` // NoFastDeps disables fast-deps. NoFastDeps bool `json:"no_fast_deps,omitempty"` // OutputLocal indicates to force to write output files to local disk // for subsequent steps. // TODO: better to have `require_local_inputs`=[<globs>] to reduce unnecessary downloads? OutputLocal bool `json:"output_local,omitempty"` // IgnoreExtraInputPattern specifies regexp to ignore extra inputs. // ignore extra input detected by strace if it matches with this pattern // e.g. cache file IgnoreExtraInputPattern string `json:"ignore_extra_input_pattern,omitempty"` // IgnoreExtraOutputPattern specifies regexp to ignore extra outputs. // ignore extra output detected by strace if it matches with this pattern // e.g. cache file IgnoreExtraOutputPattern string `json:"ignore_extra_output_pattern,omitempty"` // Impure marks the step is impure, i.e. allow extra inputs/outputs. // Better to use above options if possible. // Impure disables file access trace. Impure bool `json:"impure,omitempty"` // Replace replaces the outputs, when used by other step, // to the inputs of the step. // e.g. stamp. Replace bool `json:"replace,omitempty"` // Accumulate accumulates the inputs of the step to // the outputs, when used by other step. // e.g. thin archive. Accumulate bool `json:"accumulate,omitempty"` // Debug indicates to log debug information for the step. Debug bool `json:"debug,omitempty"` // contains filtered or unexported fields }
StepRule is a rule for step.