From a01e3377a5ad2cf3fc960aa32458b94c0b7c66fd Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 3 Aug 2020 00:29:16 +0100 Subject: [PATCH] fucking fuk --- Cargo.toml | 5 ++++- build.rs | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index ae28f4c..eef1425 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,5 +24,8 @@ memmap = "0.7" getrandom = "0.1" base64 = "0.12" -[target.'cfg(not(nightly))'.dependencies] +[build-dependencies] +rustc_version = "0.2" + +[target.'cfg(not(nightly))'.dependencies] # Fuck this. Just. Fuck. It. linked-list = "0.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..6399463 --- /dev/null +++ b/build.rs @@ -0,0 +1,24 @@ + +extern crate rustc_version; +use rustc_version::{version, version_meta, Channel}; + +fn main() { + // Assert we haven't travelled back in time + assert!(version().unwrap().major >= 1); + + // Set cfg flags depending on release channel + match version_meta().unwrap().channel { + Channel::Stable => { + println!("cargo:rustc-cfg=stable"); + } + Channel::Beta => { + println!("cargo:rustc-cfg=beta"); + } + Channel::Nightly => { + println!("cargo:rustc-cfg=nightly"); + } + Channel::Dev => { + println!("cargo:rustc-cfg=dev"); + } + } +}