Skip to content

Commit

Permalink
Merge pull request #25 from integer32llc/features-activating-dev-deps
Browse files Browse the repository at this point in the history
Remove feature components that activate features of dev-dependencies
  • Loading branch information
shepmaster authored Aug 30, 2024
2 parents 7e9c0a4 + 9dcddf6 commit 1103ad1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lint_groups_priority = { level = "allow", priority = 1 } # Remove after 1.80. ht

[workspace.dependencies]
argh = { version = "0.1.12", default-features = false }
registry-conformance = { version = "0.5.0", registry = "registry-conformance" }
registry-conformance = { version = "0.5.2", registry = "registry-conformance" }
snafu = { version = "0.8.2", default-features = false, features = ["rust_1_65", "std"] }
tokio = { version = "1.37.0", default-features = false, features = ["macros", "process", "rt-multi-thread"] }

Expand Down
29 changes: 28 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,9 +1014,33 @@ enum ExtractRootCargoTomlError {
fn adapt_cargo_toml_to_index_entry(
global: &Global,
config: &ConfigV1,
cargo_toml: cargo_toml::Root,
mut cargo_toml: cargo_toml::Root,
checksum_hex: String,
) -> index_entry::Root {
// Remove features that refer to dev-dependencies as we don't
// track those anyway.
{
// Ignore dependencies that also occur as a regular or build
// dependency, as we *do* track those.
let reg_dep_names = cargo_toml.dependencies.keys();
let build_dep_names = cargo_toml.build_dependencies.keys();
let mut only_dev_dep_names = cargo_toml.dev_dependencies.keys().collect::<BTreeSet<_>>();
for name in reg_dep_names.chain(build_dep_names) {
only_dev_dep_names.remove(name);
}

for name in only_dev_dep_names {
// We don't care about the official package name here as the
// feature syntax has to match the user-specified dependency
// name.
let prefix = format!("{name}/");

for enabled in cargo_toml.features.values_mut() {
enabled.retain(|enable| !enable.starts_with(&prefix));
}
}
}

let mut deps: Vec<_> = cargo_toml
.dependencies
.into_iter()
Expand Down Expand Up @@ -1126,6 +1150,9 @@ mod cargo_toml {
#[serde(default)]
pub build_dependencies: Dependencies,

#[serde(default)]
pub dev_dependencies: Dependencies,

#[serde(default)]
pub target: BTreeMap<String, Target>,
}
Expand Down

0 comments on commit 1103ad1

Please sign in to comment.