-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Support for target-specific dependencies #8915
Comments
I believe you can express it as a target-specific dependency like this: [dependencies]
memmap = { "0.7.0", optional = true }
[target.'cfg(unix)'.dependencies]
glommio = { "0.2.0-alpha", optional = true }
[features]
f1 = ["memmap", "glommio"] |
@ehuss Hmm... does that example work on all platforms as expected? Specifically, in the original problem statement I had I'm an all around rust n00b so apologies for the silly questions. I would have guessed Cargo builds up the dependency resolution info from the
Where the dependency info for |
You can add You cannot have invalid versions in a dependency, even if it is for another target. Cargo builds the resolve graph ignoring the target specification (it resolves all of them at the same time). |
Ok, so this is indeed a dupe of #7914. Sorry for the noise. |
Describe the problem you are trying to solve
I want to provide a feature in my Crate that may have target-specific dependencies. In other words, I want to add a feature "f1" to my crate in my
[features]
section that depends onglommio
on Linux (it's a Linux-only crate). On other platforms I may have a different dependency set. #1197/#7914 seem to be more about conditionally enabling features of an upstream package upstream rather than conditionally including the package altogether.The ability to conditionally include a dependency for a feature based on the platform.
Describe the solution you'd like
Conditionally specifying the dependencies for a feature seems like the right approach perhaps? I don't really know Cargo well enough.
Notes
Apologies if there's already an issue tracking this or some other idiomatic way to express this. I've tried looking but couldn't find anything.
The text was updated successfully, but these errors were encountered: