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

cargo hakari misses some dependencies/features #73

Open
glandium opened this issue Jun 8, 2023 · 4 comments
Open

cargo hakari misses some dependencies/features #73

glandium opened this issue Jun 8, 2023 · 4 comments

Comments

@glandium
Copy link

glandium commented Jun 8, 2023

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.

@glandium
Copy link
Author

glandium commented Jun 8, 2023

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.

@sunshowers
Copy link
Member

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.

@glandium
Copy link
Author

glandium commented Jun 8, 2023

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.

@sunshowers
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants