pub fn build<'a>(
metadata: &'a Metadata,
package: Option<&'a Package>,
target: Option<&'a Target>,
profile: Option<&'a str>,
build_options: impl IntoIterator<Item = &'a str>,
use_cross: bool,
target_triple: Option<&'a str>,
) -> Result<impl Iterator<Item = Result<Utf8PathBuf>> + 'a>Expand description
Executes a cargo build command and returns paths to the build artifacts.
ยงExamples
// executes cargo build
let workspace = cli_xtask::workspace::current();
for bin in cli_xtask::cargo::build(workspace, None, None, None, None, false, None)? {
let bin = bin?;
println!("{bin}");
}
// executes cross build --profile target --bin foo --target aarch64-unknown-linux-gnu
let workspace = cli_xtask::workspace::current();
let package = workspace.root_package().unwrap();
let target = package.targets.iter().find(|t| t.name == "foo").unwrap();
for bin in cli_xtask::cargo::build(
workspace,
Some(&package),
Some(target),
Some("release"),
vec!["--features", "feature-a"],
true,
Some("aarch64-unknown-linux-gnu"),
)? {
let bin = bin?;
println!("{bin}");
}