| 1 |
// The rustc-cfg listed below are considered public API, but it is *unstable* |
| 2 |
// and outside of the normal semver guarantees: |
| 3 |
// |
| 4 |
// - `crossbeam_no_atomic_cas` |
| 5 |
// Assume the target does *not* support atomic CAS operations. |
| 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 |
// |
| 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)] |
| 14 |
|
| 15 |
use std::env; |
| 16 |
|
| 17 |
include!("no_atomic.rs"); |
| 18 |
include!("build-common.rs"); |
| 19 |
|
| 20 |
fn main() { |
| 21 |
let target = match env::var("TARGET") { |
| 22 |
Ok(target) => convert_custom_linux_target(target), |
| 23 |
Err(e) => { |
| 24 |
println!( |
| 25 |
"cargo:warning={}: unable to get TARGET environment variable: {}", |
| 26 |
env!("CARGO_PKG_NAME"), |
| 27 |
e |
| 28 |
); |
| 29 |
return; |
| 30 |
} |
| 31 |
}; |
| 32 |
|
| 33 |
let cfg = match autocfg::AutoCfg::new() { |
| 34 |
Ok(cfg) => cfg, |
| 35 |
Err(e) => { |
| 36 |
println!( |
| 37 |
"cargo:warning={}: unable to determine rustc version: {}", |
| 38 |
env!("CARGO_PKG_NAME"), |
| 39 |
e |
| 40 |
); |
| 41 |
return; |
| 42 |
} |
| 43 |
}; |
| 44 |
|
| 45 |
// Note that this is `no_`*, not `has_*`. This allows treating as the latest |
| 46 |
// stable rustc is used when the build script doesn't run. This is useful |
| 47 |
// for non-cargo build systems that don't run the build script. |
| 48 |
if NO_ATOMIC_CAS.contains(&&*target) { |
| 49 |
println!("cargo:rustc-cfg=crossbeam_no_atomic_cas"); |
| 50 |
} |
| 51 |
|
| 52 |
if !cfg.probe_rustc_version(1, 61) { |
| 53 |
println!("cargo:rustc-cfg=crossbeam_no_const_fn_trait_bound"); |
| 54 |
} |
| 55 |
|
| 56 |
println!("cargo:rerun-if-changed=no_atomic.rs"); |
| 57 |
} |