build.rs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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`
  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. #![warn(rust_2018_idioms, single_use_lifetimes)]
  13. use std::env;
  14. include!("no_atomic_cas.rs");
  15. fn main() {
  16. let target = match env::var("TARGET") {
  17. Ok(target) => target,
  18. Err(e) => {
  19. println!(
  20. "cargo:warning={}: unable to get TARGET environment variable: {}",
  21. env!("CARGO_PKG_NAME"),
  22. e
  23. );
  24. return;
  25. }
  26. };
  27. // Note that this is `no_*`, not `has_*`. This allows treating
  28. // `cfg(target_has_atomic = "ptr")` as true when the build script doesn't
  29. // run. This is needed for compatibility with non-cargo build systems that
  30. // don't run the build script.
  31. if NO_ATOMIC_CAS.contains(&&*target) {
  32. println!("cargo:rustc-cfg=futures_no_atomic_cas");
  33. }
  34. println!("cargo:rerun-if-changed=no_atomic_cas.rs");
  35. }