Skip to content

Commit

Permalink
Also walk target.'cfg()' for dev-dependencies next to dependencies
Browse files Browse the repository at this point in the history
In [RustAudio/cpal#641] we're seeing a [failure in `ndk-macro`] to turn
a crate name with dashes into underscores as fallback, with the
underlying issue that `proc-macro-crate` failed to find our crate in
`Cargo.toml` when limited to a specific target cfg.  According to [the
Rust docs] it is perfectly possible to have `dev-dependencies` behind
such a target predicate too.

[RustAudio/cpal#641]: RustAudio/cpal#641 (comment)
[failure in `ndk-macro`]: https://github.com/rust-windowing/android-ndk-rs/blob/9060d5dbea8bdd9aee9e42ef8e8375c35adbc271/ndk-macro/src/helper.rs#L64
[the Rust docs]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#development-dependencies
  • Loading branch information
MarijnS95 committed Feb 15, 2022
1 parent 9ddaaac commit c2a4c91
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ fn extract_crate_name(
.and_then(|t| {
t.values()
.filter_map(|v| v.as_table())
.filter_map(|t| t.get("dependencies").and_then(|t| t.as_table()))
.filter_map(|t| t.get("dependencies").or_else(|| t.get("dev-dependencies")))
.filter_map(|t| t.as_table())
.find_map(|t| extract_crate_name_from_deps(orig_name, t.clone()))
})
{
Expand Down

0 comments on commit c2a4c91

Please sign in to comment.