Struct rustwide::Build

source ·
pub struct Build<'ws> { /* private fields */ }
Expand description

API to interact with a running build.

This is created from BuildDirectory::build

Implementations§

source§

impl<'ws> Build<'ws>

source

pub fn cmd<'pl, R: Runnable>(&self, bin: R) -> Command<'ws, 'pl>

Run a command inside the sandbox.

Any cargo invocation will automatically be configured to use a target directory mounted outside the sandbox. The crate’s source directory will be the working directory for the command.

Example
let mut build_dir = workspace.build_dir("foo");
build_dir.build(&toolchain, &krate, sandbox).run(|build| {
    build.cmd("rustfmt").args(&["--check", "src/main.rs"]).run()?;
    Ok(())
})?;
source

pub fn cargo<'pl>(&self) -> Command<'ws, 'pl>

Run cargo inside the sandbox, using the toolchain chosen for the build.

cargo will automatically be configured to use a target directory mounted outside the sandbox. The crate’s source directory will be the working directory for the command.

Example
let mut build_dir = workspace.build_dir("foo");
build_dir.build(&toolchain, &krate, sandbox).run(|build| {
    build.cargo().args(&["test", "--all"]).run()?;
    Ok(())
})?;
source

pub fn host_source_dir(&self) -> PathBuf

Get the path to the source code on the host machine (outside the sandbox).

source

pub fn host_target_dir(&self) -> PathBuf

Get the path to the target directory on the host machine (outside the sandbox).

source

pub fn fetch_build_std_dependencies( &self, targets: &[&str] ) -> Result<(), Error>

Available on crate feature unstable only.

Pre-fetching the dependencies for -Z build-std outside the sandbox.

When this function is called, it is possible to use -Zbuild-std inside the sandbox to build the standard library from source even when networking is disabled.

Auto Trait Implementations§

§

impl<'ws> RefUnwindSafe for Build<'ws>

§

impl<'ws> Send for Build<'ws>

§

impl<'ws> Sync for Build<'ws>

§

impl<'ws> Unpin for Build<'ws>

§

impl<'ws> UnwindSafe for Build<'ws>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.