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>
impl<'ws> Build<'ws>
sourcepub fn cmd<'pl, R: Runnable>(&self, bin: R) -> Command<'ws, 'pl>
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(())
})?;
sourcepub fn cargo<'pl>(&self) -> Command<'ws, 'pl>
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(())
})?;
sourcepub fn host_source_dir(&self) -> PathBuf
pub fn host_source_dir(&self) -> PathBuf
Get the path to the source code on the host machine (outside the sandbox).
sourcepub fn host_target_dir(&self) -> PathBuf
pub fn host_target_dir(&self) -> PathBuf
Get the path to the target directory on the host machine (outside the sandbox).
sourcepub fn fetch_build_std_dependencies(
&self,
targets: &[&str]
) -> Result<(), Error>
Available on crate feature unstable
only.
pub fn fetch_build_std_dependencies( &self, targets: &[&str] ) -> Result<(), Error>
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.