blob: 9dd6b73810f0f2d86622afec4fc73672f4775897 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use std::{env, process::Command};
fn main() {
check_nightly();
// save the optimization level, used by the pathfinder to warn if optimizations
// are off
println!(
"cargo::rustc-env=OPT_LEVEL={}",
env::var("OPT_LEVEL").unwrap()
);
}
fn check_nightly() {
// If using `rustup`, check the toolchain via `RUSTUP_TOOLCHAIN`
if let Ok(toolchain) = env::var("RUSTUP_TOOLCHAIN") {
if toolchain.contains("nightly") {
return;
} else {
panic!(
"Azalea currently requires nightly Rust. You can run `rustup override set nightly` to set the toolchain for this directory."
);
}
}
// Get the path to the Rust compiler, defaulting to `rustc`
let rustc_path = env::var("RUSTC")
.or_else(|_| env::var("CARGO_BUILD_RUSTC"))
.unwrap_or(String::from("rustc"));
// Run `rustc -V` to check the toolchain version
let rustc_command = Command::new(&rustc_path).arg("-V").output().unwrap();
if rustc_command.status.success() {
let rustc_output = String::from_utf8(rustc_command.stdout).unwrap();
if !rustc_output.contains("nightly") {
panic!(
"Azalea currently requires nightly Rust. Please check the documentation for your installation method and ensure you are using the nightly toolchain."
);
}
} else {
let rustc_output = String::from_utf8(rustc_command.stderr).unwrap();
panic!("Failed to run `{rustc_path} -V` to check the toolchain version, {rustc_output}");
}
}
|