Debian Codegraph @

debian/missing-sources/crossbeam-utils/build.rs

raw
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`
5 // Assume the target does *not* support any atomic 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 println!("cargo:rerun-if-changed=no_atomic.rs");
22 println!("cargo:rustc-check-cfg=cfg(crossbeam_no_atomic,crossbeam_sanitize_thread)");
23
24 let target = match env::var("TARGET") {
25 Ok(target) => convert_custom_linux_target(target),
26 Err(e) => {
27 println!(
28 "cargo:warning={}: unable to get TARGET environment variable: {}",
29 env!("CARGO_PKG_NAME"),
30 e
31 );
32 return;
33 }
34 };
35
36 // Note that this is `no_`*, not `has_*`. This allows treating as the latest
37 // stable rustc is used when the build script doesn't run. This is useful
38 // for non-cargo build systems that don't run the build script.
39 if NO_ATOMIC.contains(&&*target) {
40 println!("cargo:rustc-cfg=crossbeam_no_atomic");
41 }
42
43 // `cfg(sanitize = "..")` is not stabilized.
44 let sanitize = env::var("CARGO_CFG_SANITIZE").unwrap_or_default();
45 if sanitize.contains("thread") {
46 println!("cargo:rustc-cfg=crossbeam_sanitize_thread");
47 }
48 }