Skip to content

Commit

Permalink
chore: add comments to build script
Browse files Browse the repository at this point in the history
  • Loading branch information
BD103 committed Sep 30, 2024
1 parent 4639388 commit 570d8ca
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bevy_lint/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@ use toml_edit::DocumentMut;
const RUST_TOOLCHAIN: &str = include_str!("../rust-toolchain.toml");

fn main() {
// Only re-run this build script if its source or `rust-toolchain.toml` was modified.
println!("cargo::rerun-if-changed=build.rs");
println!("cargo::rerun-if-changed=../rust-toolchain.toml");

let rust_toolchain = RUST_TOOLCHAIN
.parse::<DocumentMut>()
.expect("Failed to parse `rust-toolchain.toml`.");

let channel = rust_toolchain["toolchain"]["channel"].as_str().unwrap();
let channel = rust_toolchain["toolchain"]["channel"]
.as_str()
.expect("Could not find `toolchain.channel` key in `rust-toolchain.toml`.");

// Emit the toolchain channel as an environmental variable that the crate can access using the
// `env!()` macro.
println!("cargo::rustc-env=RUST_TOOLCHAIN_CHANNEL={channel}");
}

0 comments on commit 570d8ca

Please sign in to comment.