]> git.proxmox.com Git - rustc.git/blob - vendor/serde_derive/build.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / vendor / serde_derive / build.rs
1 use std::env;
2 use std::process::Command;
3 use std::str;
4
5 // The rustc-cfg strings below are *not* public API. Please let us know by
6 // opening a GitHub issue if your build environment requires some way to enable
7 // these cfgs other than by executing our build script.
8 fn main() {
9 let minor = match rustc_minor_version() {
10 Some(minor) => minor,
11 None => return,
12 };
13
14 // Underscore const names stabilized in Rust 1.37:
15 // https://blog.rust-lang.org/2019/08/15/Rust-1.37.0.html#using-unnamed-const-items-for-macros
16 if minor >= 37 {
17 println!("cargo:rustc-cfg=underscore_consts");
18 }
19 }
20
21 fn rustc_minor_version() -> Option<u32> {
22 let rustc = env::var_os("RUSTC")?;
23 let output = Command::new(rustc).arg("--version").output().ok()?;
24 let version = str::from_utf8(&output.stdout).ok()?;
25 let mut pieces = version.split('.');
26 if pieces.next() != Some("rustc 1") {
27 return None;
28 }
29 pieces.next()?.parse().ok()
30 }