forked from TheBevyFlock/bevy_cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
21 lines (16 loc) · 800 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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()
.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}");
}