• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use std::env;
2 use std::process::Command;
3 use std::str;
4 
main()5 fn main() {
6     println!("cargo:rerun-if-changed=build.rs");
7 
8     let minor = match rustc_minor_version() {
9         Some(n) => n,
10         None => return,
11     };
12 
13     if minor >= 27 {
14         println!("cargo:rustc-cfg=crc32fast_stdarchx86");
15     }
16 }
17 
rustc_minor_version() -> Option<u32>18 fn rustc_minor_version() -> Option<u32> {
19     macro_rules! otry {
20         ($e:expr) => {
21             match $e {
22                 Some(e) => e,
23                 None => return None,
24             }
25         };
26     }
27     let rustc = otry!(env::var_os("RUSTC"));
28     let output = otry!(Command::new(rustc).arg("--version").output().ok());
29     let version = otry!(str::from_utf8(&output.stdout).ok());
30     let mut pieces = version.split('.');
31     if pieces.next() != Some("rustc 1") {
32         return None;
33     }
34     otry!(pieces.next()).parse().ok()
35 }
36