Joel Galenson | cc0890a | 2021-05-19 15:09:47 -0700 | [diff] [blame] | 1 | // The rustc-cfg listed below are considered public API, but it is *unstable* |
| 2 | // and outside of the normal semver guarantees: |
| 3 | // |
| 4 | // - `futures_no_atomic_cas` |
Joel Galenson | e869538 | 2021-08-09 10:29:26 -0700 | [diff] [blame] | 5 | // Assume the target does *not* support atomic CAS operations. |
Joel Galenson | cc0890a | 2021-05-19 15:09:47 -0700 | [diff] [blame] | 6 | // This is usually detected automatically by the build script, but you may |
| 7 | // need to enable it manually when building for custom targets or using |
| 8 | // non-cargo build systems that don't run the build script. |
| 9 | // |
David LeGare | f7dc9c1 | 2022-03-02 00:20:44 +0000 | [diff] [blame^] | 10 | // With the exceptions mentioned above, the rustc-cfg emitted by the build |
| 11 | // script are *not* public API. |
| 12 | |
| 13 | #![warn(rust_2018_idioms, single_use_lifetimes)] |
| 14 | |
| 15 | use std::env; |
| 16 | |
| 17 | include!("no_atomic_cas.rs"); |
| 18 | |
Joel Galenson | cc0890a | 2021-05-19 15:09:47 -0700 | [diff] [blame] | 19 | fn main() { |
| 20 | let target = match env::var("TARGET") { |
| 21 | Ok(target) => target, |
| 22 | Err(e) => { |
| 23 | println!( |
| 24 | "cargo:warning={}: unable to get TARGET environment variable: {}", |
| 25 | env!("CARGO_PKG_NAME"), |
| 26 | e |
| 27 | ); |
| 28 | return; |
| 29 | } |
| 30 | }; |
| 31 | |
| 32 | // Note that this is `no_*`, not `has_*`. This allows treating |
| 33 | // `cfg(target_has_atomic = "ptr")` as true when the build script doesn't |
| 34 | // run. This is needed for compatibility with non-cargo build systems that |
| 35 | // don't run the build script. |
David LeGare | f7dc9c1 | 2022-03-02 00:20:44 +0000 | [diff] [blame^] | 36 | if NO_ATOMIC_CAS.contains(&&*target) { |
Joel Galenson | cc0890a | 2021-05-19 15:09:47 -0700 | [diff] [blame] | 37 | println!("cargo:rustc-cfg=futures_no_atomic_cas"); |
| 38 | } |
| 39 | |
| 40 | println!("cargo:rerun-if-changed=no_atomic_cas.rs"); |
| 41 | } |