From 34a62da8bad60b8983f8dfe9d4a14f2c4cfa9e81 Mon Sep 17 00:00:00 2001 From: Avril Date: Mon, 12 Oct 2020 07:24:34 +0100 Subject: [PATCH] empty build.rs --- Cargo.lock | 1 + Cargo.toml | 3 +++ build.rs | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 build.rs diff --git a/Cargo.lock b/Cargo.lock index 0f1600b..1784f20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -630,6 +630,7 @@ dependencies = [ "once_cell", "pin-project", "pretty_env_logger", + "rustc_version", "serde", "serde_cbor", "smallmap", diff --git a/Cargo.toml b/Cargo.toml index 46139af..43e1b01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,3 +67,6 @@ smallmap = "1.1.5" lazy_static = "1.4.0" once_cell = "1.4.1" bzip2-sys = {version = "0.1.9", optional = true} + +[build-dependencies] +rustc_version = "0.2" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..b753838 --- /dev/null +++ b/build.rs @@ -0,0 +1,26 @@ + +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"); + } + } + + //println!("cargo:rustc-link-lib=static=bz2"); // TODO: Make this conditional for `compress-chain` +}