diff --git a/Cargo.toml b/Cargo.toml index c3331f1..1657f5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_proto" -version = "0.8.0" +version = "0.8.1" edition = "2021" authors = ["Gino Valente "] description = "Create config files for entities in Bevy" @@ -57,7 +57,7 @@ bevy_sprite = ["bevy/bevy_sprite", "bevy_proto_backend/bevy_sprite"] bevy_text = ["bevy/bevy_text", "bevy_proto_backend/bevy_text"] [dependencies] -bevy_proto_backend = { version = "0.1", path = "./bevy_proto_backend" } +bevy_proto_backend = { version = "0.1.1", path = "./bevy_proto_backend" } bevy = { version = ">=0.10.1", default-features = false, features = ["bevy_asset"] } anyhow = "1.0" serde = "1.0" diff --git a/bevy_proto_backend/Cargo.toml b/bevy_proto_backend/Cargo.toml index 3e64afb..bb07704 100644 --- a/bevy_proto_backend/Cargo.toml +++ b/bevy_proto_backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_proto_backend" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Gino Valente "] description = "Backend crate for bevy_proto" @@ -44,7 +44,7 @@ bevy_sprite = ["bevy/bevy_sprite"] bevy_text = ["bevy/bevy_text"] [dependencies] -bevy_proto_derive = { version = "0.3", path = "../bevy_proto_derive" } +bevy_proto_derive = { version = "0.3.1", path = "../bevy_proto_derive" } bevy = { version = ">=0.10.1", default-features = false, features = ["bevy_asset"] } anyhow = "1.0" serde = "1.0" diff --git a/bevy_proto_derive/Cargo.toml b/bevy_proto_derive/Cargo.toml index eb28cee..625bd3a 100644 --- a/bevy_proto_derive/Cargo.toml +++ b/bevy_proto_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_proto_derive" -version = "0.3.0" +version = "0.3.1" edition = "2021" authors = ["Gino Valente "] description = "Derive macro for use with bevy_proto" diff --git a/bevy_proto_derive/src/utils.rs b/bevy_proto_derive/src/utils.rs index 511df75..0a9d654 100644 --- a/bevy_proto_derive/src/utils.rs +++ b/bevy_proto_derive/src/utils.rs @@ -1,12 +1,20 @@ use proc_macro2::{Ident, Span, TokenStream}; -use proc_macro_crate::{crate_name, FoundCrate}; +use proc_macro_crate::{crate_name, Error, FoundCrate}; use quote::quote; -/// Returns a path to the `bevy_proto_backend` crate. +/// Returns a path to either the `bevy_proto_backend` crate or `bevy_proto::backend` module. pub(crate) fn get_proto_crate() -> TokenStream { - get_crate_path( - crate_name("bevy_proto_backend").expect("bevy_proto_backend is present in `Cargo.toml`"), - ) + match crate_name("bevy_proto_backend") { + Ok(found_crate) => get_crate_path(found_crate), + Err(Error::CrateNotFound { .. }) => { + let path = get_crate_path( + crate_name("bevy_proto") + .expect("bevy_proto or bevy_proto_backend should be present in `Cargo.toml`"), + ); + quote!(#path::backend) + } + Err(error) => panic!("{}", error), + } } /// Returns a path to the `bevy` crate. @@ -19,7 +27,7 @@ fn get_crate_path(found_crate: FoundCrate) -> TokenStream { FoundCrate::Itself => quote!(crate), FoundCrate::Name(name) => { let ident = Ident::new(&name, Span::call_site()); - quote!( #ident ) + quote!( ::#ident ) } } }