Skip to content

Commit a2b1498

Browse files
bushrat011899mockersf
authored andcommitted
Upgrade to Glam 0.29.3 and Simplify Feature Gating (#18638)
- Fixes #18397 - Supersedes #18474 - Simplifies 0.16 migration - Upgrade to Glam 0.29.3, which has backported the `nostd-libm` feature. - Expose a similar feature in `bevy_math` and enable it in `bevy_internal`, allowing `bevy_math`, `bevy_input`, and `bevy_transform` to be unconditional dependencies again. - CI --- - This includes `libm` as a dependency, but this was already the case in the common scenario where `rand` or many other features were enabled. Considering `libm` is an official Rust crate, it's a very low-risk dependency to unconditionally include. - For users who do not want `libm` included, simply import Bevy's subcrates directly, since `bevy_math/nostd-libm` will not be enabled. - I know we are _very_ late in the RC cycle for 0.16, but this has a substantial impact on the usability of `bevy` that I consider worth including.
1 parent 10daca0 commit a2b1498

File tree

8 files changed

+32
-32
lines changed

8 files changed

+32
-32
lines changed

crates/bevy_internal/Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ serialize = [
9595
"bevy_color?/serialize",
9696
"bevy_ecs/serialize",
9797
"bevy_image?/serialize",
98-
"bevy_input?/serialize",
99-
"bevy_math?/serialize",
98+
"bevy_input/serialize",
99+
"bevy_math/serialize",
100100
"bevy_scene?/serialize",
101101
"bevy_time/serialize",
102-
"bevy_transform?/serialize",
102+
"bevy_transform/serialize",
103103
"bevy_ui?/serialize",
104104
"bevy_window?/serialize",
105105
"bevy_winit?/serialize",
@@ -312,7 +312,7 @@ critical-section = [
312312
"bevy_app/critical-section",
313313
"bevy_diagnostic/critical-section",
314314
"bevy_ecs/critical-section",
315-
"bevy_input?/critical-section",
315+
"bevy_input/critical-section",
316316
"bevy_input_focus?/critical-section",
317317
"bevy_platform_support/critical-section",
318318
"bevy_reflect/critical-section",
@@ -338,7 +338,7 @@ async_executor = [
338338
"std",
339339
"bevy_tasks/async_executor",
340340
"bevy_ecs/async_executor",
341-
"bevy_transform?/async_executor",
341+
"bevy_transform/async_executor",
342342
]
343343

344344
# Enables use of browser APIs.
@@ -362,10 +362,11 @@ bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-rc.2", default-features = f
362362
] }
363363
bevy_input = { path = "../bevy_input", version = "0.16.0-rc.2", default-features = false, features = [
364364
"bevy_reflect",
365-
], optional = true }
365+
] }
366366
bevy_math = { path = "../bevy_math", version = "0.16.0-rc.2", default-features = false, features = [
367-
"bevy_reflect",
368-
], optional = true }
367+
"bevy_reflect",
368+
"nostd-libm",
369+
] }
369370
bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-rc.2", default-features = false, features = [
370371
"alloc",
371372
] }
@@ -379,7 +380,7 @@ bevy_time = { path = "../bevy_time", version = "0.16.0-rc.2", default-features =
379380
bevy_transform = { path = "../bevy_transform", version = "0.16.0-rc.2", default-features = false, features = [
380381
"bevy-support",
381382
"bevy_reflect",
382-
], optional = true }
383+
] }
383384
bevy_utils = { path = "../bevy_utils", version = "0.16.0-rc.2", default-features = false, features = [
384385
"alloc",
385386
] }

crates/bevy_internal/src/default_plugins.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ plugin_group! {
99
bevy_app:::TaskPoolPlugin,
1010
bevy_diagnostic:::FrameCountPlugin,
1111
bevy_time:::TimePlugin,
12-
#[custom(cfg(any(feature = "libm", feature = "std")))]
1312
bevy_transform:::TransformPlugin,
1413
bevy_diagnostic:::DiagnosticsPlugin,
15-
#[custom(cfg(any(feature = "libm", feature = "std")))]
1614
bevy_input:::InputPlugin,
1715
#[custom(cfg(not(feature = "bevy_window")))]
1816
bevy_app:::ScheduleRunnerPlugin,

crates/bevy_internal/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ pub use bevy_gizmos as gizmos;
3939
pub use bevy_gltf as gltf;
4040
#[cfg(feature = "bevy_image")]
4141
pub use bevy_image as image;
42-
#[cfg(any(feature = "libm", feature = "std"))]
4342
pub use bevy_input as input;
4443
#[cfg(feature = "bevy_input_focus")]
4544
pub use bevy_input_focus as input_focus;
4645
#[cfg(feature = "bevy_log")]
4746
pub use bevy_log as log;
48-
#[cfg(any(feature = "libm", feature = "std"))]
4947
pub use bevy_math as math;
5048
#[cfg(feature = "bevy_pbr")]
5149
pub use bevy_pbr as pbr;
@@ -68,7 +66,6 @@ pub use bevy_tasks as tasks;
6866
#[cfg(feature = "bevy_text")]
6967
pub use bevy_text as text;
7068
pub use bevy_time as time;
71-
#[cfg(any(feature = "libm", feature = "std"))]
7269
pub use bevy_transform as transform;
7370
#[cfg(feature = "bevy_ui")]
7471
pub use bevy_ui as ui;

crates/bevy_internal/src/prelude.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#[doc(hidden)]
22
pub use crate::{
3-
app::prelude::*, ecs::prelude::*, platform_support::prelude::*, reflect::prelude::*,
4-
time::prelude::*, utils::prelude::*, DefaultPlugins, MinimalPlugins,
3+
app::prelude::*, ecs::prelude::*, input::prelude::*, math::prelude::*,
4+
platform_support::prelude::*, reflect::prelude::*, time::prelude::*, transform::prelude::*,
5+
utils::prelude::*, DefaultPlugins, MinimalPlugins,
56
};
67

7-
#[doc(hidden)]
8-
#[cfg(any(feature = "libm", feature = "std"))]
9-
pub use crate::{input::prelude::*, math::prelude::*, transform::prelude::*};
10-
118
#[doc(hidden)]
129
#[cfg(feature = "bevy_log")]
1310
pub use crate::log::prelude::*;

crates/bevy_math/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["bevy"]
1010
rust-version = "1.85.0"
1111

1212
[dependencies]
13-
glam = { version = "0.29", default-features = false, features = ["bytemuck"] }
13+
glam = { version = "0.29.3", default-features = false, features = ["bytemuck"] }
1414
thiserror = { version = "2", default-features = false }
1515
derive_more = { version = "1", default-features = false, features = [
1616
"from",
@@ -37,7 +37,7 @@ rand = "0.8"
3737
rand_chacha = "0.3"
3838
# Enable the approx feature when testing.
3939
bevy_math = { path = ".", default-features = false, features = ["approx"] }
40-
glam = { version = "0.29", default-features = false, features = ["approx"] }
40+
glam = { version = "0.29.3", default-features = false, features = ["approx"] }
4141

4242
[features]
4343
default = ["std", "rand", "curve"]
@@ -77,6 +77,9 @@ rand = ["dep:rand", "dep:rand_distr", "glam/rand"]
7777
curve = []
7878
# Enable bevy_reflect (requires alloc)
7979
bevy_reflect = ["dep:bevy_reflect", "alloc"]
80+
# Enable libm mathematical functions as a fallback for no_std environments.
81+
# Can be overridden with std feature.
82+
nostd-libm = ["dep:libm", "glam/nostd-libm"]
8083

8184
[lints]
8285
workspace = true

crates/bevy_math/src/ops.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// - `f32::gamma`
2020
// - `f32::ln_gamma`
2121

22-
#[cfg(not(feature = "libm"))]
22+
#[cfg(all(not(feature = "libm"), feature = "std"))]
2323
#[expect(
2424
clippy::disallowed_methods,
2525
reason = "Many of the disallowed methods are disallowed to force code to use the feature-conditional re-exports from this module, but this module itself is exempt from that rule."
@@ -233,7 +233,7 @@ mod std_ops {
233233
}
234234
}
235235

236-
#[cfg(feature = "libm")]
236+
#[cfg(any(feature = "libm", all(feature = "nostd-libm", not(feature = "std"))))]
237237
mod libm_ops {
238238

239239
/// Raises a number to a floating point power.
@@ -448,7 +448,7 @@ mod libm_ops {
448448
}
449449
}
450450

451-
#[cfg(all(feature = "libm", not(feature = "std")))]
451+
#[cfg(all(any(feature = "libm", feature = "nostd-libm"), not(feature = "std")))]
452452
mod libm_ops_for_no_std {
453453
//! Provides standardized names for [`f32`] operations which may not be
454454
//! supported on `no_std` platforms.
@@ -606,20 +606,24 @@ mod std_ops_for_no_std {
606606
}
607607
}
608608

609-
#[cfg(feature = "libm")]
609+
#[cfg(any(feature = "libm", all(feature = "nostd-libm", not(feature = "std"))))]
610610
pub use libm_ops::*;
611611

612-
#[cfg(not(feature = "libm"))]
612+
#[cfg(all(not(feature = "libm"), feature = "std"))]
613613
pub use std_ops::*;
614614

615615
#[cfg(feature = "std")]
616616
pub use std_ops_for_no_std::*;
617617

618-
#[cfg(all(feature = "libm", not(feature = "std")))]
618+
#[cfg(all(any(feature = "libm", feature = "nostd-libm"), not(feature = "std")))]
619619
pub use libm_ops_for_no_std::*;
620620

621-
#[cfg(all(not(feature = "libm"), not(feature = "std")))]
622-
compile_error!("Either the `libm` feature or the `std` feature must be enabled.");
621+
#[cfg(all(
622+
not(feature = "libm"),
623+
not(feature = "std"),
624+
not(feature = "nostd-libm")
625+
))]
626+
compile_error!("Either the `libm`, `std`, or `nostd-libm` feature must be enabled.");
623627

624628
/// This extension trait covers shortfall in determinacy from the lack of a `libm` counterpart
625629
/// to `f32::powi`. Use this for the common small exponents.

crates/bevy_mikktspace/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ std = ["glam/std"]
2222
libm = ["glam/libm", "dep:libm"]
2323

2424
[dependencies]
25-
glam = { version = "0.29.0", default-features = false }
25+
glam = { version = "0.29.3", default-features = false }
2626
libm = { version = "0.2", default-features = false, optional = true }
2727

2828
[[example]]

crates/bevy_reflect/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ derive_more = { version = "1", default-features = false, features = ["from"] }
9999
serde = { version = "1", default-features = false, features = ["alloc"] }
100100
assert_type_match = "0.1.1"
101101
smallvec = { version = "1.11", default-features = false, optional = true }
102-
glam = { version = "0.29", default-features = false, features = [
102+
glam = { version = "0.29.3", default-features = false, features = [
103103
"serde",
104104
], optional = true }
105105
petgraph = { version = "0.7", features = ["serde-1"], optional = true }

0 commit comments

Comments
 (0)