Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add --no-default-features flag #647

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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