Skip to content

Commit

Permalink
Add support for Cargo feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed Sep 7, 2023
1 parent 6d046ce commit 8044558
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ struct Build {
#[structopt(long)]
release: bool,

/// Enable build feature flags.
#[structopt(long)]
features: Vec<String>,

/// Build a specific example from the examples/ dir.
#[structopt(long)]
example: Option<String>,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -785,6 +795,10 @@ struct Package {
#[structopt(long)]
example: Option<String>,

/// Enable build feature flags.
#[structopt(long)]
features: Vec<String>,

/// clean before building
#[structopt(long)]
clean: bool,
Expand Down Expand Up @@ -814,6 +828,7 @@ impl Package {
let device_build = Build {
device: true,
example: self.example.clone(),
features: self.features.clone(),
release: true,
run: false,
};
Expand All @@ -822,6 +837,7 @@ impl Package {
let sim_build = Build {
device: false,
example: self.example.clone(),
features: self.features.clone(),
release: true,
run: false,
};
Expand Down

0 comments on commit 8044558

Please sign in to comment.