Skip to content

Commit

Permalink
Determine rust channel by parsing rustc output
Browse files Browse the repository at this point in the history
The RUSTUP_TOOLCHAIN environment variable might not always be present.
This is the case for e.g. NixOS where rust is routinely not installed via
rustup, thus not setting this env var, causing build failures.
Instead, build.rs will now run `rustc -V` and check if the output contains the
word "nightly".
  • Loading branch information
itsCryne committed Jul 12, 2024
1 parent 3d717b6 commit a2ef942
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions azalea/build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
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.");
let rustc_version_output = Command::new("rustc").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. If you have installed Rust with rustup you can use `rustup override set nightly` to set the toolchain for this directory.");
}
}

0 comments on commit a2ef942

Please sign in to comment.