Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ pub struct Cook {
/// projects that rely on a custom build system (i.e. not `cargo`).
#[clap(long)]
no_build: bool,
/// Number of rust workers
#[clap(long)]
jobs: Option<u16>,
}

fn _main() -> Result<(), anyhow::Error> {
Expand Down Expand Up @@ -195,6 +198,7 @@ fn _main() -> Result<(), anyhow::Error> {
zigbuild,
bins,
no_build,
jobs,
}) => {
if std::io::stdout().is_terminal() {
eprintln!("WARNING stdout appears to be a terminal.");
Expand Down Expand Up @@ -295,6 +299,7 @@ fn _main() -> Result<(), anyhow::Error> {
verbose,
bins,
no_build,
jobs,
})
.context("Failed to cook recipe.")?;
}
Expand Down
6 changes: 6 additions & 0 deletions src/recipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct CookArgs {
pub bin: Option<Vec<String>>,
pub bins: bool,
pub no_build: bool,
pub jobs: Option<u16>,
}

impl Recipe {
Expand Down Expand Up @@ -117,6 +118,7 @@ fn build_dependencies(args: &CookArgs) {
no_std: _no_std,
bins,
no_build: _no_build,
jobs,
} = args;
let cargo_path = std::env::var("CARGO").expect("The `CARGO` environment variable was not set. This is unexpected: it should always be provided by `cargo` when invoking a custom sub-command, allowing `cargo-chef` to correctly detect which toolchain should be used. Please file a bug.");
let mut command = Command::new(cargo_path);
Expand Down Expand Up @@ -202,6 +204,10 @@ fn build_dependencies(args: &CookArgs) {
command_with_args.arg("--bins");
}

if let Some(count) = jobs {
command_with_args.arg("--jobs").arg(count.to_string());
}

execute_command(command_with_args);
}

Expand Down