diff --git a/src/lib.rs b/src/lib.rs index b62711e..d50fa59 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ mod recipe; mod skeleton; -pub use recipe::{CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs}; +pub use recipe::{ + AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs, +}; pub use skeleton::*; diff --git a/src/main.rs b/src/main.rs index 4149d1b..10a1d89 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ use anyhow::{anyhow, Context}; -use chef::{CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs}; +use chef::{ + AllFeatures, CommandArg, CookArgs, DefaultFeatures, OptimisationProfile, Recipe, TargetArgs, +}; use clap::crate_version; use clap::Parser; use fs_err as fs; @@ -87,6 +89,9 @@ pub struct Cook { /// Do not activate the `default` feature. #[clap(long)] no_default_features: bool, + /// Enable all features. + #[clap(long)] + all_features: bool, /// Space or comma separated list of features to activate. #[clap(long, value_delimiter = ',')] features: Option>, @@ -152,6 +157,7 @@ fn _main() -> Result<(), anyhow::Error> { clippy, target, no_default_features, + all_features, features, unstable_features, target_dir, @@ -227,6 +233,12 @@ fn _main() -> Result<(), anyhow::Error> { DefaultFeatures::Enabled }; + let all_features = if all_features { + AllFeatures::Enabled + } else { + AllFeatures::Disabled + }; + let serialized = fs::read_to_string(recipe_path) .context("Failed to read recipe from the specified path.")?; let recipe: Recipe = @@ -242,6 +254,7 @@ fn _main() -> Result<(), anyhow::Error> { profile, command, default_features, + all_features, features, unstable_features, target, diff --git a/src/recipe.rs b/src/recipe.rs index fe5e156..54e4b73 100644 --- a/src/recipe.rs +++ b/src/recipe.rs @@ -28,6 +28,7 @@ pub struct CookArgs { pub profile: OptimisationProfile, pub command: CommandArg, pub default_features: DefaultFeatures, + pub all_features: AllFeatures, pub features: Option>, pub unstable_features: Option>, pub target: Option>, @@ -78,11 +79,18 @@ pub enum DefaultFeatures { Disabled, } +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +pub enum AllFeatures { + Enabled, + Disabled, +} + fn build_dependencies(args: &CookArgs) { let CookArgs { profile, command: command_arg, default_features, + all_features, features, unstable_features, target, @@ -116,6 +124,9 @@ fn build_dependencies(args: &CookArgs) { let feature_flag = features.iter().cloned().collect::>().join(","); command_with_args.arg("--features").arg(feature_flag); } + if all_features == &AllFeatures::Enabled { + command_with_args.arg("--all-features"); + } if let Some(unstable_features) = unstable_features { for unstable_feature in unstable_features.iter().cloned() { command_with_args.arg("-Z").arg(unstable_feature);