Debian Codegraph @

build.rs

raw symbols SCIP
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 >= 80 {
14 println!("cargo:rustc-check-cfg=cfg(no_const_type_id)");
15 }
16
17 if compiler < 61 {
18 // Function pointer casting in const fn.
19 // https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html#more-capabilities-for-const-fn
20 println!("cargo:rustc-cfg=no_const_type_id");
21 }
22 }
23
24 fn rustc_minor_version() -> Option<u32> {
25 let rustc = env::var_os("RUSTC")?;
26 let output = Command::new(rustc).arg("--version").output().ok()?;
27 let version = str::from_utf8(&output.stdout).ok()?;
28 let mut pieces = version.split('.');
29 if pieces.next() != Some("rustc 1") {
30 return None;
31 }
32 pieces.next()?.parse().ok()
33 }