RFC 1361 allows specifying dependencies like this:
[target."cfg(windows)".dependencies]
winapi = "0.2"
[target."cfg(unix)".dependencies]
unix-socket = "0.4"
[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.2"
The RFC did not specify a timeline for the community to shift over to using these kinds of dependencies. The problem is that old cargo versions will not be able to interpret the new targets correctly. Ironically, support for this was implemented in 0.9.0 but the toml version needed to support this was not configured in cargo until 0.10.0. To clarify compatibility:
target.x86_64-pc-windows-msvc.dependencies
- cargo 0.8.0-: supported
- cargo 0.9.0: supported
- cargo 0.10.0+: supported
target."cfg(windows)".dependencies
- cargo 0.8.0-: ignored
- cargo 0.9.0: supported
- cargo 0.10.0+: supported
target.'cfg(target_os="windows")'.dependencies
- cargo 0.8.0-: Cargo.toml parse error
- cargo 0.9.0: Cargo.toml parse error
- cargo 0.10.0+: supported
I’m not sure this is accurate, but I believe the latest stable Rust (1.9.0) shipped with cargo 0.10.0.
So, while moving some of the big crates over might cause breakage, I’d really like to get rid of the winapi dependency in all of my crates. Would the Rust 1.10.0 release be a good time to switch everything over?
P.S. Man I wrote this whole post being sure rand
depended on winapi
but that’s no longer the case. Regardless, there are still plenty of crates that could benefit from winapi-abatement: cargo, mio, openssl, time, etc. winapi
is still the 2nd most-downloaded crate on crates.io.