From 03294f82fd6a94a82aa5153d0cecccadbe99546b Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 27 May 2019 16:02:46 -0700 Subject: [PATCH 1/3] Add some hints to the docs for `cfg()` targets https://users.rust-lang.org/t/what-cfg-expressions-are-expected-to-work-in-cargo-toml-quoted-targets/28662 --- src/doc/src/reference/specifying-dependencies.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/doc/src/reference/specifying-dependencies.md b/src/doc/src/reference/specifying-dependencies.md index 049553f9cf5..5986dcc0610 100644 --- a/src/doc/src/reference/specifying-dependencies.md +++ b/src/doc/src/reference/specifying-dependencies.md @@ -461,6 +461,19 @@ Like with Rust, the syntax here supports the `not`, `any`, and `all` operators to combine various cfg name/value pairs. Note that the `cfg` syntax has only been available since Cargo 0.9.0 (Rust 1.8.0). +If you want to know which cfg targets are available on your platform, run +`rustc --print=cfg` from the command line. If you want to know which `cfg` +targets are available for another platform, such as 64-bit Windows, +run `rustc --print=cfg --target=x86_64-pc-windows-msvc`. +If you want to know which cfg targets are used by the release profile, +add the `-O` parameter. + +This same set of values is used throughout the build for all crates in your project, +so, unlike in your Rust source code, +you cannot use `[target.'cfg(feature = "my_crate")'.dependencies]` to add +dependencies based on optional crate features. +Use [the `[features]` section](manifest.md#the-features-section) instead. + In addition to `#[cfg]` syntax, Cargo also supports listing out the full target the dependencies would apply to: From f2663baef31177fa52709a415b32186e970b64b6 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 28 May 2019 10:59:15 -0700 Subject: [PATCH 2/3] Update specifying-dependencies.md --- src/doc/src/reference/specifying-dependencies.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/doc/src/reference/specifying-dependencies.md b/src/doc/src/reference/specifying-dependencies.md index 5986dcc0610..c8e6660a25e 100644 --- a/src/doc/src/reference/specifying-dependencies.md +++ b/src/doc/src/reference/specifying-dependencies.md @@ -465,11 +465,8 @@ If you want to know which cfg targets are available on your platform, run `rustc --print=cfg` from the command line. If you want to know which `cfg` targets are available for another platform, such as 64-bit Windows, run `rustc --print=cfg --target=x86_64-pc-windows-msvc`. -If you want to know which cfg targets are used by the release profile, -add the `-O` parameter. -This same set of values is used throughout the build for all crates in your project, -so, unlike in your Rust source code, +Unlike in your Rust source code, you cannot use `[target.'cfg(feature = "my_crate")'.dependencies]` to add dependencies based on optional crate features. Use [the `[features]` section](manifest.md#the-features-section) instead. From 69f9adbe12cdb6f3508ba0e1f0c62ce101cec898 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 28 May 2019 15:00:47 -0700 Subject: [PATCH 3/3] Link cfg, remove old note, fix link. --- src/doc/src/reference/specifying-dependencies.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/doc/src/reference/specifying-dependencies.md b/src/doc/src/reference/specifying-dependencies.md index c8e6660a25e..da28bd07206 100644 --- a/src/doc/src/reference/specifying-dependencies.md +++ b/src/doc/src/reference/specifying-dependencies.md @@ -440,7 +440,8 @@ Cargo how to find local unpublished crates. Platform-specific dependencies take the same format, but are listed under a -`target` section. Normally Rust-like `#[cfg]` syntax will be used to define +`target` section. Normally Rust-like [`#[cfg]` +syntax](../reference/conditional-compilation.html) will be used to define these sections: ```toml @@ -458,8 +459,7 @@ native = { path = "native/x86_64" } ``` Like with Rust, the syntax here supports the `not`, `any`, and `all` operators -to combine various cfg name/value pairs. Note that the `cfg` syntax has only -been available since Cargo 0.9.0 (Rust 1.8.0). +to combine various cfg name/value pairs. If you want to know which cfg targets are available on your platform, run `rustc --print=cfg` from the command line. If you want to know which `cfg` @@ -469,7 +469,8 @@ run `rustc --print=cfg --target=x86_64-pc-windows-msvc`. Unlike in your Rust source code, you cannot use `[target.'cfg(feature = "my_crate")'.dependencies]` to add dependencies based on optional crate features. -Use [the `[features]` section](manifest.md#the-features-section) instead. +Use [the `[features]` section](reference/manifest.html#the-features-section) +instead. In addition to `#[cfg]` syntax, Cargo also supports listing out the full target the dependencies would apply to: