diff --git a/Cargo.toml b/Cargo.toml index fe75df7..1b5587b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,9 @@ relm = "0.10" relm-derive = "0.10" shakmaty = "0.4" +[build-dependencies] +version_check = "0.1" + [dev-dependencies] rand = "0.3" relm-attributes = "0.10" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..3f9d25b --- /dev/null +++ b/build.rs @@ -0,0 +1,26 @@ +// This file is part of the chessground library. +// Copyright (C) 2017 Niklas Fiekas +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +extern crate version_check; + +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + // detect support for nightly features + if let Some(true) = version_check::supports_features() { + println!("cargo:rustc-cfg=nightly"); + } +} diff --git a/src/boardstate.rs b/src/boardstate.rs index 70a7637..15d4114 100644 --- a/src/boardstate.rs +++ b/src/boardstate.rs @@ -16,6 +16,7 @@ use std::f64::consts::PI; +#[cfg(not(nightly))] use option_filter::OptionFilterExt; use cairo::prelude::*; diff --git a/src/ground.rs b/src/ground.rs index dec39fd..08bc323 100644 --- a/src/ground.rs +++ b/src/ground.rs @@ -20,6 +20,7 @@ use std::f64::consts::PI; use std::cmp::{min, max}; use std::fmt; +#[cfg(not(nightly))] use option_filter::OptionFilterExt; use gtk; diff --git a/src/lib.rs b/src/lib.rs index 059fcc5..8c0d9d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,6 +20,8 @@ #![warn(missing_debug_implementations)] +#![cfg_attr(nightly, feature(option_filter))] + extern crate gtk; extern crate gdk; extern crate cairo; diff --git a/src/pieces.rs b/src/pieces.rs index f8e8e86..4831e15 100644 --- a/src/pieces.rs +++ b/src/pieces.rs @@ -16,6 +16,7 @@ use std::f64::consts::PI; +#[cfg(not(nightly))] use option_filter::OptionFilterExt; use time::SteadyTime; diff --git a/src/promotable.rs b/src/promotable.rs index 38f884a..3b74a5b 100644 --- a/src/promotable.rs +++ b/src/promotable.rs @@ -16,6 +16,7 @@ use std::f64::consts::PI; +#[cfg(not(nightly))] use option_filter::OptionFilterExt; use time::SteadyTime;