Plaform- or feature-specific dependencies


In the cargo docs, in the section on platform-specific dependencies, there is an example like this:

[target.'cfg(target_arch = "x86")'.dependencies]
native = { path = "native/i686" }

[target.'cfg(target_arch = "x86_64")'.dependencies]
native = { path = "native/x86_64" }

but if I have that in my Cargo.toml and then try to build or run with cargo, I get:

error: failed to parse manifest at `/path/to/Cargo.toml`

Caused by:
  found duplicate dependency name native, but all
  dependencies must have a unique name

Is there a way to setup dependencies so that, for example, you could just write extern crate native and then cargo build takes care of building and linking the correct crate depending on the platform?

(I’d hate to have to resort to the old Makefile trick of having multiple sections commented out and expecting users to uncomment the appropriate section)

Also, can you use things beside target_arch in the target specifications, for example switching on features:

 [target.'cfg(feature = "foo")'.dependencies]
 [target.'cfg(not(feature = "foo")'.dependencies]