From 35e0b5be0011126bbbb1e1dcc62a497de7dd5385 Mon Sep 17 00:00:00 2001 From: Matty Weatherley Date: Mon, 23 Dec 2024 22:09:36 -0500 Subject: [PATCH] Make `bevy_reflect` feature of `bevy_math` non-default (#16938) # Objective bevy_reflect is a big part of bevy_math's dependency footprint, and is often not useful when using bevy_math standalone (as I often do). The goal with this PR is to avoid pulling in those dependencies by default without compromising the usability of bevy_math types within Bevy proper. ## Solution `bevy_reflect` has been removed from default features of `bevy_math`. However, the feature is enabled by `bevy_internal`, so that `bevy_reflect` is enabled when `bevy_math` is used through `bevy`. Philosophically, if there were a feature flag toggling reflection on `bevy` globally, then whether `bevy_math` enabled `bevy_reflect` itself would depend on that, but that doesn't exist for the time being. ## Testing It compiles :) ## Migration Guide `bevy_reflect` has been made a non-default feature of `bevy_math`. (It is still enabled when `bevy_math` is used through `bevy`.) You may need to enable this feature if you are using `bevy_math` on its own and desire for the types it exports to implement `Reflect` and other reflection traits. --- crates/bevy_internal/Cargo.toml | 4 +++- crates/bevy_math/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index b00b9f6bb4a16..7450c1c3a64a7 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -271,7 +271,9 @@ bevy_hierarchy = { path = "../bevy_hierarchy", version = "0.15.0-dev" } bevy_input = { path = "../bevy_input", version = "0.15.0-dev" } bevy_input_focus = { path = "../bevy_input_focus", version = "0.15.0-dev" } bevy_log = { path = "../bevy_log", version = "0.15.0-dev" } -bevy_math = { path = "../bevy_math", version = "0.15.0-dev" } +bevy_math = { path = "../bevy_math", version = "0.15.0-dev", features = [ + "bevy_reflect", +] } bevy_ptr = { path = "../bevy_ptr", version = "0.15.0-dev" } bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [ "bevy", diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index f635d2a1c1533..c444004521606 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -42,7 +42,7 @@ bevy_math = { path = ".", version = "0.15.0-dev", default-features = false, feat glam = { version = "0.29", default-features = false, features = ["approx"] } [features] -default = ["std", "rand", "bevy_reflect", "curve"] +default = ["std", "rand", "curve"] std = [ "alloc", "glam/std",