From 141292ad914e05016a897c87e91e628cdae5ed22 Mon Sep 17 00:00:00 2001 From: theduke Date: Sat, 2 Dec 2017 02:27:41 +0100 Subject: [PATCH] Export codegen from main juniper crate Use a trick for re-exporting proc-macros to supply juniper_derive as a dependency of juniper. Users will now just have to depend on juniper directly. --- juniper/Cargo.toml | 13 +++++++++++-- juniper/src/lib.rs | 11 +++++++++++ juniper_codegen/Cargo.toml | 4 ++-- juniper_tests/Cargo.toml | 3 +-- juniper_tests/src/lib.rs | 2 -- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/juniper/Cargo.toml b/juniper/Cargo.toml index 7450bd9b..689b6a68 100644 --- a/juniper/Cargo.toml +++ b/juniper/Cargo.toml @@ -20,16 +20,25 @@ harness = false path = "benches/bench.rs" [features] +codegen = ["juniper_codegen"] nightly = [] expose-test-schema = [] -default = ["chrono", "url", "uuid"] +default = [ + "codegen", + "chrono", + "url", + "uuid" +] [dependencies] +juniper_codegen = { version = "0.8.1", path = "../juniper_codegen" , optional = true} + fnv = "1.0.3" -chrono = { version = "^0.4.0", optional = true } ordermap = { version = "^0.2.11", features = ["serde-1"] } serde = { version = "^1.0.8" } serde_derive = {version="^1.0.8" } + +chrono = { version = "^0.4.0", optional = true } serde_json = { version="^1.0.2", optional = true } url = { version = "^1.5.1", optional = true } uuid = { version = "0.5.1", optional = true } diff --git a/juniper/src/lib.rs b/juniper/src/lib.rs index da27c845..dfbe8965 100644 --- a/juniper/src/lib.rs +++ b/juniper/src/lib.rs @@ -136,6 +136,17 @@ extern crate url; #[cfg(any(test, feature = "uuid"))] extern crate uuid; +// If the "codegen" feature is enabled, depend on juniper_codegen and re-export everything in it. +// This allows users to just depend on juniper and get the derive funcationality automatically. +#[cfg(feature = "codegen")] +#[allow(unused_imports)] +#[macro_use] +extern crate juniper_codegen; + +#[cfg(feature = "codegen")] +#[doc(hidden)] +pub use juniper_codegen::*; + use std::borrow::Cow; #[macro_use] diff --git a/juniper_codegen/Cargo.toml b/juniper_codegen/Cargo.toml index b7b13fa8..bb235925 100644 --- a/juniper_codegen/Cargo.toml +++ b/juniper_codegen/Cargo.toml @@ -11,8 +11,8 @@ repository = "https://github.com/graphql-rust/juniper" proc-macro = true [dependencies] -syn = "0.11.11" -quote = "0.3.15" +syn = "0.11" +quote = "0.3" [badges] travis-ci = { repository = "graphql-rust/juniper" } diff --git a/juniper_tests/Cargo.toml b/juniper_tests/Cargo.toml index dcfa9f1c..7b87fa78 100644 --- a/juniper_tests/Cargo.toml +++ b/juniper_tests/Cargo.toml @@ -4,8 +4,7 @@ version = "0.1.0" [dependencies] juniper = { path = "../juniper" } -juniper_codegen = { path = "../juniper_codegen" } -serde_json = { version = "^1.0.2" } +serde_json = { version = "1" } [dev-dependencies] fnv = "1.0.3" diff --git a/juniper_tests/src/lib.rs b/juniper_tests/src/lib.rs index 6f0a6e98..c4fc104c 100644 --- a/juniper_tests/src/lib.rs +++ b/juniper_tests/src/lib.rs @@ -1,7 +1,5 @@ #[macro_use] extern crate juniper; -#[macro_use] -extern crate juniper_codegen; extern crate serde_json; #[cfg(test)]