use uuid again since proc_macro::Span
isn't unique enough
This commit is contained in:
parent
5dd2e99c7c
commit
655a2f81b1
@ -23,7 +23,7 @@ auto_register = []
|
|||||||
# Enables automatic reflection using inventory. Not supported on all platforms.
|
# Enables automatic reflection using inventory. Not supported on all platforms.
|
||||||
auto_register_inventory = ["auto_register"]
|
auto_register_inventory = ["auto_register"]
|
||||||
# Enables automatic reflection on platforms not supported by inventory. See `load_type_registrations` for more info.
|
# Enables automatic reflection on platforms not supported by inventory. See `load_type_registrations` for more info.
|
||||||
auto_register_static = ["auto_register"]
|
auto_register_static = ["auto_register", "dep:uuid"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.17.0-dev" }
|
bevy_macro_utils = { path = "../../bevy_macro_utils", version = "0.17.0-dev" }
|
||||||
@ -31,6 +31,9 @@ indexmap = "2.0"
|
|||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
syn = { version = "2.0", features = ["full", "extra-traits"] }
|
||||||
|
uuid = { version = "1.13.1", default-features = false, features = [
|
||||||
|
"v4",
|
||||||
|
], optional = true }
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
# TODO: Assuming all wasm builds are for the browser. Require `no_std` support to break assumption.
|
# TODO: Assuming all wasm builds are for the browser. Require `no_std` support to break assumption.
|
||||||
|
@ -169,11 +169,8 @@ pub fn reflect_auto_registration(meta: &ReflectMeta) -> Option<proc_macro2::Toke
|
|||||||
};
|
};
|
||||||
|
|
||||||
if cfg!(feature = "auto_register_static") {
|
if cfg!(feature = "auto_register_static") {
|
||||||
use core::hash::{Hash, Hasher};
|
|
||||||
use proc_macro::Span;
|
|
||||||
use std::{
|
use std::{
|
||||||
env, fs,
|
env, fs,
|
||||||
hash::DefaultHasher,
|
|
||||||
io::Write,
|
io::Write,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{LazyLock, Mutex},
|
sync::{LazyLock, Mutex},
|
||||||
@ -207,20 +204,7 @@ pub fn reflect_auto_registration(meta: &ReflectMeta) -> Option<proc_macro2::Toke
|
|||||||
Mutex::new(file)
|
Mutex::new(file)
|
||||||
});
|
});
|
||||||
|
|
||||||
let crate_name =
|
let export_name = format!("_bevy_reflect_register_{}", uuid::Uuid::new_v4().as_u128());
|
||||||
env::var("CARGO_CRATE_NAME").expect("Expected cargo to set CARGO_CRATE_NAME env var");
|
|
||||||
let span = Span::call_site();
|
|
||||||
let mut hasher = DefaultHasher::new();
|
|
||||||
span.file().hash(&mut hasher);
|
|
||||||
let file_path_hash = hasher.finish();
|
|
||||||
|
|
||||||
let export_name = format!(
|
|
||||||
"_bevy_reflect_register_{}_{}_{}_{}",
|
|
||||||
crate_name,
|
|
||||||
file_path_hash,
|
|
||||||
span.line(),
|
|
||||||
span.column(),
|
|
||||||
);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut file = REGISTRATION_FNS_EXPORT.lock().unwrap();
|
let mut file = REGISTRATION_FNS_EXPORT.lock().unwrap();
|
||||||
|
Loading…
Reference in New Issue
Block a user