Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,10 @@
- Accept `generics = <...>` as shorthand for `generics(...)` in attributes (feature: `compat_generics_angles`).
- This feature will eventually be removed unless a petition is opened.
- Add optional `default_plugin` feature to allow omitting `plugin = ...` when a default plugin is set via `#[auto_plugin(default_plugin)]`.

---
## v0.11.0
- Update to bevy 0.19
- Remove deprecated `auto_add_event` alias; use `auto_add_message`.
- Remove deprecated `#[auto_plugin]` args `generics(...)`, `impl_generic_auto_plugin_trait`, and `impl_generic_plugin_trait`.
- Remove deprecated `init(...)` and `resource(...)` args from `auto_insert_resource`; use `insert(...)`.
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_auto_plugin"
version = "0.10.0"
version = "0.11.0"
authors = ["Brett Striker <strikeforcezero@gmail.com>"]
repository = "https://github.com/StrikeForceZero/bevy_auto_plugin"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -42,18 +42,18 @@ _wasm = [
members = ["crates/*"]

[workspace.dependencies]
bevy_auto_plugin_shared = { version = "0.10.0", path = "crates/bevy_auto_plugin_shared" }
bevy_auto_plugin_proc_macros = { version = "0.10.0", path = "crates/bevy_auto_plugin_proc_macros" }
bevy_auto_plugin_shared = { version = "0.11.0", path = "crates/bevy_auto_plugin_shared" }
bevy_auto_plugin_proc_macros = { version = "0.11.0", path = "crates/bevy_auto_plugin_proc_macros" }
internal_test_util = { path = "crates/internal_test_util" }
internal_test_proc_macro = { path = "crates/internal_test_proc_macro" }
bevy = { version = "0.18", default-features = false, features = ["bevy_state"] }
bevy_app = { version = "0.18", default-features = false }
bevy_state = { version = "0.18", default-features = false }
bevy_reflect = { version = "0.18", default-features = false }
bevy_reflect_derive = { version = "0.18", default-features = false }
bevy_internal = { version = "0.18", default-features = false }
bevy_ecs = { version = "0.18", default-features = false }
bevy_ecs_macros = { version = "0.18", default-features = false }
bevy = { version = "0.19", default-features = false, features = ["bevy_state"] }
bevy_app = { version = "0.19", default-features = false }
bevy_state = { version = "0.19", default-features = false }
bevy_reflect = { version = "0.19", default-features = false }
bevy_reflect_derive = { version = "0.19", default-features = false }
bevy_internal = { version = "0.19", default-features = false }
bevy_ecs = { version = "0.19", default-features = false }
bevy_ecs_macros = { version = "0.19", default-features = false }
proc-macro2 = "1"
syn = { version = "2", features = ["full", "extra-traits", "visit-mut"] }
quote = "1"
Expand Down
10 changes: 9 additions & 1 deletion MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@
- Removed `generics` from `auto_init_state` and `auto_state` - There should be no valid use cases for this but if you have one and were using it please open an issue.

## v0.8 to v0.9
- Deprecated (compiler error) `resource` in favor of `insert` in `auto_insert_resource`
- Deprecated (compiler error) `resource` in favor of `insert` in `auto_insert_resource`

## v0.10 to v0.11
- Bevy support moved from 0.18 to 0.19.
- Removed `auto_add_event`; use `auto_add_message`.
- Removed `#[auto_plugin]` params `generics(...)`, `impl_generic_auto_plugin_trait`, and `impl_generic_plugin_trait`.
- Use `impl_plugin_trait` when you want the derive to implement Bevy's `Plugin`.
- `AutoPlugin` is always implemented when deriving `AutoPlugin`.
- Removed `init(...)` and `resource(...)` from `auto_insert_resource`; use `insert(...)`.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ The following examples demonstrate how common Bevy patterns can be expressed mor
## Bevy Compatibility

| bevy_auto_plugin | Bevy |
| --- | --- |
| 0.9.x - 0.10.x | 0.18 |
| 0.6.x - 0.8.x | 0.17 |
| 0.2.x - 0.5.x | 0.16 |
| 0.1.x | 0.15 |
|------------------|------|
| 0.11.x | 0.19 |
| 0.9.x - 0.10.x | 0.18 |
| 0.6.x - 0.8.x | 0.17 |
| 0.2.x - 0.5.x | 0.16 |
| 0.1.x | 0.15 |

## Examples

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_auto_plugin_proc_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_auto_plugin_proc_macros"
version = "0.10.0"
version = "0.11.0"
authors = ["Brett Striker <strikeforcezero@gmail.com>"]
repository = "https://github.com/StrikeForceZero/bevy_auto_plugin/crates/bevy_auto_plugin_proc_macros"
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_auto_plugin_shared/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_auto_plugin_shared"
version = "0.10.0"
version = "0.11.0"
authors = ["Brett Striker <strikeforcezero@gmail.com>"]
repository = "https://github.com/StrikeForceZero/bevy_auto_plugin/crates/bevy_auto_plugin_shared"
license = "MIT OR Apache-2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub static AUTO_PLUGIN_REGISTRY_BEFORE_BUILD: LazyLock<AutoPluginRegistry> = Laz
let mut registry = registry
.into_iter()
.map(|(type_id, mut entries)| {
entries.sort_by(|a, b| a.0.cmp(&b.0));
entries.sort_by_key(|a| a.0);
let mut build_fns = Vec::with_capacity(entries.len());
for (_, build_fn) in entries {
build_fns.push(build_fn);
Expand Down Expand Up @@ -111,7 +111,7 @@ pub static AUTO_PLUGIN_REGISTRY_AFTER_BUILD: LazyLock<AutoPluginRegistry> = Lazy
let mut registry = registry
.into_iter()
.map(|(type_id, mut entries)| {
entries.sort_by(|a, b| a.0.cmp(&b.0));
entries.sort_by_key(|a| a.0);
let mut build_fns = Vec::with_capacity(entries.len());
for (_, build_fn) in entries {
build_fns.push(build_fn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,6 @@ pub fn auto_bind_plugin_outer(attr: MacroStream, input: MacroStream) -> MacroStr
.unwrap_or_else(|err| compile_error_with!(err, og_input))
}

#[cfg(test)]
mod tests {
use super::*;
use internal_test_proc_macro::xtest;
use quote::quote;
#[xtest]
fn test_auto_bind_plugin_inner() {
let attr = quote!(plugin = Test);
let input = quote! {
#[derive(Component, Reflect)]
#[reflect(Component)]
#[auto_register_type]
#[some::path::auto_name]
struct FooComponent;
};
assert_eq!(
auto_bind_plugin_outer(attr, input).to_string(),
quote! {
# [derive (Component , Reflect)]
# [reflect (Component)]
# [auto_register_type (plugin = Test)]
# [some::path::auto_name (plugin = Test)]
struct FooComponent ;
}
.to_string()
);
}
}

pub fn attrs_inject_plugin_param(
attrs: &mut Vec<syn::Attribute>,
plugin: &syn::Path,
Expand Down Expand Up @@ -193,3 +164,33 @@ fn list_has_key(ml: &syn::MetaList, key: &str) -> bool {
Err(_) => false,
}
}

#[cfg(test)]
mod tests {
use super::*;
use internal_test_proc_macro::xtest;
use quote::quote;

#[xtest]
fn test_auto_bind_plugin_inner() {
let attr = quote!(plugin = Test);
let input = quote! {
#[derive(Component, Reflect)]
#[reflect(Component)]
#[auto_register_type]
#[some::path::auto_name]
struct FooComponent;
};
assert_eq!(
auto_bind_plugin_outer(attr, input).to_string(),
quote! {
# [derive (Component , Reflect)]
# [reflect (Component)]
# [auto_register_type (plugin = Test)]
# [some::path::auto_name (plugin = Test)]
struct FooComponent ;
}
.to_string()
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::util::macros::parse_macro_input2;
use proc_macro2::TokenStream as MacroStream;
use syn::spanned::Spanned;

pub fn expand_derive_auto_plugin(input: MacroStream) -> MacroStream {
use crate::{
Expand All @@ -21,38 +20,6 @@ pub fn expand_derive_auto_plugin(input: MacroStream) -> MacroStream {
params
};

let mut compile_warnings = quote! {};

#[allow(deprecated)]
if params.auto_plugin.impl_generic_auto_plugin_trait.is_present() {
compile_warnings.extend(
syn::Error::new(
params.auto_plugin.impl_generic_auto_plugin_trait.span(),
"always implemented - remove `impl_generic_auto_plugin_trait`",
)
.to_compile_error(),
)
}

#[allow(deprecated)]
if params.auto_plugin.impl_generic_plugin_trait.is_present() {
compile_warnings.extend(
syn::Error::new(
params.auto_plugin.impl_generic_plugin_trait.span(),
"use `impl_plugin_trait` instead",
)
.to_compile_error(),
)
}

#[allow(deprecated)]
for generics in &params.auto_plugin.generics {
compile_warnings.extend(
syn::Error::new(generics.span(), "no longer needed - remove `generics(...)`")
.to_compile_error(),
)
}

let ident = &params.ident; // `Test`
let generics = &params.generics; // `<T1, T2>`
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
Expand All @@ -79,7 +46,7 @@ pub fn expand_derive_auto_plugin(input: MacroStream) -> MacroStream {
#[cfg(feature = "default_plugin")]
if params.auto_plugin.default_plugin.is_present() {
if !params.generics.params.is_empty() {
compile_warnings.extend(
output.extend(
syn::Error::new(
params.auto_plugin.default_plugin.span(),
"`default_plugin` is not supported for generic plugins; use a concrete wrapper type",
Expand All @@ -96,7 +63,6 @@ pub fn expand_derive_auto_plugin(input: MacroStream) -> MacroStream {
}

quote! {
#compile_warnings
#output
}
}
Loading
Loading