Skip to content

Commit c0ee0da

Browse files
stepanchegfacebook-github-bot
authored andcommitted
--cfg=rustc_nightly in Cargo builds
Reviewed By: ndmitchell Differential Revision: D41061862 fbshipit-source-id: 53006710077fee535c41e3c958ec8a73f385dc78
1 parent c2f6fe0 commit c0ee0da

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

starlark/build.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
fn main() {
1919
lalrpop();
20+
rust_nightly();
2021
}
2122

2223
fn lalrpop() {
@@ -28,3 +29,25 @@ fn lalrpop() {
2829
.process_file(source)
2930
.unwrap();
3031
}
32+
33+
fn rust_nightly() {
34+
let rustc = std::env::var("RUSTC").unwrap();
35+
let version = std::process::Command::new(rustc)
36+
.arg("--version")
37+
.output()
38+
.unwrap();
39+
40+
assert!(version.status.success());
41+
42+
// Nightly output:
43+
// rustc 1.64.0-nightly (affe0d3a0 2022-08-05)
44+
// Stable output:
45+
// rustc 1.64.0 (a55dd71d5 2022-09-19)
46+
47+
let stdout = String::from_utf8(version.stdout).unwrap();
48+
assert!(stdout.contains("rustc"), "Sanity check");
49+
let nightly = stdout.contains("nightly");
50+
if nightly {
51+
println!("cargo:rustc-cfg=rust_nightly");
52+
}
53+
}

0 commit comments

Comments
 (0)