guppy-rs/guppy

cargo hakari misses some dependencies/features

glandium opened this issue · 4 comments

Steps to reproduce:

  • Create 2 dummy crates:
cargo new --lib a
cargo new --lib b
  • Create a Cargo.toml file with the following content:
[workspace]
members = [
    "a",
    "b",
]
  • In a/Cargo.toml add the following content after [dependencies]:
audio_thread_priority = {version = "0.26", features = ["winapi"] }
  • In b/Cargo.toml add the following content after [dependencies]:
winapi = { version = "0.3", features = ["winbase"] }
  • Initialize/generate/install hakari:
cargo hakari init workspace-hack
cargo hakari generate
cargo hakari manage-deps
  • Run the following commands:
cargo check -p a --target x86_64-pc-windows-msvc
cargo check -p b --target x86_64-pc-windows-msvc

Expected result:
My understanding of what hakari is meant to do is that winapi should be built only once.

Actual result:
It is built twice, because the workspace hack doesn't contain the common features for winapi.

Adding output-single-feature = true to .config/hakari.toml makes it add winapi = { version = "0.3", default-features = false, features = ["winbase"] }. It seems it's missing the indirect features the winapi feature of audio_thread_priority add per https://github.com/mozilla/audio_thread_priority/blob/e80987a0511d671a09b612c05c831030da235edc/Cargo.toml#L41-L45.

Hi, could you follow the instructions here to add the platforms you use? https://docs.rs/cargo-hakari/latest/cargo_hakari/config/index.html#platforms

By default, hakari doesn't try to unify platform-specific dependencies. It will do so if you list out platforms in that section.

Oh indeed, it works better with platforms... it's a little inconvenient, though.

I'll note that it's not really clear from the doc that this is the expected outcome. I mean, your comment makes it clear, but the doc doesn't really.

Yeah, I agree. Would you like to submit a change to the docs regarding this? Would be greatly appreciated!