Skip to content

Commit 3d3746e

Browse files
Simplify bevy_utils Features (#19090)
# Objective Now that `bevy_platform::cfg` is merged, we can start tidying up features. This PR starts with `bevy_utils`. ## Solution - Removed `serde` and `critical-section` features (they were just re-exports of `bevy_platform` anyway) - Removed `std`, `alloc` features, relying on `bevy_platform::cfg` to check for availability. - Added `parallel` feature to provide access to the `Parallel` type. - Moved the `HashMap` type aliases into `map.rs` for better organisation. ## Testing - CI
1 parent d7cab93 commit 3d3746e

File tree

13 files changed

+124
-157
lines changed

13 files changed

+124
-157
lines changed

crates/bevy_app/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ std = [
4747
"bevy_ecs/std",
4848
"dep:ctrlc",
4949
"downcast-rs/std",
50-
"bevy_utils/std",
5150
"bevy_tasks/std",
5251
"bevy_platform/std",
5352
]
@@ -77,9 +76,7 @@ web = [
7776
bevy_derive = { path = "../bevy_derive", version = "0.16.0-dev" }
7877
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev", default-features = false }
7978
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", default-features = false, optional = true }
80-
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false, features = [
81-
"alloc",
82-
] }
79+
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false }
8380
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev", default-features = false }
8481
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-features = false }
8582

crates/bevy_diagnostic/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ serialize = [
1818
"dep:serde",
1919
"bevy_ecs/serialize",
2020
"bevy_time/serialize",
21-
"bevy_utils/serde",
2221
"bevy_platform/serialize",
2322
]
2423

@@ -39,7 +38,6 @@ std = [
3938
"bevy_app/std",
4039
"bevy_platform/std",
4140
"bevy_time/std",
42-
"bevy_utils/std",
4341
"bevy_tasks/std",
4442
]
4543

@@ -50,7 +48,6 @@ critical-section = [
5048
"bevy_app/critical-section",
5149
"bevy_platform/critical-section",
5250
"bevy_time/critical-section",
53-
"bevy_utils/critical-section",
5451
"bevy_tasks/critical-section",
5552
]
5653

@@ -59,9 +56,7 @@ critical-section = [
5956
bevy_app = { path = "../bevy_app", version = "0.16.0-dev", default-features = false }
6057
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev", default-features = false }
6158
bevy_time = { path = "../bevy_time", version = "0.16.0-dev", default-features = false }
62-
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false, features = [
63-
"alloc",
64-
] }
59+
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false }
6560
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev", default-features = false }
6661
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-features = false, features = [
6762
"alloc",

crates/bevy_ecs/Cargo.toml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ default = ["std", "bevy_reflect", "async_executor", "backtrace"]
2020
multi_threaded = ["bevy_tasks/multi_threaded", "dep:arrayvec"]
2121

2222
## Adds serialization support through `serde`.
23-
serialize = [
24-
"dep:serde",
25-
"bevy_utils/serde",
26-
"bevy_platform/serialize",
27-
"indexmap/serde",
28-
]
23+
serialize = ["dep:serde", "bevy_platform/serialize", "indexmap/serde"]
2924

3025
## Adds runtime reflection support using `bevy_reflect`.
3126
bevy_reflect = ["dep:bevy_reflect"]
@@ -67,7 +62,7 @@ async_executor = ["std", "bevy_tasks/async_executor"]
6762
std = [
6863
"bevy_reflect?/std",
6964
"bevy_tasks/std",
70-
"bevy_utils/std",
65+
"bevy_utils/parallel",
7166
"bitflags/std",
7267
"concurrent-queue/std",
7368
"disqualified/alloc",
@@ -94,9 +89,7 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", features = [
9489
"smallvec",
9590
], default-features = false, optional = true }
9691
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev", default-features = false }
97-
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false, features = [
98-
"alloc",
99-
] }
92+
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false }
10093
bevy_ecs_macros = { path = "macros", version = "0.16.0-dev" }
10194
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-features = false, features = [
10295
"alloc",

crates/bevy_image/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ qoi = ["image/qoi"]
3232
tga = ["image/tga"]
3333
tiff = ["image/tiff"]
3434
webp = ["image/webp"]
35-
serialize = ["bevy_reflect", "bevy_platform/serialize", "bevy_utils/serde"]
35+
serialize = ["bevy_reflect", "bevy_platform/serialize"]
3636

3737
# For ktx2 supercompression
3838
zlib = ["flate2"]

crates/bevy_input/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ std = [
4242
"bevy_app/std",
4343
"bevy_ecs/std",
4444
"bevy_math/std",
45-
"bevy_utils/std",
4645
"bevy_reflect/std",
4746
"bevy_platform/std",
4847
]

crates/bevy_internal/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ std = [
296296
"bevy_state?/std",
297297
"bevy_time/std",
298298
"bevy_transform/std",
299-
"bevy_utils/std",
300299
"bevy_tasks/std",
301300
"bevy_window?/std",
302301
]
@@ -314,7 +313,6 @@ critical-section = [
314313
"bevy_reflect/critical-section",
315314
"bevy_state?/critical-section",
316315
"bevy_time/critical-section",
317-
"bevy_utils/critical-section",
318316
"bevy_tasks/critical-section",
319317
]
320318

@@ -377,9 +375,7 @@ bevy_transform = { path = "../bevy_transform", version = "0.16.0-dev", default-f
377375
"bevy-support",
378376
"bevy_reflect",
379377
] }
380-
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false, features = [
381-
"alloc",
382-
] }
378+
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false }
383379
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev", default-features = false }
384380

385381
# bevy (std required)

crates/bevy_reflect/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ wgpu-types = ["dep:wgpu-types"]
5454
## on `no_std` targets, but provides access to certain additional features on
5555
## supported platforms.
5656
std = [
57-
"bevy_utils/std",
5857
"erased-serde/std",
5958
"downcast-rs/std",
6059
"serde/std",
@@ -67,10 +66,7 @@ std = [
6766

6867
## `critical-section` provides the building blocks for synchronization primitives
6968
## on all platforms, including `no_std`.
70-
critical-section = [
71-
"bevy_platform/critical-section",
72-
"bevy_utils/critical-section",
73-
]
69+
critical-section = ["bevy_platform/critical-section"]
7470

7571
## Enables use of browser APIs.
7672
## Note this is currently only applicable on `wasm32` architectures.
@@ -79,9 +75,7 @@ web = ["bevy_platform/web", "uuid?/js"]
7975
[dependencies]
8076
# bevy
8177
bevy_reflect_derive = { path = "derive", version = "0.16.0-dev" }
82-
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false, features = [
83-
"alloc",
84-
] }
78+
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false }
8579
bevy_ptr = { path = "../bevy_ptr", version = "0.16.0-dev" }
8680
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-features = false, features = [
8781
"alloc",

crates/bevy_state/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ bevy_app = ["dep:bevy_app"]
3030
## supported platforms.
3131
std = [
3232
"bevy_ecs/std",
33-
"bevy_utils/std",
3433
"bevy_reflect?/std",
3534
"bevy_app?/std",
3635
"bevy_platform/std",
@@ -40,7 +39,6 @@ std = [
4039
## on all platforms, including `no_std`.
4140
critical-section = [
4241
"bevy_ecs/critical-section",
43-
"bevy_utils/critical-section",
4442
"bevy_app?/critical-section",
4543
"bevy_reflect?/critical-section",
4644
"bevy_platform/critical-section",

crates/bevy_transform/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ std = [
7474
"bevy_math/std",
7575
"bevy_reflect?/std",
7676
"bevy_tasks/std",
77-
"bevy_utils/std",
77+
"bevy_utils/parallel",
7878
"serde?/std",
7979
]
8080

crates/bevy_utils/Cargo.toml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,10 @@ license = "MIT OR Apache-2.0"
99
keywords = ["bevy"]
1010

1111
[features]
12-
default = ["std", "serde"]
12+
default = ["parallel"]
1313

14-
# Functionality
15-
16-
## Adds serialization support through `serde`.
17-
serde = ["bevy_platform/serialize"]
18-
19-
# Platform Compatibility
20-
21-
## Allows access to the `std` crate. Enabling this feature will prevent compilation
22-
## on `no_std` targets, but provides access to certain additional features on
23-
## supported platforms.
24-
std = ["alloc", "bevy_platform/std", "dep:thread_local"]
25-
26-
## Allows access to the `alloc` crate.
27-
alloc = ["bevy_platform/alloc"]
28-
29-
## `critical-section` provides the building blocks for synchronization primitives
30-
## on all platforms, including `no_std`.
31-
critical-section = ["bevy_platform/critical-section"]
14+
# Provides access to the `Parallel` type.
15+
parallel = ["bevy_platform/std", "dep:thread_local"]
3216

3317
[dependencies]
3418
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev", default-features = false }

0 commit comments

Comments
 (0)