Debian Codegraph @

third_party/rust/async-trait/build.rs

raw
1 use std::env;
2 use std::process::Command;
3 use std::str;
4
5 fn main() {
6 println!("cargo:rerun-if-changed=build.rs");
7
8 let compiler = match rustc_minor_version() {
9 Some(compiler) => compiler,
10 None => return,
11 };
12
13 if compiler < 45 {
14 println!("cargo:rustc-cfg=no_span_mixed_site");
15 }
16
17 if compiler < 47 {
18 println!("cargo:rustc-cfg=self_span_hack");
19 }
20 }
21
22 fn rustc_minor_version() -> Option<u32> {
23 let rustc = env::var_os("RUSTC")?;
24 let output = Command::new(rustc).arg("--version").output().ok()?;
25 let version = str::from_utf8(&output.stdout).ok()?;
26 let mut pieces = version.split('.');
27 if pieces.next() != Some("rustc 1") {
28 return None;
29 }
30 pieces.next()?.parse().ok()
31 }