It is somewhat similar to #2.
https://github.com/rustgd/collision-rs/blob/master/Cargo.toml
[dependencies] serde = { version = "1.0", optional = true, features = ["derive"] } [target.'cfg(feature="serde")'.dependencies] cgmath = { version = "0.17", features = ["serde"] } num = { version = "0.2", features = ["serde"] }
We should pull cgmath/serde and num/serde only in case serde feature is activated.
serde
@zbyszek can you take a look on this? This should be implementable right now with your rustcfg and current macro code (since those are optional dependencies).
In cargo metadata I see:
{ "name": "cgmath", "source": "registry+https://github.com/rust-lang/crates.io-index", "req": "^0.16", "kind": null, "rename": null, "optional": false, "uses_default_features": true, "features": [], "target": null, "registry": null }, { "name": "cgmath", "source": "registry+https://github.com/rust-lang/crates.io-index", "req": "^0.16", "kind": null, "rename": null, "optional": false, "uses_default_features": true, "features": [ "serde" ], "target": "cfg(feature = \"serde\")", "registry": null },
Metadata Update from @ignatenkobrain: - Issue assigned to zbyszek
Hasn't this long been fixed? At least, I think it behaves correctly now.
Metadata Update from @zbyszek: - Assignee reset
I have no idea.
I don't think this is fixed as we need to introduce here that cexpr parser that @zbyszek wrote at some point... essentially this is like os ,/ arch dependent dependencies which we don't handle now.
Oh, right, the example from the ticket body is very weird at second glance:
The only way I've ever seen this specified is like this:
[dependencies] serde_crate = { version = "1.0", optional = true, features = ["derive"], package = "serde" } cgmath = { version = "0.17", optional = true } num = { version = "0.2", optional = true } [features] serde = ["serde_crate", "cgmath/serde", "num/serde"]
This doesn't actually work in cargo either:
warning: Found feature = ... in target.'cfg(...)'.dependencies. This key is not supported for selecting dependencies and will not work as expected. Use the [features] section instead: https://doc.rust-lang.org/cargo/reference/features.html
feature = ...
target.'cfg(...)'.dependencies
And if you look at the collision-rs repo now, they have indeed switched to [features].
[features]
Metadata Update from @ignatenkobrain: - Issue close_status updated to: Invalid - Issue status updated to: Closed (was: Open)
Then I think we can do this :)
Login to comment on this ticket.