-
-
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_meshwill 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_backendfeature, as thats not an actual crate) - cross-crate features between
bevy_crate1andbevy_crate2are namedcrate1_crate2, in the order that most makes sense, when possible. (lets call itui_pickinginstead ofbevy_ui_picking_backend, andgltf_animationinstead 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
pickingfeature, but yesui_picking, and we can have areflectfeature which enables a group of more granularreflect_ecs,reflect_cameraetc. features, each of which do not force-enable any crates besides bevy_reflect thanks to ? feature syntax. note there is nobevy_reflectfeature currently, it is always enabled) - cross-crate features need not propagate to identically-named features: for example
reflect_ecsenablesbevy_ecs?/bevy_reflect. There is noreflect_ecsfeature 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:
animationbecomesgltf_animationbevy_ui_picking_backendbecomesui_pickingbevy_mesh_picking_backendbecomesmesh_pickingbevy_sprite_picking_backendbecomessprite_picking- we add
sprite_text,sprite_render_text,ui_text,ui_render_text, for gatingbevy_textsupport on each ofbevy_sprite,bevy_sprite_render,bevy_ui,bevy_ui_render pbr_gizmos,sprite_gizmosfeatures for gatingbevy_gizmossupport onbevy_pbrandbevy_sprite- potentially a few more such as discussed in make bevy_mesh optional for bevy_animate #20742
- a new
reflectfeature 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