-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
A-Cross-CuttingImpacts the entire engineImpacts the entire engineC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-DependenciesA change to the crates that Bevy depends onA change to the crates that Bevy depends onC-DocsAn addition or correction to our documentationAn addition or correction to our documentationS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Milestone
Description
#20714 triggered some discussion about how we should approach features in bevy. There was some disagreement, and ive been thinking more about it and now believe we can reach an agreement. Proposal for a path forward:
bevy_*
crates always only enable the crate they are named after and any transitivebevy_*
crate dependency features. This means enablingbevy_mesh
will enablebevy_image
, because it has a non-optional dependency on it. This means that if you have a no-default-features bevy with only bevy_mesh feature enabled, you can still import bevy::image, even though bevy_image is not enabled. I think this makes sense, because bevy_image is needed to talk about bevy_mesh atm, so having it easily importable is good.- cross-crate features like gltf animations, which need both bevy_gltf and bevy_animation to work, never enable crate features. They are declared in
feature_name = ["bevy_crate?/feature_name"]
form, and propagated down to all relevant crates. This means we can have them all in default-features, and when a user wants to "remove" a default crate they can easily copy paste the feature list and just delete the crate-name featuresbevy_*
which they do not want, without worrying about which other features are enabling these. - cross-crate features never start with
bevy_
. (i.e. nobevy_ui_picking_backend
feature, as thats not an actual crate) - cross-crate features between
bevy_crate1
andbevy_crate2
are namedcrate1_crate2
, in the order that most makes sense, when possible. (lets call itui_picking
instead ofbevy_ui_picking_backend
, andgltf_animation
instead ofanimation
) - cross-crate features are granular if they can work in isolation: we can make feature groups at a higher level out of more granular features, but not the other way around. (i.e. no
picking
feature, but yesui_picking
, and we can have areflect
feature which enables a group of more granularreflect_ecs
,reflect_camera
etc. features, each of which do not force-enable any crates besides bevy_reflect thanks to ? feature syntax. note there is nobevy_reflect
feature currently, it is always enabled) - cross-crate features need not propagate to identically-named features: for example
reflect_ecs
enablesbevy_ecs?/bevy_reflect
. There is noreflect_ecs
feature onbevy_ecs
, as that would be redundant and hurt single-crate UX.
Adopting this pattern means we need to rename a few features and add a few features:
animation
becomesgltf_animation
bevy_ui_picking_backend
becomesui_picking
bevy_mesh_picking_backend
becomesmesh_picking
bevy_sprite_picking_backend
becomessprite_picking
- we add
sprite_text
,sprite_render_text
,ui_text
,ui_render_text
, for gatingbevy_text
support on each ofbevy_sprite
,bevy_sprite_render
,bevy_ui
,bevy_ui_render
pbr_gizmos
,sprite_gizmos
features for gatingbevy_gizmos
support onbevy_pbr
andbevy_sprite
- potentially a few more such as discussed in make bevy_mesh optional for bevy_animate #20742
- a new
reflect
feature which enables a feature group ofreflect_*
features such asreflect_ecs = ["bevy_ecs?/bevy_reflect"]
,reflect_app = ["bevy_app?/bevy_reflect"]
etc.
IceSentry, afonsolage and BD103BD103
Metadata
Metadata
Assignees
Labels
A-Cross-CuttingImpacts the entire engineImpacts the entire engineC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-DependenciesA change to the crates that Bevy depends onA change to the crates that Bevy depends onC-DocsAn addition or correction to our documentationAn addition or correction to our documentationS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished