ninja – Ninja Buildcloth Syntax Layer
ninja provides the main interface for managing Makefile output, and is
a thin wrapper around the basic functionality for BuildCloth().
- 
class ninja.NinjaFileCloth(indent=2, ninjafile=None)
- NinjaFileCloth wraps BuildCloth() to provide
an interface for specifying Ninja-based build systems. - 
- 
add_rule(name, command, description, depfile=None, generator=False, restat=False, rsp=None, pool=None, block='_all')
- 
| Parameters: | 
name (string) – Required. Holds the name of the
rule. build() targets
must refer to a rules using this name.command (list) – Required. The shell command or commands. Must
present commands as a list, even if there is only one item.description (string) – Required. A description of the command’s
operation, to be included in Ninja’s output. | 
|---|
 
 - 
- ;param string depfile: Optional; defaults to None. Specify a
- Makefile with dependencies, such as what gcc
or other tool chain might generate.
- ;param boolean generator: Optional; defaults to False. Specifies a
- special generator rule, signifiying that this
rule generates Ninja files.
- ;param boolean restat: Optional; defaults to False. When True
- specifies a rule where Ninja will check the
mtime of the file and remove dependencies of
this target if the file didn’t change.
- ;param tuple rsp: Optional; defaults to disabled. The first value holds
- the path to the file, and the second value holds the
content (typically $in.)
 - 
| Parameters: | 
pool (string) – Optional; defaults to disabled. Specify the name of
a worker pool to use for these build targets.block (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - Consider ninja’s rule reference for more
information about these options. 
 - 
- 
build(path, rule, dep=[], vars={}, order_only=[], implicit=[], block='_all')
- 
| Parameters: | 
path (string) – A path for the build target.rule (string) – The name of build rule.dep (list) – A list of explicit dependencies.vars (dict) – A mapping of variable names to their values.order_only (list) – A list of order-only dependencies.implicit (list) – A list of implicit dependenciesblock (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - Consider ninja’s rule statement reference for
more information about these options. 
 - 
- 
default(rule, block='_all')
- 
| Parameters: | 
rule (string) – The name of the default rule.block (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - See ninja’s documentation on the default rule
for more information. 
 - 
- 
phony(name, dependency, block='_all')
- 
| Parameters: | 
name (string) – The name of a phony rule.dependency (string) – The build targets which are “phony.”block (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - See ninja’s documentation on phony rules
for more information. 
 - 
- 
pool(name, depth, block='_all')
- 
| Parameters: | 
name (string) – The name of the worker pool for buildingdepth (int) – The size of the worker pool. This cannot exceed the
default parallelism specified by -j to ninja
on the command line.block (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - Pools provide a way to control and limit concurrency for specific
jobs. See ninja’s documentation of pools for more
information. - 
- Note - Pools are an experimental feature of Ninja that may be
removed in a future release. 
 
 - 
- 
rule(name, rule_dict, block='_all')
- 
| Parameters: | 
name (string) – The name of the build rule. This string will
identify the rule when you specify a builder.rule_dict (dict) – A dictionary that contains a complete Ninja build rule.block (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - rule() parses rule_dict for the
following fields and constructs a corresponding ninja rule: - 
- command (required; a list.)
- depfile (a path.)
- description` (required. a string.)
- generator
- restat
- rspfile (requires corresponding rsp_content field)
 - Internally, rule() wraps
add_rule(). 
 - 
- 
var(variable, value, block='_all')
- 
| Parameters: | 
variable (string) – The name of the variable.value (string) – The value of the variable.block (string) – Optional; defaults to _all. Specify the name of
the block in builder. | 
|---|
 
 - Adds a variable assignment to a build system block. 
 
- 
ninja.process_command(command)
- 
| Parameters: | command (list) – A list of commands. | 
|---|
 
 - Helper function to take a list of commands and transform the command into a
; `` separated list of commands to support multi-operation build
commands. If ``command is not a list, raises
buildcloth.err.MalformedContent.