blob: b2de2dc8684256f49afc5ba971244e7f99c3699a [file] [log] [blame]
Austin Schuh6ea9bfa2023-08-06 19:05:10 -07001// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9// It would be nice to use the rustversion crate here instead,
10// but that doesn't work with inner attributes.
11fn main() {
12 if let Some(ver) = rustc_version() {
13 if ver.contains("nightly") {
14 println!("cargo:rustc-cfg=nightly")
15 }
16 }
17}
18
19fn rustc_version() -> Option<String> {
20 let rustc = std::env::var_os("RUSTC")?;
21 let output = std::process::Command::new(rustc)
22 .arg("--version")
23 .output()
24 .ok()?;
25 let version = String::from_utf8(output.stdout).ok()?;
26 Some(version)
27}