build.rs 961 B

1234567891011121314151617181920212223242526272829
  1. extern crate autocfg;
  2. use std::env;
  3. fn main() {
  4. let ac = autocfg::new();
  5. // If the "i128" feature is explicity requested, don't bother probing for it.
  6. // It will still cause a build error if that was set improperly.
  7. if env::var_os("CARGO_FEATURE_I128").is_some() || ac.probe_type("i128") {
  8. autocfg::emit("has_i128");
  9. }
  10. if env::var_os("CARGO_FEATURE_COPYSIGN").is_some() || ac.probe_expression("f32::copysign") {
  11. autocfg::emit("has_copysign");
  12. }
  13. ac.emit_expression_cfg(
  14. "unsafe { 1f64.to_int_unchecked::<i32>() }",
  15. "has_to_int_unchecked",
  16. );
  17. ac.emit_expression_cfg("1u32.reverse_bits()", "has_reverse_bits");
  18. ac.emit_expression_cfg("1u32.trailing_ones()", "has_leading_trailing_ones");
  19. ac.emit_expression_cfg("{ let mut x = 1; x += &2; }", "has_int_assignop_ref");
  20. ac.emit_expression_cfg("1u32.div_euclid(1u32)", "has_div_euclid");
  21. autocfg::rerun_path("build.rs");
  22. }