pub trait RuleVariables: Variables {
// Provided methods
fn depfile(self, depfile: impl ToArg) -> Self { ... }
fn deps_gcc(self) -> Self { ... }
fn deps_msvc_prefix(self, msvc_deps_prefix: impl ToArg) -> Self { ... }
fn deps_msvc(self) -> Self { ... }
fn description(self, desc: impl ToArg) -> Self { ... }
fn generator(self) -> Self { ... }
fn restat(self) -> Self { ... }
fn rspfile(self, rspfile: impl ToArg, rspfile_content: impl ToArg) -> Self { ... }
fn pool_console(self) -> Self { ... }
fn pool(self, pool: impl AsRef<Pool>) -> Self { ... }
}Expand description
Trait for implementing variables for rule and build
Provided Methods§
Sourcefn depfile(self, depfile: impl ToArg) -> Self
fn depfile(self, depfile: impl ToArg) -> Self
Set the depfile for this rule or build to explicitly support C/C++ header
dependencies
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("cc", "gcc -c $in -o $out")
.depfile("$out.d");
assert_eq!(ninja.to_string(), r###"
rule cc
command = gcc -c $in -o $out
depfile = $out.d
"###);Sourcefn deps_gcc(self) -> Self
fn deps_gcc(self) -> Self
Set deps = gcc for this rule or build
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("cc", "gcc -c $in -o $out")
.deps_gcc();
assert_eq!(ninja.to_string(), r###"
rule cc
command = gcc -c $in -o $out
deps = gcc
"###);Sourcefn deps_msvc_prefix(self, msvc_deps_prefix: impl ToArg) -> Self
fn deps_msvc_prefix(self, msvc_deps_prefix: impl ToArg) -> Self
Set deps = msvc for this rule (or build) and the msvc_deps_prefix variable
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("cl", "cl /c $in /Fo$out")
.deps_msvc_prefix("Note: including file: ");
assert_eq!(ninja.to_string(), format!(r###"
rule cl
command = cl /c $in /Fo$out
deps = msvc
msvc_deps_prefix = Note: including file: {}"###, "\n"));Sourcefn deps_msvc(self) -> Self
fn deps_msvc(self) -> Self
Set deps = msvc for this rule or build without msvc_deps_prefix
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("cl", "cl /c $in /Fo$out")
.deps_msvc();
assert_eq!(ninja.to_string(), r###"
rule cl
command = cl /c $in /Fo$out
deps = msvc
"###);Sourcefn description(self, desc: impl ToArg) -> Self
fn description(self, desc: impl ToArg) -> Self
Set the description of the rule to be printed during the build
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("cc", "gcc -c $in -o $out")
.description("Compiling $out");
assert_eq!(ninja.to_string(), r###"
rule cc
command = gcc -c $in -o $out
description = Compiling $out
"###);Sourcefn generator(self) -> Self
fn generator(self) -> Self
Indicate the rule is used to re-invoke the generator
§Example
use ninja_writer::*;
let ninja = Ninja::new();
let configure = ninja.rule("configure", "cargo run --manifest-path ./configure/Cargo.toml -- $out")
.generator();
configure.build(["build.ninja"]);
assert_eq!(ninja.to_string(), r###"
rule configure
command = cargo run --manifest-path ./configure/Cargo.toml -- $out
generator = 1
build build.ninja: configure
"###);Sourcefn restat(self) -> Self
fn restat(self) -> Self
Specify restat = 1 for the rule or build
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("example", "...")
.restat();
assert_eq!(ninja.to_string(), r###"
rule example
command = ...
restat = 1
"###);Sourcefn rspfile(self, rspfile: impl ToArg, rspfile_content: impl ToArg) -> Self
fn rspfile(self, rspfile: impl ToArg, rspfile_content: impl ToArg) -> Self
Specify rspfile and rspfile_content variables for this rule or build
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("example", "...")
.rspfile("foo", "bar");
assert_eq!(ninja.to_string(), r###"
rule example
command = ...
rspfile = foo
rspfile_content = bar
"###);Sourcefn pool_console(self) -> Self
fn pool_console(self) -> Self
Set pool = console for this rule or build
See https://ninja-build.org/manual.html#_the_literal_console_literal_pool
§Example
use ninja_writer::*;
let ninja = Ninja::new();
ninja.rule("example", "...").pool_console();
assert_eq!(ninja.to_string(), r###"
rule example
command = ...
pool = console
"###);Sourcefn pool(self, pool: impl AsRef<Pool>) -> Self
fn pool(self, pool: impl AsRef<Pool>) -> Self
Set the pool for this rule or build
§Example
use ninja_writer::*;
let ninja = Ninja::new();
let pool = ninja.pool("expensive", 4);
let rule = ninja.rule("cc", "gcc -c $in -o $out").pool(pool);
rule.build(["foo.o"]).with(["foo.c"]);
assert_eq!(ninja.to_string(), r###"
pool expensive
depth = 4
rule cc
command = gcc -c $in -o $out
pool = expensive
build foo.o: cc foo.c
"###);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.