1 | use std::process::Command; |
2 | |
3 | fn main() { |
4 | if let Ok(v) = Command::new("rustc" ).arg("--version" ).output() { |
5 | let s = match String::from_utf8(v.stdout) { |
6 | Ok(s) => s, |
7 | _ => return, |
8 | }; |
9 | if !s.starts_with("rustc " ) { |
10 | return; |
11 | } |
12 | if let Some(s) = s.split(' ' ).skip(1).next() { |
13 | let s = s.split('.' ).collect::<Vec<_>>(); |
14 | if s.len() < 3 { |
15 | return; |
16 | } |
17 | if s[0] == "1" && u32::from_str_radix(&s[1], 10) |
18 | .map(|nb| nb < 30) |
19 | .unwrap_or_else(|_| false) { |
20 | println!("cargo:rustc-cfg=feature= \"old_macros \"" ); |
21 | } |
22 | } |
23 | } |
24 | } |