• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // - `crossbeam_no_atomic`
11 //      Assume the target does *not* support any atomic operations.
12 //      This is usually detected automatically by the build script, but you may
13 //      need to enable it manually when building for custom targets or using
14 //      non-cargo build systems that don't run the build script.
15 //
16 // - `crossbeam_no_atomic_64`
17 //      Assume the target does *not* support AtomicU64/AtomicI64.
18 //      This is usually detected automatically by the build script, but you may
19 //      need to enable it manually when building for custom targets or using
20 //      non-cargo build systems that don't run the build script.
21 //
22 // With the exceptions mentioned above, the rustc-cfg emitted by the build
23 // script are *not* public API.
24 
25 #![warn(rust_2018_idioms)]
26 
27 use std::env;
28 
29 include!("no_atomic.rs");
30 
main()31 fn main() {
32     let target = match env::var("TARGET") {
33         Ok(target) => target,
34         Err(e) => {
35             println!(
36                 "cargo:warning={}: unable to get TARGET environment variable: {}",
37                 env!("CARGO_PKG_NAME"),
38                 e
39             );
40             return;
41         }
42     };
43 
44     // Note that this is `no_*`, not `has_*`. This allows treating
45     // `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
46     // run. This is needed for compatibility with non-cargo build systems that
47     // don't run the build script.
48     if NO_ATOMIC_CAS.contains(&&*target) {
49         println!("cargo:rustc-cfg=crossbeam_no_atomic_cas");
50     }
51     if NO_ATOMIC.contains(&&*target) {
52         println!("cargo:rustc-cfg=crossbeam_no_atomic");
53         println!("cargo:rustc-cfg=crossbeam_no_atomic_64");
54     } else if NO_ATOMIC_64.contains(&&*target) {
55         println!("cargo:rustc-cfg=crossbeam_no_atomic_64");
56     } else {
57         // Otherwise, assuming `"max-atomic-width" == 64` or `"max-atomic-width" == 128`.
58     }
59 
60     println!("cargo:rerun-if-changed=no_atomic.rs");
61 }
62