diff --git a/src/main.rs b/src/main.rs index f9ae3c2..5e5803b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, } fn _main() -> Result<(), anyhow::Error> { @@ -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."); @@ -295,6 +299,7 @@ fn _main() -> Result<(), anyhow::Error> { verbose, bins, no_build, + jobs, }) .context("Failed to cook recipe.")?; } diff --git a/src/recipe.rs b/src/recipe.rs index 1f26f76..1755ceb 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -47,6 +47,7 @@ pub struct CookArgs { pub bin: Option>, pub bins: bool, pub no_build: bool, + pub jobs: Option, } impl Recipe { @@ -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); @@ -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); }