From e1025f1555561a24cd3c903384a6b9cd3978104f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Wed, 23 Mar 2016 17:28:54 +0100 Subject: [PATCH] Use serde serialization as a standalone feature This will prevent random build breaking due to two derives. --- Cargo.toml | 7 ++++--- src/gl_context_attributes.rs | 3 ++- src/gl_limits.rs | 3 ++- src/lib.rs | 7 ++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 48a3e64..d052522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "offscreen_gl_context" license = "MIT / Apache-2.0" version = "0.1.0" authors = ["ecoal95 ", "The Servo Project Developers"] -description = "Creation and manipulation of HW accelerated offscreen rendering contexts in multiple platforms. Originally intended for the Servo project WebGL implementation." +description = "Creation and manipulation of HW accelerated offscreen rendering contexts in multiple platforms. Originally intended for the Servo project's WebGL implementation." repository = "https://github.com/ecoal95/rust-offscreen-rendering-context" build = "build.rs" @@ -15,13 +15,14 @@ khronos_api = "1.0" [features] default = [] test_egl_in_linux = [] +serde_serialization = ["serde", "serde_macros"] [dependencies] log = "0.3.3" gleam = "0.2" euclid = "0.6.1" -serde = ">=0.6.1, <0.8" -serde_macros = ">=0.6.1, <0.8" +serde = { version = ">=0.6.1, <0.8", optional = true } +serde_macros = { version = ">=0.6.1, <0.8", optional = true } [target.x86_64-apple-darwin.dependencies] core-foundation = "0.2.0" diff --git a/src/gl_context_attributes.rs b/src/gl_context_attributes.rs index 8bc58c9..82f1ab3 100644 --- a/src/gl_context_attributes.rs +++ b/src/gl_context_attributes.rs @@ -1,7 +1,8 @@ /// This structure represents the attributes the context must support /// It's almost (if not) identical to WebGLGLContextAttributes -#[derive(Clone, Debug, Copy, Deserialize, Serialize)] +#[derive(Clone, Debug, Copy)] +#[cfg_attr(feature="serde_serialization", derive(Serialize, Deserialize))] pub struct GLContextAttributes { pub alpha: bool, pub depth: bool, diff --git a/src/gl_limits.rs b/src/gl_limits.rs index ff1fc9e..aeaf745 100644 --- a/src/gl_limits.rs +++ b/src/gl_limits.rs @@ -1,7 +1,8 @@ use gleam::gl::types::GLint; use gleam::gl; -#[derive(Clone, Deserialize, Serialize)] +#[derive(Clone)] +#[cfg_attr(feature="serde_serialization", derive(Serialize, Deserialize))] pub struct GLLimits { pub max_vertex_attribs: GLint, } diff --git a/src/lib.rs b/src/lib.rs index d05060c..ed5794f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,9 +1,10 @@ -#![feature(custom_derive)] -#![feature(plugin)] -#![plugin(serde_macros)] +#![cfg_attr(feature="serde_serialization", feature(plugin, custom_derive))] +#![cfg_attr(feature="serde_serialization", plugin(serde_macros))] extern crate gleam; extern crate euclid; + +#[cfg(feature="serde_serialization")] extern crate serde; #[cfg(target_os="linux")]