From 9a79e8e2c97f7762b3c3a779cc1d98561ab95937 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Sun, 5 Jan 2025 20:03:29 +0100 Subject: [PATCH] Decouple component and field macro crates from the library crates (#47) * Decouple cgp-component-macro crate from cgp-component * Decouple cgp-field-macro from cgp-field * Reformat Cargo.toml files * Add changelog --- CHANGELOG.md | 6 ++++++ Cargo.lock | 15 ++++++++------- crates/cgp-async-macro/Cargo.toml | 4 ++-- crates/cgp-async/Cargo.toml | 2 +- crates/cgp-component-macro-lib/Cargo.toml | 10 +++++----- crates/cgp-component-macro/Cargo.toml | 3 +-- crates/cgp-component/Cargo.toml | 1 - crates/cgp-component/src/lib.rs | 3 --- crates/cgp-core/Cargo.toml | 14 ++++++++------ crates/cgp-core/src/prelude.rs | 9 ++++----- crates/cgp-error-std/Cargo.toml | 2 +- crates/cgp-error/Cargo.toml | 7 ++++--- crates/cgp-error/src/can_raise_error.rs | 3 ++- crates/cgp-error/src/has_error_type.rs | 3 ++- crates/cgp-extra/Cargo.toml | 2 +- crates/cgp-field-macro-lib/Cargo.toml | 10 +++++----- crates/cgp-field-macro/Cargo.toml | 2 +- crates/cgp-field/Cargo.toml | 1 - crates/cgp-field/src/lib.rs | 1 - crates/cgp-inner/Cargo.toml | 3 ++- crates/cgp-inner/src/lib.rs | 3 ++- crates/cgp-run/Cargo.toml | 7 ++++--- crates/cgp-run/src/lib.rs | 1 + crates/cgp-type/Cargo.toml | 3 ++- crates/cgp-type/src/traits/has_type.rs | 3 ++- 25 files changed, 64 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51dc084..0cc9d8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v0.3.0 (pre-release) + +- Decouple component and field macro crates from the library crates - [#47](https://github.com/contextgeneric/cgp/pull/47) + - Remove `cgp-component-macro` crate from being a dependency of `cgp-component`. + - Remove `cgp-field-macro` crate from being a dependency of `cgp-field`. + ## v0.2.0 (2025-12-08) - Rename `define_components!` to `cgp_preset!` with slight improvement - [#41](https://github.com/contextgeneric/cgp/pull/41) diff --git a/Cargo.lock b/Cargo.lock index f4540ed..808fcb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -31,16 +31,12 @@ dependencies = [ [[package]] name = "cgp-component" version = "0.2.0" -dependencies = [ - "cgp-component-macro", -] [[package]] name = "cgp-component-macro" version = "0.2.0" dependencies = [ "cgp-component-macro-lib", - "proc-macro2", ] [[package]] @@ -60,8 +56,10 @@ version = "0.2.0" dependencies = [ "cgp-async", "cgp-component", + "cgp-component-macro", "cgp-error", "cgp-field", + "cgp-field-macro", "cgp-inner", "cgp-type", ] @@ -72,6 +70,7 @@ version = "0.2.0" dependencies = [ "cgp-async", "cgp-component", + "cgp-component-macro", "cgp-type", ] @@ -102,7 +101,6 @@ name = "cgp-field" version = "0.2.0" dependencies = [ "cgp-component", - "cgp-field-macro", "cgp-type", ] @@ -130,6 +128,7 @@ name = "cgp-inner" version = "0.2.0" dependencies = [ "cgp-component", + "cgp-component-macro", ] [[package]] @@ -138,6 +137,7 @@ version = "0.2.0" dependencies = [ "cgp-async", "cgp-component", + "cgp-component-macro", "cgp-error", ] @@ -153,6 +153,7 @@ name = "cgp-type" version = "0.2.0" dependencies = [ "cgp-component", + "cgp-component-macro", ] [[package]] @@ -222,9 +223,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" dependencies = [ "proc-macro2", "quote", diff --git a/crates/cgp-async-macro/Cargo.toml b/crates/cgp-async-macro/Cargo.toml index d7c24c3..a36897d 100644 --- a/crates/cgp-async-macro/Cargo.toml +++ b/crates/cgp-async-macro/Cargo.toml @@ -17,6 +17,6 @@ proc-macro = true [features] [dependencies] -syn = { version = "2.0.90", features = [ "full" ] } -quote = "1.0.33" +syn = { version = "2.0.90", features = [ "full" ] } +quote = "1.0.33" proc-macro2 = "1.0.92" \ No newline at end of file diff --git a/crates/cgp-async/Cargo.toml b/crates/cgp-async/Cargo.toml index dc40c4a..c08f4c0 100644 --- a/crates/cgp-async/Cargo.toml +++ b/crates/cgp-async/Cargo.toml @@ -26,4 +26,4 @@ static = [ "async" ] [dependencies] cgp-async-macro = { version = "0.2.0" } -cgp-sync = { version = "0.2.0" } \ No newline at end of file +cgp-sync = { version = "0.2.0" } \ No newline at end of file diff --git a/crates/cgp-component-macro-lib/Cargo.toml b/crates/cgp-component-macro-lib/Cargo.toml index ea50af6..ff2a459 100644 --- a/crates/cgp-component-macro-lib/Cargo.toml +++ b/crates/cgp-component-macro-lib/Cargo.toml @@ -12,8 +12,8 @@ description = """ """ [dependencies] -syn = { version = "2.0.90", features = [ "full", "extra-traits" ] } -quote = "1.0.33" -proc-macro2 = "1.0.92" -itertools = "0.13.0" -prettyplease = "0.2.25" +syn = { version = "2.0.90", features = [ "full", "extra-traits" ] } +quote = "1.0.33" +proc-macro2 = "1.0.92" +itertools = "0.13.0" +prettyplease = "0.2.25" diff --git a/crates/cgp-component-macro/Cargo.toml b/crates/cgp-component-macro/Cargo.toml index 1353cf4..02e3542 100644 --- a/crates/cgp-component-macro/Cargo.toml +++ b/crates/cgp-component-macro/Cargo.toml @@ -15,5 +15,4 @@ description = """ proc-macro = true [dependencies] -cgp-component-macro-lib = { version = "0.2.0" } -proc-macro2 = "1.0.92" \ No newline at end of file +cgp-component-macro-lib = { version = "0.2.0" } \ No newline at end of file diff --git a/crates/cgp-component/Cargo.toml b/crates/cgp-component/Cargo.toml index 6e1d9ce..a04c95f 100644 --- a/crates/cgp-component/Cargo.toml +++ b/crates/cgp-component/Cargo.toml @@ -12,4 +12,3 @@ description = """ """ [dependencies] -cgp-component-macro = { version = "0.2.0" } diff --git a/crates/cgp-component/src/lib.rs b/crates/cgp-component/src/lib.rs index 69ec76d..b44d966 100644 --- a/crates/cgp-component/src/lib.rs +++ b/crates/cgp-component/src/lib.rs @@ -8,8 +8,5 @@ pub mod traits; pub mod types; -pub use cgp_component_macro::{ - cgp_component, cgp_preset, delegate_components, for_each_replace, replace_with, -}; pub use traits::{DelegateComponent, HasComponents}; pub use types::{UseContext, UseDelegate, WithContext, WithProvider}; diff --git a/crates/cgp-core/Cargo.toml b/crates/cgp-core/Cargo.toml index e590e3f..ca47694 100644 --- a/crates/cgp-core/Cargo.toml +++ b/crates/cgp-core/Cargo.toml @@ -16,9 +16,11 @@ default = [ "full" ] full = [ "cgp-async/full" ] [dependencies] -cgp-async = { version = "0.2.0", default-features = false } -cgp-component = { version = "0.2.0" } -cgp-type = { version = "0.2.0" } -cgp-error = { version = "0.2.0" } -cgp-field = { version = "0.2.0" } -cgp-inner = { version = "0.2.0" } \ No newline at end of file +cgp-async = { version = "0.2.0", default-features = false } +cgp-component = { version = "0.2.0" } +cgp-component-macro = { version = "0.2.0" } +cgp-type = { version = "0.2.0" } +cgp-error = { version = "0.2.0" } +cgp-field = { version = "0.2.0" } +cgp-field-macro = { version = "0.2.0" } +cgp-inner = { version = "0.2.0" } \ No newline at end of file diff --git a/crates/cgp-core/src/prelude.rs b/crates/cgp-core/src/prelude.rs index bcba4db..8ebd30c 100644 --- a/crates/cgp-core/src/prelude.rs +++ b/crates/cgp-core/src/prelude.rs @@ -1,9 +1,8 @@ pub use cgp_async::{async_trait, Async, MaybeSend, MaybeStatic, MaybeSync}; -pub use cgp_component::{ +pub use cgp_component::{DelegateComponent, HasComponents}; +pub use cgp_component_macro::{ cgp_component, cgp_preset, delegate_components, for_each_replace, replace_with, - DelegateComponent, HasComponents, }; pub use cgp_error::{CanRaiseError, HasErrorType}; -pub use cgp_field::{ - product, symbol, Char, Cons, Either, HasField, HasFieldMut, Nil, Product, Sum, Void, -}; +pub use cgp_field::{Char, Cons, Either, HasField, HasFieldMut, Nil, Void}; +pub use cgp_field_macro::{product, symbol, HasField, Product, Sum}; diff --git a/crates/cgp-error-std/Cargo.toml b/crates/cgp-error-std/Cargo.toml index 6d609c2..5bb559a 100644 --- a/crates/cgp-error-std/Cargo.toml +++ b/crates/cgp-error-std/Cargo.toml @@ -12,4 +12,4 @@ description = """ """ [dependencies] -cgp-core = { version = "0.2.0", default-features = false } \ No newline at end of file +cgp-core = { version = "0.2.0", default-features = false } \ No newline at end of file diff --git a/crates/cgp-error/Cargo.toml b/crates/cgp-error/Cargo.toml index 02a9198..4bbbea6 100644 --- a/crates/cgp-error/Cargo.toml +++ b/crates/cgp-error/Cargo.toml @@ -12,6 +12,7 @@ description = """ """ [dependencies] -cgp-async = { version = "0.2.0", default-features = false } -cgp-component = { version = "0.2.0" } -cgp-type = { version = "0.2.0" } +cgp-async = { version = "0.2.0", default-features = false } +cgp-component = { version = "0.2.0" } +cgp-component-macro = { version = "0.2.0" } +cgp-type = { version = "0.2.0" } diff --git a/crates/cgp-error/src/can_raise_error.rs b/crates/cgp-error/src/can_raise_error.rs index bdf0441..2d75329 100644 --- a/crates/cgp-error/src/can_raise_error.rs +++ b/crates/cgp-error/src/can_raise_error.rs @@ -1,4 +1,5 @@ -use cgp_component::{cgp_component, DelegateComponent, HasComponents, UseDelegate}; +use cgp_component::{DelegateComponent, HasComponents, UseDelegate}; +use cgp_component_macro::cgp_component; use crate::has_error_type::HasErrorType; diff --git a/crates/cgp-error/src/has_error_type.rs b/crates/cgp-error/src/has_error_type.rs index f93441f..c0aba7c 100644 --- a/crates/cgp-error/src/has_error_type.rs +++ b/crates/cgp-error/src/has_error_type.rs @@ -1,7 +1,8 @@ use core::fmt::Debug; use cgp_async::Async; -use cgp_component::{cgp_component, DelegateComponent, HasComponents, WithProvider}; +use cgp_component::{DelegateComponent, HasComponents, WithProvider}; +use cgp_component_macro::cgp_component; use cgp_type::traits::has_type::ProvideType; /** diff --git a/crates/cgp-extra/Cargo.toml b/crates/cgp-extra/Cargo.toml index 75ea918..8f1be5b 100644 --- a/crates/cgp-extra/Cargo.toml +++ b/crates/cgp-extra/Cargo.toml @@ -12,4 +12,4 @@ description = """ """ [dependencies] -cgp-run = { version = "0.2.0" } +cgp-run = { version = "0.2.0" } diff --git a/crates/cgp-field-macro-lib/Cargo.toml b/crates/cgp-field-macro-lib/Cargo.toml index 5847fb8..32da9a5 100644 --- a/crates/cgp-field-macro-lib/Cargo.toml +++ b/crates/cgp-field-macro-lib/Cargo.toml @@ -12,8 +12,8 @@ description = """ """ [dependencies] -syn = { version = "2.0.90", features = [ "full" ] } -quote = "1.0.33" -proc-macro2 = "1.0.92" -itertools = "0.13.0" -prettyplease = "0.2.20" +syn = { version = "2.0.90", features = [ "full" ] } +quote = "1.0.33" +proc-macro2 = "1.0.92" +itertools = "0.13.0" +prettyplease = "0.2.20" diff --git a/crates/cgp-field-macro/Cargo.toml b/crates/cgp-field-macro/Cargo.toml index 6f0e2f0..75644f1 100644 --- a/crates/cgp-field-macro/Cargo.toml +++ b/crates/cgp-field-macro/Cargo.toml @@ -16,4 +16,4 @@ proc-macro = true [dependencies] cgp-field-macro-lib = { version = "0.2.0" } -proc-macro2 = "1.0.92" \ No newline at end of file +proc-macro2 = "1.0.92" \ No newline at end of file diff --git a/crates/cgp-field/Cargo.toml b/crates/cgp-field/Cargo.toml index 2df4a10..aeca1c4 100644 --- a/crates/cgp-field/Cargo.toml +++ b/crates/cgp-field/Cargo.toml @@ -12,6 +12,5 @@ description = """ """ [dependencies] -cgp-field-macro = { version = "0.2.0" } cgp-component = { version = "0.2.0" } cgp-type = { version = "0.2.0" } \ No newline at end of file diff --git a/crates/cgp-field/src/lib.rs b/crates/cgp-field/src/lib.rs index 1ebbee0..c549bd1 100644 --- a/crates/cgp-field/src/lib.rs +++ b/crates/cgp-field/src/lib.rs @@ -4,6 +4,5 @@ pub mod impls; pub mod traits; pub mod types; -pub use cgp_field_macro::{product, symbol, HasField, Product, Sum}; pub use traits::{FieldGetter, HasField, HasFieldMut, MutFieldGetter}; pub use types::{Char, Cons, Either, Field, Index, Nil, Void}; diff --git a/crates/cgp-inner/Cargo.toml b/crates/cgp-inner/Cargo.toml index 131a751..ab068cf 100644 --- a/crates/cgp-inner/Cargo.toml +++ b/crates/cgp-inner/Cargo.toml @@ -12,4 +12,5 @@ description = """ """ [dependencies] -cgp-component = { version = "0.2.0" } \ No newline at end of file +cgp-component = { version = "0.2.0" } +cgp-component-macro = { version = "0.2.0" } \ No newline at end of file diff --git a/crates/cgp-inner/src/lib.rs b/crates/cgp-inner/src/lib.rs index d48c772..098ef26 100644 --- a/crates/cgp-inner/src/lib.rs +++ b/crates/cgp-inner/src/lib.rs @@ -2,7 +2,8 @@ extern crate alloc; -use cgp_component::{cgp_component, DelegateComponent, HasComponents}; +use cgp_component::{DelegateComponent, HasComponents}; +use cgp_component_macro::cgp_component; #[cgp_component { name: InnerComponent, diff --git a/crates/cgp-run/Cargo.toml b/crates/cgp-run/Cargo.toml index 31bbf5b..0da6082 100644 --- a/crates/cgp-run/Cargo.toml +++ b/crates/cgp-run/Cargo.toml @@ -12,6 +12,7 @@ description = """ """ [dependencies] -cgp-async = { version = "0.2.0", default-features = false } -cgp-error = { version = "0.2.0" } -cgp-component = { version = "0.2.0" } \ No newline at end of file +cgp-async = { version = "0.2.0", default-features = false } +cgp-error = { version = "0.2.0" } +cgp-component = { version = "0.2.0" } +cgp-component-macro = { version = "0.2.0" } \ No newline at end of file diff --git a/crates/cgp-run/src/lib.rs b/crates/cgp-run/src/lib.rs index 2802947..1e49ec0 100644 --- a/crates/cgp-run/src/lib.rs +++ b/crates/cgp-run/src/lib.rs @@ -7,6 +7,7 @@ use alloc::boxed::Box; use cgp_async::*; use cgp_component::*; +use cgp_component_macro::*; use cgp_error::HasErrorType; #[cgp_component { diff --git a/crates/cgp-type/Cargo.toml b/crates/cgp-type/Cargo.toml index 7eec780..d4cd836 100644 --- a/crates/cgp-type/Cargo.toml +++ b/crates/cgp-type/Cargo.toml @@ -12,4 +12,5 @@ description = """ """ [dependencies] -cgp-component = { version = "0.2.0" } +cgp-component = { version = "0.2.0" } +cgp-component-macro = { version = "0.2.0" } diff --git a/crates/cgp-type/src/traits/has_type.rs b/crates/cgp-type/src/traits/has_type.rs index 43242be..27c22d8 100644 --- a/crates/cgp-type/src/traits/has_type.rs +++ b/crates/cgp-type/src/traits/has_type.rs @@ -1,4 +1,5 @@ -use cgp_component::{cgp_component, DelegateComponent, HasComponents, UseContext, UseDelegate}; +use cgp_component::{DelegateComponent, HasComponents, UseContext, UseDelegate}; +use cgp_component_macro::cgp_component; #[cgp_component { name: TypeComponent,