1 #![warn(rust_2018_idioms)] 2 3 use std::env; 4 5 include!("no_atomic.rs"); 6 7 // The rustc-cfg strings below are *not* public API. Please let us know by 8 // opening a GitHub issue if your build environment requires some way to enable 9 // these cfgs other than by executing our build script. main()10fn main() { 11 let target = match env::var("TARGET") { 12 Ok(target) => target, 13 Err(e) => { 14 println!( 15 "cargo:warning={}: unable to get TARGET environment variable: {}", 16 env!("CARGO_PKG_NAME"), 17 e 18 ); 19 return; 20 } 21 }; 22 23 // Note that this is `no_*`, not `has_*`. This allows treating 24 // `cfg(target_has_atomic = "ptr")` as true when the build script doesn't 25 // run. This is needed for compatibility with non-cargo build systems that 26 // don't run the build script. 27 if NO_ATOMIC_CAS.contains(&&*target) { 28 println!("cargo:rustc-cfg=crossbeam_no_atomic_cas"); 29 } 30 if NO_ATOMIC.contains(&&*target) { 31 println!("cargo:rustc-cfg=crossbeam_no_atomic"); 32 println!("cargo:rustc-cfg=crossbeam_no_atomic_64"); 33 } else if NO_ATOMIC_64.contains(&&*target) { 34 println!("cargo:rustc-cfg=crossbeam_no_atomic_64"); 35 } else { 36 // Otherwise, assuming `"max-atomic-width" == 64`. 37 } 38 39 println!("cargo:rerun-if-changed=no_atomic.rs"); 40 } 41