mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Minor fixes for bevy_utils
in no_std
(#15463)
# Objective - Contributes to #15460 ## Solution - Made `web-time` a `wasm32`-only dependency. - Moved time-related exports to its own module for clarity. - Feature-gated allocator requirements for `hashbrown` behind `alloc`. - Enabled compile-time RNG for `ahash` (runtime RNG will preferentially used in `std` environments) - Made `thread_local` optional by feature-gating the `Parallel` type. ## Testing - Ran CI locally. - `cargo build -p bevy_utils --target "x86_64-unknown-none" --no-default-features`
This commit is contained in:
parent
d0edbdac78
commit
53adcd7667
3 changed files with 29 additions and 8 deletions
|
@ -9,26 +9,33 @@ license = "MIT OR Apache-2.0"
|
||||||
keywords = ["bevy"]
|
keywords = ["bevy"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std"]
|
default = ["std", "serde"]
|
||||||
std = ["alloc", "tracing/std", "ahash/std"]
|
std = [
|
||||||
alloc = []
|
"alloc",
|
||||||
|
"tracing/std",
|
||||||
|
"ahash/std",
|
||||||
|
"dep:thread_local",
|
||||||
|
"ahash/runtime-rng",
|
||||||
|
]
|
||||||
|
alloc = ["hashbrown/default"]
|
||||||
detailed_trace = []
|
detailed_trace = []
|
||||||
|
serde = ["hashbrown/serde"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
ahash = { version = "0.8.7", default-features = false, features = [
|
ahash = { version = "0.8.7", default-features = false, features = [
|
||||||
"runtime-rng",
|
"compile-time-rng",
|
||||||
] }
|
] }
|
||||||
tracing = { version = "0.1", default-features = false }
|
tracing = { version = "0.1", default-features = false }
|
||||||
web-time = { version = "1.1" }
|
hashbrown = { version = "0.14.2", default-features = false }
|
||||||
hashbrown = { version = "0.14.2", features = ["serde"] }
|
|
||||||
bevy_utils_proc_macros = { version = "0.15.0-dev", path = "macros" }
|
bevy_utils_proc_macros = { version = "0.15.0-dev", path = "macros" }
|
||||||
thread_local = "1.0"
|
thread_local = { version = "1.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
static_assertions = "1.1.0"
|
static_assertions = "1.1.0"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||||
getrandom = { version = "0.2.0", features = ["js"] }
|
getrandom = { version = "0.2.0", features = ["js"] }
|
||||||
|
web-time = { version = "1.1" }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
|
|
@ -31,15 +31,18 @@ mod default;
|
||||||
mod object_safe;
|
mod object_safe;
|
||||||
pub use object_safe::assert_object_safe;
|
pub use object_safe::assert_object_safe;
|
||||||
mod once;
|
mod once;
|
||||||
|
#[cfg(feature = "std")]
|
||||||
mod parallel_queue;
|
mod parallel_queue;
|
||||||
|
mod time;
|
||||||
|
|
||||||
pub use ahash::{AHasher, RandomState};
|
pub use ahash::{AHasher, RandomState};
|
||||||
pub use bevy_utils_proc_macros::*;
|
pub use bevy_utils_proc_macros::*;
|
||||||
pub use default::default;
|
pub use default::default;
|
||||||
pub use hashbrown;
|
pub use hashbrown;
|
||||||
|
#[cfg(feature = "std")]
|
||||||
pub use parallel_queue::*;
|
pub use parallel_queue::*;
|
||||||
|
pub use time::*;
|
||||||
pub use tracing;
|
pub use tracing;
|
||||||
pub use web_time::{Duration, Instant, SystemTime, SystemTimeError, TryFromFloatSecsError};
|
|
||||||
|
|
||||||
#[cfg(feature = "alloc")]
|
#[cfg(feature = "alloc")]
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
|
11
crates/bevy_utils/src/time.rs
Normal file
11
crates/bevy_utils/src/time.rs
Normal file
|
@ -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};
|
Loading…
Reference in a new issue