feature gate picking backends (#15369)

# Objective

Fixes #15306

## Solution

- Add feature gate on the module and the place where each one is used
- Declare the features and make them default

## Testing

- CI
This commit is contained in:
Benjamin Brienen 2024-09-22 21:35:15 +02:00 committed by GitHub
parent 58f6fa94a2
commit 9386bd0114
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 22 additions and 7 deletions

View file

@ -68,6 +68,8 @@ default = [
"bevy_core_pipeline",
"bevy_pbr",
"bevy_picking",
"bevy_sprite_picking_backend",
"bevy_ui_picking_backend",
"bevy_gltf",
"bevy_render",
"bevy_sprite",
@ -87,6 +89,12 @@ default = [
"sysinfo_plugin",
]
# Provides an implementation for picking sprites
bevy_sprite_picking_backend = ["bevy_picking"]
# Provides an implementation for picking ui
bevy_ui_picking_backend = ["bevy_picking"]
# Force dynamic linking, which improves iterative compile times
dynamic_linking = ["dep:bevy_dylib", "bevy_internal/dynamic_linking"]
@ -141,6 +149,7 @@ bevy_sprite = [
"bevy_render",
"bevy_core_pipeline",
"bevy_color",
"bevy_sprite_picking_backend",
]
# Provides text functionality
@ -153,6 +162,7 @@ bevy_ui = [
"bevy_text",
"bevy_sprite",
"bevy_color",
"bevy_ui_picking_backend",
]
# winit window and input backend
@ -3459,12 +3469,14 @@ wasm = true
name = "sprite_picking"
path = "examples/picking/sprite_picking.rs"
doc-scrape-examples = true
required-features = ["bevy_sprite_picking_backend"]
[package.metadata.example.sprite_picking]
name = "Sprite Picking"
description = "Demonstrates picking sprites and sprite atlases"
category = "Picking"
wasm = true
required-features = ["bevy_sprite_picking_backend"]
[[example]]
name = "animation_masks"

View file

@ -9,7 +9,8 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]
[features]
bevy_picking = ["dep:bevy_picking", "dep:bevy_window"]
default = ["bevy_sprite_picking_backend"]
bevy_sprite_picking_backend = ["bevy_picking", "bevy_window"]
webgl = []
webgpu = []

View file

@ -11,7 +11,7 @@
mod bundle;
mod dynamic_texture_atlas_builder;
mod mesh2d;
#[cfg(feature = "bevy_picking")]
#[cfg(feature = "bevy_sprite_picking_backend")]
mod picking_backend;
mod render;
mod sprite;
@ -134,7 +134,7 @@ impl Plugin for SpritePlugin {
),
);
#[cfg(feature = "bevy_picking")]
#[cfg(feature = "bevy_sprite_picking_backend")]
app.add_plugins(picking_backend::SpritePickingBackend);
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {

View file

@ -40,9 +40,9 @@ nonmax = "0.5"
smallvec = "1.11"
[features]
default = ["bevy_ui_picking_backend"]
serialize = ["serde", "smallvec/serde", "bevy_math/serialize"]
bevy_picking = ["dep:bevy_picking"]
bevy_ui_picking_backend = ["bevy_picking"]
[lints]
workspace = true

View file

@ -17,7 +17,7 @@ pub mod ui_material;
pub mod update;
pub mod widget;
#[cfg(feature = "bevy_picking")]
#[cfg(feature = "bevy_ui_picking_backend")]
pub mod picking_backend;
use bevy_derive::{Deref, DerefMut};
@ -194,7 +194,7 @@ impl Plugin for UiPlugin {
build_ui_render(app);
#[cfg(feature = "bevy_picking")]
#[cfg(feature = "bevy_ui_picking_backend")]
app.add_plugins(picking_backend::UiPickingBackend);
}

View file

@ -26,9 +26,11 @@ The default feature set enables most of the expected features of a game engine,
|bevy_render|Provides rendering functionality|
|bevy_scene|Provides scene functionality|
|bevy_sprite|Provides sprite functionality|
|bevy_sprite_picking_backend|Provides an implementation for picking sprites|
|bevy_state|Enable built in global state machines|
|bevy_text|Provides text functionality|
|bevy_ui|A custom ECS-driven UI framework|
|bevy_ui_picking_backend|Provides an implementation for picking ui|
|bevy_winit|winit window and input backend|
|default_font|Include a default font, containing only ASCII characters, at the cost of a 20kB binary size increase|
|hdr|HDR image format support|