Skip to content

Commit f1c8dfa

Browse files
committed
implement build.rs for rustc_public
1 parent d37b6e0 commit f1c8dfa

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

build.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use std::process::{self, Command};
2+
use std::{env, str};
3+
4+
use rustversion;
5+
6+
const MSRV: &str = "2025-08-09";
7+
const SUPPORTED: bool = rustversion::cfg!(since(2025-08-09));
8+
9+
fn main() {
10+
if !SUPPORTED {
11+
let current = rustc_version().unwrap_or(String::from("unknown"));
12+
eprintln!(
13+
"\nERROR: rustc_public requires rustc nightly-{MSRV} or newer\n\
14+
current: {current}\n\
15+
help: run `rustup update nightly`.\n"
16+
);
17+
process::exit(1);
18+
}
19+
println!("cargo:rerun-if-changed=build.rs");
20+
}
21+
22+
fn rustc_version() -> Option<String> {
23+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| {
24+
eprintln!("RUSTC is not set during build script execution.\n");
25+
process::exit(1);
26+
});
27+
let output = Command::new(rustc).arg("--version").output().ok()?;
28+
let version = str::from_utf8(&output.stdout).ok()?;
29+
version.parse().ok()
30+
}

rust-toolchain.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[toolchain]
2-
channel = "nightly"
32
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]

0 commit comments

Comments
 (0)