From 570d8cafdbbf31bc9535c3ff084013049668fd93 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:53:59 -0400 Subject: [PATCH] chore: add comments to build script --- bevy_lint/build.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bevy_lint/build.rs b/bevy_lint/build.rs index 941712c..6f4fe00 100644 --- a/bevy_lint/build.rs +++ b/bevy_lint/build.rs @@ -3,6 +3,7 @@ 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"); @@ -10,7 +11,11 @@ fn main() { .parse::() .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}"); }