From 8044558c56910ae98274fbd601d020924bf3d9cb Mon Sep 17 00:00:00 2001 From: Jay Oster Date: Wed, 6 Sep 2023 18:25:20 -0700 Subject: [PATCH] Add support for Cargo feature flags --- src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index 1a24be6..e6527d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -158,6 +158,10 @@ struct Build { #[structopt(long)] release: bool, + /// Enable build feature flags. + #[structopt(long)] + features: Vec, + /// Build a specific example from the examples/ dir. #[structopt(long)] example: Option, @@ -637,6 +641,12 @@ impl Build { args.push("--release"); } + let features; + if !self.features.is_empty() { + features = format!("--features={}", self.features.join(",")); + args.push(&features); + } + if self.device { args.push("--target"); args.push("thumbv7em-none-eabihf"); @@ -785,6 +795,10 @@ struct Package { #[structopt(long)] example: Option, + /// Enable build feature flags. + #[structopt(long)] + features: Vec, + /// clean before building #[structopt(long)] clean: bool, @@ -814,6 +828,7 @@ impl Package { let device_build = Build { device: true, example: self.example.clone(), + features: self.features.clone(), release: true, run: false, }; @@ -822,6 +837,7 @@ impl Package { let sim_build = Build { device: false, example: self.example.clone(), + features: self.features.clone(), release: true, run: false, };