Build

Struct Build 

Source
pub struct Build {
    pub rule: RefCounted<String>,
    pub outputs: AddOnlyVec<String>,
    pub implicit_outputs: AddOnlyVec<String>,
    pub dependencies: AddOnlyVec<String>,
    pub implicit_dependencies: AddOnlyVec<String>,
    pub order_only_dependencies: AddOnlyVec<String>,
    pub validations: AddOnlyVec<String>,
    pub variables: AddOnlyVec<Variable>,
}
Expand description

A build edge, as defined by the build keyword

See https://ninja-build.org/manual.html#_build_statements

§Example

Since build edges are tied to rules, use RuleRef::build to create them.

use ninja_writer::*;

let ninja = Ninja::new();
let cc = ninja.rule("cc", "gcc $cflags -c $in -o $out");
cc.build(["foo.o"]).with(["foo.c"]);

assert_eq!(ninja.to_string(), r###"
rule cc
  command = gcc $cflags -c $in -o $out

build foo.o: cc foo.c
"###);

Fields§

§rule: RefCounted<String>

The rule name

§outputs: AddOnlyVec<String>

The list of outputs, as defined by build <outputs>:

§implicit_outputs: AddOnlyVec<String>

The list of implicit outputs.

See https://ninja-build.org/manual.html#ref_outputs

§dependencies: AddOnlyVec<String>

The list of dependencies (inputs).

See https://ninja-build.org/manual.html#ref_dependencies

§implicit_dependencies: AddOnlyVec<String>

The list of implicit dependencies (inputs).

See https://ninja-build.org/manual.html#ref_dependencies

§order_only_dependencies: AddOnlyVec<String>

The list of order-only dependencies (inputs).

See https://ninja-build.org/manual.html#ref_dependencies

§validations: AddOnlyVec<String>§variables: AddOnlyVec<Variable>

The list of variables, as an indented block

Implementations§

Source§

impl Build

Source

pub fn new(rule: &Rule, outputs: impl IntoIterator<Item = impl ToArg>) -> Self

Create a new build with the given explicit outputs and rule

Trait Implementations§

Source§

impl AsRef<Build> for BuildRef

Source§

fn as_ref(&self) -> &Build

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl BuildVariables for Build

Source§

fn as_build(&self) -> &Build

Internal function for implementing variables for build
Source§

fn dyndep(self, dyndep: impl ToArg) -> Self

Specify dynamic dependency file Read more
Source§

fn with(self, inputs: impl IntoIterator<Item = impl ToArg>) -> Self

Add explicit dependencies (inputs) Read more
Source§

fn with_implicit(self, inputs: impl IntoIterator<Item = impl ToArg>) -> Self

Add implicit dependencies Read more
Source§

fn with_order_only(self, inputs: impl IntoIterator<Item = impl ToArg>) -> Self

Add order-only dependencies Read more
Source§

fn validations(self, validations: impl IntoIterator<Item = impl ToArg>) -> Self

Add validations Read more
Source§

fn output_implicit(self, outputs: impl IntoIterator<Item = impl ToArg>) -> Self

Add validations Read more
Source§

impl Debug for Build

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Build

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl RuleVariables for Build

Source§

fn depfile(self, depfile: impl ToArg) -> Self

Set the depfile for this rule or build to explicitly support C/C++ header dependencies Read more
Source§

fn deps_gcc(self) -> Self

Set deps = gcc for this rule or build Read more
Source§

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 Read more
Source§

fn deps_msvc(self) -> Self

Set deps = msvc for this rule or build without msvc_deps_prefix Read more
Source§

fn description(self, desc: impl ToArg) -> Self

Set the description of the rule to be printed during the build Read more
Source§

fn generator(self) -> Self

Indicate the rule is used to re-invoke the generator Read more
Source§

fn restat(self) -> Self

Specify restat = 1 for the rule or build Read more
Source§

fn rspfile(self, rspfile: impl ToArg, rspfile_content: impl ToArg) -> Self

Specify rspfile and rspfile_content variables for this rule or build Read more
Source§

fn pool_console(self) -> Self

Set pool = console for this rule or build Read more
Source§

fn pool(self, pool: impl AsRef<Pool>) -> Self

Set the pool for this rule or build Read more
Source§

impl Variables for Build

Source§

fn add_variable_internal(&self, v: Variable)

Add a variable Read more
Source§

fn variable(self, name: impl ToArg, value: impl ToArg) -> Self

Add a variable to the current scope

Auto Trait Implementations§

§

impl !Freeze for Build

§

impl !RefUnwindSafe for Build

§

impl !Send for Build

§

impl !Sync for Build

§

impl Unpin for Build

§

impl UnwindSafe for Build

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.