Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine rust channel by parsing rustc output if env vars do not exist #163

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions azalea/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
use std::env;
use std::process::Command;

fn main() {
let rust_toolchain = env::var("RUSTUP_TOOLCHAIN").unwrap();
if rust_toolchain.starts_with("stable") {
panic!("Azalea currently requires nightly Rust. You can use `rustup override set nightly` to set the toolchain for this directory.");
match env::var("RUSTUP_TOOLCHAIN") {
Ok(rust_toolchain) if !rust_toolchain.starts_with("nightly") => { // stable & beta
panic!("Azalea currently requires nightly Rust. You can use `rustup override set nightly` to set the toolchain for this directory.");
}
Ok(_) => return, // nightly
Err(_) => { // probably not installed via rustup, run rustc and parse its output
let rustc_command = env::var("RUSTC")
.or_else(|_| env::var("CARGO_BUILD_RUSTC"))
.unwrap_or(String::from("rustc"));
let rustc_version_output = Command::new(rustc_command).arg("-V").output().unwrap();
if !rustc_version_output.status.success()
|| !String::from_utf8(rustc_version_output.stdout)
.unwrap()
.contains("nightly")
{
panic!("Azalea currently requires nightly Rust. It seems that you did not install Rust via rustup. Please check the documentation for your installation method, to find out how to use nightly Rust.");
}
}
}
}
Loading