Skip to content

Commit

Permalink
feat: add --no-default-features flag (#647)
Browse files Browse the repository at this point in the history
* feat: add --no-default-features flag

* fix: update changelog

* Update CHANGELOG.md

Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>

---------

Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>
  • Loading branch information
etiennetremel and SergioGasquez committed Jul 1, 2024
1 parent 5c898ac commit 44ba4d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Add `hold-in-reset` and `reset` subcommands
- [cargo-espflash]: Add `--no-default-features` flag to mirror cargo features behavior

## [3.1.0] - 2024-05-24

Expand Down
10 changes: 10 additions & 0 deletions cargo-espflash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ struct BuildArgs {
/// Comma delimited list of build features
#[arg(long, use_value_delimiter = true)]
pub features: Option<Vec<String>>,
/// Do not activate the `default` feature
#[arg(long)]
pub no_default_features: bool,
/// Require Cargo.lock and cache are up to date
#[arg(long)]
pub frozen: bool,
Expand Down Expand Up @@ -373,6 +376,9 @@ fn build(
.ok_or_else(|| NoTargetError::new(Some(chip)))?;

let mut metadata_cmd = MetadataCommand::new();
if build_options.no_default_features {
metadata_cmd.features(cargo_metadata::CargoOpt::NoDefaultFeatures);
}
if let Some(features) = &build_options.features {
metadata_cmd.features(cargo_metadata::CargoOpt::SomeFeatures(features.clone()));
}
Expand Down Expand Up @@ -435,6 +441,10 @@ fn build(
args.push(package.to_string());
}

if build_options.no_default_features {
args.push("--no-default-features".to_string());
}

if let Some(features) = &build_options.features {
args.push("--features".to_string());
args.push(features.join(","));
Expand Down

0 comments on commit 44ba4d4

Please sign in to comment.