From 36c8a336de43f1d41a7ef680c7a3c921501f5873 Mon Sep 17 00:00:00 2001 From: Bowarc Date: Thu, 3 Apr 2025 01:24:59 +0200 Subject: [PATCH 1/3] Add a way to set the jobs limit --- src/lib.rs | 2 +- src/main.rs | 8 +++++++- src/recipe.rs | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d50fa59..109f999 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,6 @@ mod recipe; mod skeleton; pub use recipe::{ - AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs, + AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs }; pub use skeleton::*; diff --git a/src/main.rs b/src/main.rs index f9ae3c2..06c4f33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use anyhow::{anyhow, Context}; use chef::{ - AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs, + AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, + TargetArgs, }; use clap::crate_version; use clap::Parser; @@ -154,6 +155,9 @@ pub struct Cook { /// projects that rely on a custom build system (i.e. not `cargo`). #[clap(long)] no_build: bool, + /// Specify the number of worker that you want to use + #[clap(long)] + jobs: Option, } fn _main() -> Result<(), anyhow::Error> { @@ -195,6 +199,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 +300,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..cce1b29 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); } From cd673e1252f1711d4c714c9d3c5538e4ea2bd84b Mon Sep 17 00:00:00 2001 From: Bowarc Date: Mon, 5 May 2025 07:12:32 +0200 Subject: [PATCH 2/3] Comment update --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 06c4f33..6d4210e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -155,7 +155,7 @@ pub struct Cook { /// projects that rely on a custom build system (i.e. not `cargo`). #[clap(long)] no_build: bool, - /// Specify the number of worker that you want to use + /// Number of rust workers #[clap(long)] jobs: Option, } From f092200b74b31728f49bc5f9b368c1e3ecdb6638 Mon Sep 17 00:00:00 2001 From: Bowarc Date: Mon, 5 May 2025 08:35:49 +0200 Subject: [PATCH 3/3] Fmt --- src/lib.rs | 2 +- src/main.rs | 3 +-- src/recipe.rs | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 109f999..d50fa59 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,6 @@ mod recipe; mod skeleton; pub use recipe::{ - AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs + AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs, }; pub use skeleton::*; diff --git a/src/main.rs b/src/main.rs index 6d4210e..5e5803b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ use anyhow::{anyhow, Context}; use chef::{ - AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, - TargetArgs, + AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs, }; use clap::crate_version; use clap::Parser; diff --git a/src/recipe.rs b/src/recipe.rs index cce1b29..1755ceb 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -47,7 +47,7 @@ pub struct CookArgs { pub bin: Option>, pub bins: bool, pub no_build: bool, - pub jobs: Option + pub jobs: Option, } impl Recipe { @@ -118,7 +118,7 @@ fn build_dependencies(args: &CookArgs) { no_std: _no_std, bins, no_build: _no_build, - jobs + 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); @@ -204,10 +204,10 @@ fn build_dependencies(args: &CookArgs) { command_with_args.arg("--bins"); } - if let Some(count) = jobs{ + if let Some(count) = jobs { command_with_args.arg("--jobs").arg(count.to_string()); } - + execute_command(command_with_args); }