Skip to content

Commit 512b746

Browse files
authored
Disentangle bevy_utils/bevy_core's reexported dependencies (#12313)
# Objective Make bevy_utils less of a compilation bottleneck. Tackle #11478. ## Solution * Move all of the directly reexported dependencies and move them to where they're actually used. * Remove the UUID utilities that have gone unused since `TypePath` took over for `TypeUuid`. * There was also a extraneous bytemuck dependency on `bevy_core` that has not been used for a long time (since `encase` became the primary way to prepare GPU buffers). * Remove the `all_tuples` macro reexport from bevy_ecs since it's accessible from `bevy_utils`. --- ## Changelog Removed: Many of the reexports from bevy_utils (petgraph, uuid, nonmax, smallvec, and thiserror). Removed: bevy_core's reexports of bytemuck. ## Migration Guide bevy_utils' reexports of petgraph, uuid, nonmax, smallvec, and thiserror have been removed. bevy_core' reexports of bytemuck's types has been removed. Add them as dependencies in your own crate instead.
1 parent a1974a4 commit 512b746

File tree

57 files changed

+81
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+81
-125
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ bytemuck = "1.7"
338338
futures-lite = "2.0.1"
339339
crossbeam-channel = "0.5.0"
340340
argh = "0.1.12"
341+
thiserror = "1.0"
341342

342343
[[example]]
343344
name = "hello_world"

crates/bevy_animation/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.14.0-dev" }
2626

2727
# other
2828
sha1_smol = { version = "1.0" }
29-
uuid = { version = "1.7", features = ["v5"] }
29+
uuid = { version = "1.7", features = ["v4"] }
3030

3131
[lints]
3232
workspace = true

crates/bevy_animation/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ use bevy_render::mesh::morph::MorphWeights;
2020
use bevy_time::Time;
2121
use bevy_transform::{prelude::Transform, TransformSystem};
2222
use bevy_utils::hashbrown::HashMap;
23-
use bevy_utils::{tracing::error, NoOpHash, Uuid};
23+
use bevy_utils::{tracing::error, NoOpHash};
2424
use sha1_smol::Sha1;
25+
use uuid::Uuid;
2526

2627
#[allow(missing_docs)]
2728
pub mod prelude {

crates/bevy_app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }
2626
serde = { version = "1.0", features = ["derive"], optional = true }
2727
ron = { version = "0.8.0", optional = true }
2828
downcast-rs = "1.2.0"
29-
29+
thiserror = "1.0"
3030

3131
[target.'cfg(target_arch = "wasm32")'.dependencies]
3232
wasm-bindgen = { version = "0.2" }

crates/bevy_app/src/app.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ use bevy_ecs::{
77
InternedScheduleLabel, ScheduleBuildSettings, ScheduleLabel,
88
},
99
};
10-
use bevy_utils::{intern::Interned, thiserror::Error, tracing::debug, HashMap, HashSet};
10+
use bevy_utils::{intern::Interned, tracing::debug, HashMap, HashSet};
1111
use std::{
1212
fmt::Debug,
1313
panic::{catch_unwind, resume_unwind, AssertUnwindSafe},
1414
};
15+
use thiserror::Error;
1516

1617
#[cfg(feature = "trace")]
1718
use bevy_utils::tracing::info_span;

crates/bevy_app/src/plugin.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ pub trait Plugins<Marker>: sealed::Plugins<Marker> {}
115115
impl<Marker, T> Plugins<Marker> for T where T: sealed::Plugins<Marker> {}
116116

117117
mod sealed {
118-
119-
use bevy_ecs::all_tuples;
118+
use bevy_utils::all_tuples;
120119

121120
use crate::{App, AppError, Plugin, PluginGroup};
122121

crates/bevy_asset/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ watch = []
2121
bevy_app = { path = "../bevy_app", version = "0.14.0-dev" }
2222
bevy_asset_macros = { path = "macros", version = "0.14.0-dev" }
2323
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev" }
24-
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev" }
24+
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
25+
"uuid",
26+
] }
2527
bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }
2628
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
2729

@@ -37,6 +39,7 @@ parking_lot = { version = "0.12", features = ["arc_lock", "send_guard"] }
3739
ron = "0.8"
3840
serde = { version = "1", features = ["derive"] }
3941
thiserror = "1.0"
42+
uuid = { version = "1.0", features = ["v4"] }
4043

4144
[target.'cfg(target_os = "android")'.dependencies]
4245
bevy_winit = { path = "../bevy_winit", version = "0.14.0-dev" }

crates/bevy_asset/src/assets.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use bevy_ecs::{
77
system::{Res, ResMut, Resource},
88
};
99
use bevy_reflect::{Reflect, TypePath};
10-
use bevy_utils::{HashMap, Uuid};
10+
use bevy_utils::HashMap;
1111
use crossbeam_channel::{Receiver, Sender};
1212
use serde::{Deserialize, Serialize};
1313
use std::{
@@ -17,6 +17,7 @@ use std::{
1717
sync::{atomic::AtomicU32, Arc},
1818
};
1919
use thiserror::Error;
20+
use uuid::Uuid;
2021

2122
/// A generational runtime-only identifier for a specific [`Asset`] stored in [`Assets`]. This is optimized for efficient runtime
2223
/// usage and is not suitable for identifying assets across app runs.

crates/bevy_asset/src/handle.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ use crate::{
44
};
55
use bevy_ecs::prelude::*;
66
use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath};
7-
use bevy_utils::{get_short_name, Uuid};
7+
use bevy_utils::get_short_name;
88
use crossbeam_channel::{Receiver, Sender};
99
use std::{
1010
any::TypeId,
1111
hash::{Hash, Hasher},
1212
sync::Arc,
1313
};
1414
use thiserror::Error;
15+
use uuid::Uuid;
1516

1617
/// Provides [`Handle`] and [`UntypedHandle`] _for a specific asset type_.
1718
/// This should _only_ be used for one specific asset type.

crates/bevy_asset/src/id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::{Asset, AssetIndex};
22
use bevy_reflect::Reflect;
3-
use bevy_utils::Uuid;
3+
use uuid::Uuid;
44

55
use std::{
66
any::TypeId,

crates/bevy_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }
2424
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
2525

2626
# other
27-
bytemuck = "1.5"
2827
serde = { version = "1.0", optional = true }
28+
uuid = "1.0"
2929

3030
[features]
3131
serialize = ["dep:serde"]

crates/bevy_core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ mod serde;
66
mod task_pool_options;
77

88
use bevy_ecs::system::Resource;
9-
pub use bytemuck::{bytes_of, cast_slice, Pod, Zeroable};
109
pub use name::*;
1110
pub use task_pool_options::*;
1211

crates/bevy_core_pipeline/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
3636
serde = { version = "1", features = ["derive"] }
3737
bitflags = "2.3"
3838
radsort = "0.1"
39+
nonmax = "0.5"
3940

4041
[lints]
4142
workspace = true

crates/bevy_core_pipeline/src/core_2d/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ use bevy_render::{
4242
render_resource::CachedRenderPipelineId,
4343
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
4444
};
45-
use bevy_utils::{nonmax::NonMaxU32, FloatOrd};
45+
use bevy_utils::FloatOrd;
46+
use nonmax::NonMaxU32;
4647

4748
use crate::{tonemapping::TonemappingNode, upscaling::UpscalingNode};
4849

crates/bevy_core_pipeline/src/core_3d/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ use bevy_render::{
6767
view::{ExtractedView, ViewDepthTexture, ViewTarget},
6868
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
6969
};
70-
use bevy_utils::{nonmax::NonMaxU32, tracing::warn, FloatOrd, HashMap};
70+
use bevy_utils::{tracing::warn, FloatOrd, HashMap};
71+
use nonmax::NonMaxU32;
7172

7273
use crate::{
7374
core_3d::main_transmissive_pass_3d_node::MainTransmissivePass3dNode,

crates/bevy_core_pipeline/src/deferred/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use bevy_render::{
1010
render_phase::{CachedRenderPipelinePhaseItem, DrawFunctionId, PhaseItem},
1111
render_resource::{CachedRenderPipelineId, TextureFormat},
1212
};
13-
use bevy_utils::nonmax::NonMaxU32;
13+
use nonmax::NonMaxU32;
1414

1515
pub const DEFERRED_PREPASS_FORMAT: TextureFormat = TextureFormat::Rgba32Uint;
1616
pub const DEFERRED_LIGHTING_PASS_ID_FORMAT: TextureFormat = TextureFormat::R8Uint;

crates/bevy_core_pipeline/src/prepass/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ use bevy_render::{
3838
render_resource::{CachedRenderPipelineId, Extent3d, TextureFormat, TextureView},
3939
texture::ColorAttachment,
4040
};
41-
use bevy_utils::nonmax::NonMaxU32;
41+
use nonmax::NonMaxU32;
4242

4343
pub const NORMAL_PREPASS_FORMAT: TextureFormat = TextureFormat::Rgb10a2Unorm;
4444
pub const MOTION_VECTOR_PREPASS_FORMAT: TextureFormat = TextureFormat::Rg16Float;

crates/bevy_ecs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", optional = tr
2121
bevy_tasks = { path = "../bevy_tasks", version = "0.14.0-dev" }
2222
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
2323
bevy_ecs_macros = { path = "macros", version = "0.14.0-dev" }
24+
petgraph = "0.6"
2425

2526
bitflags = "2.3"
2627
concurrent-queue = "2.4.0"

crates/bevy_ecs/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ pub mod prelude {
5252
};
5353
}
5454

55-
pub use bevy_utils::all_tuples;
56-
5755
#[cfg(test)]
5856
mod tests {
5957
use crate as bevy_ecs;

crates/bevy_ecs/src/schedule/graph_utils.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
use std::fmt::Debug;
22

3-
use bevy_utils::{
4-
petgraph::{algo::TarjanScc, graphmap::NodeTrait, prelude::*},
5-
HashMap, HashSet,
6-
};
3+
use bevy_utils::{HashMap, HashSet};
74
use fixedbitset::FixedBitSet;
5+
use petgraph::{algo::TarjanScc, graphmap::NodeTrait, prelude::*};
86

97
use crate::schedule::set::*;
108

crates/bevy_ecs/src/schedule/schedule.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ use std::{
77
use bevy_utils::tracing::info_span;
88
use bevy_utils::{default, tracing::info};
99
use bevy_utils::{
10-
petgraph::{algo::TarjanScc, prelude::*},
11-
thiserror::Error,
1210
tracing::{error, warn},
1311
HashMap, HashSet,
1412
};
15-
1613
use fixedbitset::FixedBitSet;
14+
use petgraph::{algo::TarjanScc, prelude::*};
15+
use thiserror::Error;
1716

1817
use crate::{
1918
self as bevy_ecs,

crates/bevy_ecs/src/schedule/stepping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use crate::{
77
system::{IntoSystem, ResMut, Resource},
88
};
99
use bevy_utils::{
10-
thiserror::Error,
1110
tracing::{error, info, warn},
1211
TypeIdMap,
1312
};
13+
use thiserror::Error;
1414

1515
#[cfg(test)]
1616
use bevy_utils::tracing::debug;

crates/bevy_gizmos/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ bevy_math = { path = "../bevy_math", version = "0.14.0-dev" }
2323
bevy_asset = { path = "../bevy_asset", version = "0.14.0-dev" }
2424
bevy_render = { path = "../bevy_render", version = "0.14.0-dev" }
2525
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
26-
bevy_core = { path = "../bevy_core", version = "0.14.0-dev" }
2726
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev" }
2827
bevy_core_pipeline = { path = "../bevy_core_pipeline", version = "0.14.0-dev" }
2928
bevy_transform = { path = "../bevy_transform", version = "0.14.0-dev" }
3029
bevy_gizmos_macros = { path = "macros", version = "0.14.0-dev" }
3130

31+
bytemuck = "1.0"
32+
3233
[lints]
3334
workspace = true

crates/bevy_gizmos/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ use aabb::AabbGizmoPlugin;
5757
use bevy_app::{App, Last, Plugin};
5858
use bevy_asset::{load_internal_asset, Asset, AssetApp, Assets, Handle};
5959
use bevy_color::LinearRgba;
60-
use bevy_core::cast_slice;
6160
use bevy_ecs::{
6261
component::Component,
6362
query::ROQueryItem,
@@ -83,6 +82,7 @@ use bevy_render::{
8382
Extract, ExtractSchedule, Render, RenderApp, RenderSet,
8483
};
8584
use bevy_utils::TypeIdMap;
85+
use bytemuck::cast_slice;
8686
use config::{
8787
DefaultGizmoConfigGroup, GizmoConfig, GizmoConfigGroup, GizmoConfigStore, GizmoMeshConfig,
8888
};

crates/bevy_gltf/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ base64 = "0.21.5"
5454
percent-encoding = "2.1"
5555
serde = { version = "1.0", features = ["derive"] }
5656
serde_json = "1"
57+
smallvec = "1.11"
5758

5859
[lints]
5960
workspace = true

crates/bevy_gltf/src/loader.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ use bevy_scene::Scene;
3636
use bevy_tasks::IoTaskPool;
3737
use bevy_transform::components::Transform;
3838
use bevy_utils::tracing::{error, info_span, warn};
39-
use bevy_utils::{
40-
smallvec::{smallvec, SmallVec},
41-
HashMap, HashSet,
42-
};
39+
use bevy_utils::{HashMap, HashSet};
4340
use gltf::{
4441
accessor::Iter,
4542
mesh::{util::ReadIndices, Mode},
4643
texture::{Info, MagFilter, MinFilter, TextureTransform, WrappingMode},
4744
Material, Node, Primitive, Semantic,
4845
};
4946
use serde::{Deserialize, Serialize};
47+
use smallvec::{smallvec, SmallVec};
5048
use std::io::Error;
5149
use std::{
5250
collections::VecDeque,

crates/bevy_hierarchy/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ bevy_core = { path = "../bevy_core", version = "0.14.0-dev", optional = true }
2121
bevy_ecs = { path = "../bevy_ecs", version = "0.14.0-dev", default-features = false }
2222
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
2323
"bevy",
24+
"smallvec",
2425
], optional = true }
2526
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
2627

28+
smallvec = { version = "1.11", features = ["union", "const_generics"] }
29+
2730
[lints]
2831
workspace = true

crates/bevy_hierarchy/src/child_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bevy_ecs::{
66
system::{Commands, EntityCommands},
77
world::{Command, EntityWorldMut, World},
88
};
9-
use bevy_utils::smallvec::{smallvec, SmallVec};
9+
use smallvec::{smallvec, SmallVec};
1010

1111
// Do not use `world.send_event_batch` as it prints error message when the Events are not available in the world,
1212
// even though it's a valid use case to execute commands on a world without events. Loading a GLTF file for example
@@ -696,7 +696,7 @@ mod tests {
696696
components::{Children, Parent},
697697
HierarchyEvent::{self, ChildAdded, ChildMoved, ChildRemoved},
698698
};
699-
use bevy_utils::smallvec::{smallvec, SmallVec};
699+
use smallvec::{smallvec, SmallVec};
700700

701701
use bevy_ecs::{
702702
component::Component,

crates/bevy_hierarchy/src/components/children.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use bevy_ecs::{
66
prelude::FromWorld,
77
world::World,
88
};
9-
use bevy_utils::smallvec::SmallVec;
109
use core::slice;
10+
use smallvec::SmallVec;
1111
use std::ops::Deref;
1212

1313
/// Contains references to the child entities of this entity.

crates/bevy_pbr/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fixedbitset = "0.4"
4040
bytemuck = { version = "1", features = ["derive"] }
4141
radsort = "0.1"
4242
smallvec = "1.6"
43+
nonmax = "0.5"
4344

4445
[lints]
4546
workspace = true

crates/bevy_pbr/src/render/light.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ use bevy_render::{
1818
use bevy_transform::{components::GlobalTransform, prelude::Transform};
1919
#[cfg(feature = "trace")]
2020
use bevy_utils::tracing::info_span;
21-
use bevy_utils::{
22-
nonmax::NonMaxU32,
23-
tracing::{error, warn},
24-
};
21+
use bevy_utils::tracing::{error, warn};
22+
use nonmax::NonMaxU32;
2523
use std::{hash::Hash, num::NonZeroU64, ops::Range};
2624

2725
use crate::*;

crates/bevy_reflect/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ keywords = ["bevy"]
1010
readme = "README.md"
1111

1212
[features]
13-
default = []
13+
default = ["smallvec"]
1414
# When enabled, provides Bevy-related reflection implementations
1515
bevy = ["smallvec", "bevy_math", "smol_str"]
1616
glam = ["dep:glam"]
1717
bevy_math = ["glam", "dep:bevy_math"]
18-
smallvec = []
18+
smallvec = ["dep:smallvec"]
19+
uuid = ["dep:uuid"]
1920
# When enabled, allows documentation comments to be accessed via reflection
2021
documentation = ["bevy_reflect_derive/documentation"]
2122

@@ -33,9 +34,11 @@ erased-serde = "0.4"
3334
downcast-rs = "1.2"
3435
thiserror = "1.0"
3536
serde = "1"
37+
smallvec = { version = "1.11", optional = true }
3638

3739
glam = { version = "0.25", features = ["serde"], optional = true }
3840
smol_str = { version = "0.2.0", optional = true }
41+
uuid = { version = "1.0", optional = true, features = ["v4", "serde"] }
3942

4043
[dev-dependencies]
4144
ron = "0.8.0"

0 commit comments

Comments
 (0)