diff --git a/crates/bevy_utils/Cargo.toml b/crates/bevy_utils/Cargo.toml index 7f83ec17c9..c1555d8ba9 100644 --- a/crates/bevy_utils/Cargo.toml +++ b/crates/bevy_utils/Cargo.toml @@ -9,26 +9,33 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [features] -default = ["std"] -std = ["alloc", "tracing/std", "ahash/std"] -alloc = [] +default = ["std", "serde"] +std = [ + "alloc", + "tracing/std", + "ahash/std", + "dep:thread_local", + "ahash/runtime-rng", +] +alloc = ["hashbrown/default"] detailed_trace = [] +serde = ["hashbrown/serde"] [dependencies] ahash = { version = "0.8.7", default-features = false, features = [ - "runtime-rng", + "compile-time-rng", ] } tracing = { version = "0.1", default-features = false } -web-time = { version = "1.1" } -hashbrown = { version = "0.14.2", features = ["serde"] } +hashbrown = { version = "0.14.2", default-features = false } bevy_utils_proc_macros = { version = "0.15.0-dev", path = "macros" } -thread_local = "1.0" +thread_local = { version = "1.0", optional = true } [dev-dependencies] static_assertions = "1.1.0" [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2.0", features = ["js"] } +web-time = { version = "1.1" } [lints] workspace = true diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index 9cd1782345..1f7e1f7e5c 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -31,15 +31,18 @@ mod default; mod object_safe; pub use object_safe::assert_object_safe; mod once; +#[cfg(feature = "std")] mod parallel_queue; +mod time; pub use ahash::{AHasher, RandomState}; pub use bevy_utils_proc_macros::*; pub use default::default; pub use hashbrown; +#[cfg(feature = "std")] pub use parallel_queue::*; +pub use time::*; pub use tracing; -pub use web_time::{Duration, Instant, SystemTime, SystemTimeError, TryFromFloatSecsError}; #[cfg(feature = "alloc")] use alloc::boxed::Box; diff --git a/crates/bevy_utils/src/time.rs b/crates/bevy_utils/src/time.rs new file mode 100644 index 0000000000..fb5136eb03 --- /dev/null +++ b/crates/bevy_utils/src/time.rs @@ -0,0 +1,11 @@ +#[cfg(target_arch = "wasm32")] +pub use web_time::{Duration, Instant, SystemTime, SystemTimeError, TryFromFloatSecsError}; + +#[cfg(all(not(target_arch = "wasm32"), feature = "std"))] +pub use { + core::time::{Duration, TryFromFloatSecsError}, + std::time::{Instant, SystemTime, SystemTimeError}, +}; + +#[cfg(all(not(target_arch = "wasm32"), not(feature = "std")))] +pub use core::time::{Duration, TryFromFloatSecsError};