diff --git a/components/derive_common/Cargo.toml b/components/derive_common/Cargo.toml new file mode 100644 index 00000000000..2a4fac64405 --- /dev/null +++ b/components/derive_common/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "derive_common" +version = "0.0.1" +authors = ["The Servo Project Developers"] +license = "MPL-2.0" +publish = false + +[lib] +path = "lib.rs" + +[dependencies] +darling = "0.8" +proc-macro2 = "0.4" +quote = "0.6" +syn = { version = "0.15", features = ["visit"] } +synstructure = "0.10" diff --git a/components/style_derive/cg.rs b/components/derive_common/cg.rs similarity index 100% rename from components/style_derive/cg.rs rename to components/derive_common/cg.rs diff --git a/components/derive_common/lib.rs b/components/derive_common/lib.rs new file mode 100644 index 00000000000..1e8d20aa32d --- /dev/null +++ b/components/derive_common/lib.rs @@ -0,0 +1,14 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +extern crate darling; +extern crate proc_macro; +extern crate proc_macro2; +#[macro_use] +extern crate quote; +#[macro_use] +extern crate syn; +extern crate synstructure; + +pub mod cg; diff --git a/components/style_derive/Cargo.toml b/components/style_derive/Cargo.toml index 13bd8854948..38c68ac0e36 100644 --- a/components/style_derive/Cargo.toml +++ b/components/style_derive/Cargo.toml @@ -11,6 +11,7 @@ proc-macro = true [dependencies] darling = "0.8" +derive_common = { path = "../derive_common" } proc-macro2 = "0.4" quote = "0.6" syn = { version = "0.15", features = ["visit"] } diff --git a/components/style_derive/animate.rs b/components/style_derive/animate.rs index d9674e444c3..ccccdf9d0df 100644 --- a/components/style_derive/animate.rs +++ b/components/style_derive/animate.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::cg; use darling::util::IdentList; +use derive_common::cg; use proc_macro2::TokenStream; use quote::TokenStreamExt; use syn::{DeriveInput, Path, WhereClause}; diff --git a/components/style_derive/compute_squared_distance.rs b/components/style_derive/compute_squared_distance.rs index d8cf2f6dd18..68c8fdec4c5 100644 --- a/components/style_derive/compute_squared_distance.rs +++ b/components/style_derive/compute_squared_distance.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; -use crate::cg; +use derive_common::cg; use proc_macro2::TokenStream; use quote::TokenStreamExt; use syn::{DeriveInput, Path}; diff --git a/components/style_derive/lib.rs b/components/style_derive/lib.rs index 8631f2a33ea..85791c32783 100644 --- a/components/style_derive/lib.rs +++ b/components/style_derive/lib.rs @@ -6,6 +6,7 @@ #[macro_use] extern crate darling; +extern crate derive_common; extern crate proc_macro; extern crate proc_macro2; #[macro_use] @@ -17,7 +18,6 @@ extern crate synstructure; use proc_macro::TokenStream; mod animate; -mod cg; mod compute_squared_distance; mod parse; mod specified_value_info; diff --git a/components/style_derive/parse.rs b/components/style_derive/parse.rs index b9b7ae37e1c..80c214bd734 100644 --- a/components/style_derive/parse.rs +++ b/components/style_derive/parse.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::cg; use crate::to_css::CssVariantAttrs; +use derive_common::cg; use proc_macro2::TokenStream; use syn::{self, DeriveInput, Path}; use synstructure::{Structure, VariantInfo}; diff --git a/components/style_derive/specified_value_info.rs b/components/style_derive/specified_value_info.rs index 4fa11faca84..79e88e9459a 100644 --- a/components/style_derive/specified_value_info.rs +++ b/components/style_derive/specified_value_info.rs @@ -2,9 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::cg; use crate::parse::ParseVariantAttrs; use crate::to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs}; +use derive_common::cg; use proc_macro2::TokenStream; use quote::TokenStreamExt; use syn::{Data, DeriveInput, Fields, Ident, Type}; diff --git a/components/style_derive/to_animated_value.rs b/components/style_derive/to_animated_value.rs index 1aba9b3327e..17c313e1ed0 100644 --- a/components/style_derive/to_animated_value.rs +++ b/components/style_derive/to_animated_value.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::cg; +use derive_common::cg; use proc_macro2::{Span, TokenStream}; use syn::{DeriveInput, Ident}; use synstructure::BindStyle; diff --git a/components/style_derive/to_animated_zero.rs b/components/style_derive/to_animated_zero.rs index 523ef9b7a9f..6f0c2fe7ff2 100644 --- a/components/style_derive/to_animated_zero.rs +++ b/components/style_derive/to_animated_zero.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; -use crate::cg; +use derive_common::cg; use proc_macro2::TokenStream; use quote::TokenStreamExt; use syn; diff --git a/components/style_derive/to_computed_value.rs b/components/style_derive/to_computed_value.rs index b0b2aa6af63..21efae17c66 100644 --- a/components/style_derive/to_computed_value.rs +++ b/components/style_derive/to_computed_value.rs @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::cg; +use derive_common::cg; use proc_macro2::{Span, TokenStream}; use syn::{DeriveInput, Ident}; use synstructure::BindStyle; diff --git a/components/style_derive/to_css.rs b/components/style_derive/to_css.rs index 249ff2969cd..dfd5bc8193f 100644 --- a/components/style_derive/to_css.rs +++ b/components/style_derive/to_css.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use crate::cg; use darling::util::Override; +use derive_common::cg; use proc_macro2::TokenStream; use quote::{ToTokens, TokenStreamExt}; use syn::{self, Data, Path, WhereClause};