From 6a664f58fee06df92d7d63e6e1ef210bd560be03 Mon Sep 17 00:00:00 2001 From: Xudong Huang Date: Fri, 1 Sep 2017 11:01:56 +0800 Subject: [PATCH] :gift: add nightly detection build --- Cargo.toml | 7 +++++++ build.rs | 11 +++++++++++ src/lib.rs | 14 +++++++------- 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 build.rs diff --git a/Cargo.toml b/Cargo.toml index 0e242f9..e964601 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,13 @@ description = "Generator Library in Rust" readme = "README.md" keywords = ["generator", "coroutine", "green", "thread", "fiber"] categories = ["data-structures", "algorithms"] +build = "build.rs" + +[dependencies] +log = "0.3" + +[build-dependencies] +rustc_version = "0.2" [profile.release] opt-level=3 diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..68c9f1c --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +extern crate rustc_version; +use rustc_version::{version_meta, Channel}; + +fn main() { + // Set cfg flags depending on release channel + if let Channel::Nightly = version_meta().unwrap().channel { + return println!("cargo:rustc-cfg=nightly"); + } + + panic!("stable build is not supported now!"); +} diff --git a/src/lib.rs b/src/lib.rs index fb0657b..6716f44 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,19 +3,19 @@ //! Rust generator library //! -#![feature(asm)] -#![feature(alloc)] -#![feature(fnbox)] -#![feature(rustc_private)] -#![feature(naked_functions)] -#![feature(core_intrinsics)] -#![feature(repr_simd)] +#![cfg_attr(nightly, feature(asm))] +#![cfg_attr(nightly, feature(alloc))] +#![cfg_attr(nightly, feature(fnbox))] +#![cfg_attr(nightly, feature(naked_functions))] +#![cfg_attr(nightly, feature(core_intrinsics))] +#![cfg_attr(nightly, feature(repr_simd))] #![cfg_attr(test, deny(warnings))] #![deny(missing_docs)] #[macro_use] extern crate log; +#[cfg(nightly)] extern crate alloc; mod rt;