Remove stepping from default features (#12847)

# Objective

Fix #11931 

## Solution

- Make stepping a non-default feature
- Adjust documentation and examples
- In particular, make the breakout example not show the stepping prompt
if compiled without the feature (shows a log message instead)

---

## Changelog

- Removed `bevy_debug_stepping` from default features

## Migration Guide

The system-by-system stepping feature is now disabled by default; to use
it, enable the `bevy_debug_stepping` feature explicitly:

```toml
[dependencies]
bevy = { version = "0.14", features = ["bevy_debug_stepping"] }
```

Code using
[`Stepping`](https://docs.rs/bevy/latest/bevy/ecs/schedule/struct.Stepping.html)
will still compile with the feature disabled, but will print a runtime
error message to the console if the application attempts to enable
stepping.

---------

Co-authored-by: James Liu <contact@jamessliu.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
This commit is contained in:
Jonathan 2024-04-03 22:16:02 +03:00 committed by GitHub
parent 3928d01841
commit eb82ec047e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 25 additions and 11 deletions

View file

@ -79,7 +79,6 @@ default = [
"default_font", "default_font",
"webgl2", "webgl2",
"sysinfo_plugin", "sysinfo_plugin",
"bevy_debug_stepping",
] ]
# Force dynamic linking, which improves iterative compile times # Force dynamic linking, which improves iterative compile times
@ -1685,10 +1684,11 @@ wasm = false
name = "system_stepping" name = "system_stepping"
path = "examples/ecs/system_stepping.rs" path = "examples/ecs/system_stepping.rs"
doc-scrape-examples = true doc-scrape-examples = true
required-features = ["bevy_debug_stepping"]
[package.metadata.example.system_stepping] [package.metadata.example.system_stepping]
name = "System Stepping" name = "System Stepping"
description = "Demonstrate stepping through systems in order of execution" description = "Demonstrate stepping through systems in order of execution."
category = "ECS (Entity Component System)" category = "ECS (Entity Component System)"
wasm = false wasm = false
@ -1744,7 +1744,7 @@ doc-scrape-examples = true
[package.metadata.example.breakout] [package.metadata.example.breakout]
name = "Breakout" name = "Breakout"
description = "An implementation of the classic game \"Breakout\"" description = "An implementation of the classic game \"Breakout\"."
category = "Games" category = "Games"
wasm = true wasm = true

View file

@ -11,7 +11,7 @@ keywords = ["bevy"]
[features] [features]
trace = [] trace = []
bevy_debug_stepping = [] bevy_debug_stepping = []
default = ["bevy_reflect", "bevy_debug_stepping"] default = ["bevy_reflect"]
bevy_reflect = ["dep:bevy_reflect", "bevy_ecs/bevy_reflect"] bevy_reflect = ["dep:bevy_reflect", "bevy_ecs/bevy_reflect"]
[dependencies] [dependencies]

View file

@ -13,7 +13,7 @@ categories = ["game-engines", "data-structures"]
trace = [] trace = []
multi-threaded = ["bevy_tasks/multi-threaded"] multi-threaded = ["bevy_tasks/multi-threaded"]
bevy_debug_stepping = [] bevy_debug_stepping = []
default = ["bevy_reflect", "bevy_debug_stepping"] default = ["bevy_reflect"]
[dependencies] [dependencies]
bevy_ptr = { path = "../bevy_ptr", version = "0.14.0-dev" } bevy_ptr = { path = "../bevy_ptr", version = "0.14.0-dev" }

View file

@ -18,7 +18,6 @@ The default feature set enables most of the expected features of a game engine,
|bevy_audio|Provides audio functionality| |bevy_audio|Provides audio functionality|
|bevy_color|Provides shared color types and operations| |bevy_color|Provides shared color types and operations|
|bevy_core_pipeline|Provides cameras and other basic render pipeline features| |bevy_core_pipeline|Provides cameras and other basic render pipeline features|
|bevy_debug_stepping|Enable stepping-based debugging of Bevy systems|
|bevy_gilrs|Adds gamepad support| |bevy_gilrs|Adds gamepad support|
|bevy_gizmos|Adds support for rendering gizmos| |bevy_gizmos|Adds support for rendering gizmos|
|bevy_gltf|[glTF](https://www.khronos.org/gltf/) support| |bevy_gltf|[glTF](https://www.khronos.org/gltf/) support|
@ -50,6 +49,7 @@ The default feature set enables most of the expected features of a game engine,
|async-io|Use async-io's implementation of block_on instead of futures-lite's implementation. This is preferred if your application uses async-io.| |async-io|Use async-io's implementation of block_on instead of futures-lite's implementation. This is preferred if your application uses async-io.|
|basis-universal|Basis Universal compressed texture support| |basis-universal|Basis Universal compressed texture support|
|bevy_ci_testing|Enable systems that allow for automated testing on CI| |bevy_ci_testing|Enable systems that allow for automated testing on CI|
|bevy_debug_stepping|Enable stepping-based debugging of Bevy systems|
|bevy_dev_tools|Provides a collection of developer tools| |bevy_dev_tools|Provides a collection of developer tools|
|bevy_dynamic_plugin|Plugin for dynamic loading (using [libloading](https://crates.io/crates/libloading))| |bevy_dynamic_plugin|Plugin for dynamic loading (using [libloading](https://crates.io/crates/libloading))|
|bmp|BMP image format support| |bmp|BMP image format support|

View file

@ -262,14 +262,14 @@ Example | Description
[System Closure](../examples/ecs/system_closure.rs) | Show how to use closures as systems, and how to configure `Local` variables by capturing external state [System Closure](../examples/ecs/system_closure.rs) | Show how to use closures as systems, and how to configure `Local` variables by capturing external state
[System Parameter](../examples/ecs/system_param.rs) | Illustrates creating custom system parameters with `SystemParam` [System Parameter](../examples/ecs/system_param.rs) | Illustrates creating custom system parameters with `SystemParam`
[System Piping](../examples/ecs/system_piping.rs) | Pipe the output of one system into a second, allowing you to handle any errors gracefully [System Piping](../examples/ecs/system_piping.rs) | Pipe the output of one system into a second, allowing you to handle any errors gracefully
[System Stepping](../examples/ecs/system_stepping.rs) | Demonstrate stepping through systems in order of execution [System Stepping](../examples/ecs/system_stepping.rs) | Demonstrate stepping through systems in order of execution.
## Games ## Games
Example | Description Example | Description
--- | --- --- | ---
[Alien Cake Addict](../examples/games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game [Alien Cake Addict](../examples/games/alien_cake_addict.rs) | Eat the cakes. Eat them all. An example 3D game
[Breakout](../examples/games/breakout.rs) | An implementation of the classic game "Breakout" [Breakout](../examples/games/breakout.rs) | An implementation of the classic game "Breakout".
[Contributors](../examples/games/contributors.rs) | Displays each contributor as a bouncy bevy-ball! [Contributors](../examples/games/contributors.rs) | Displays each contributor as a bouncy bevy-ball!
[Desk Toy](../examples/games/desk_toy.rs) | Bevy logo as a desk toy using transparent windows! Now with Googly Eyes! [Desk Toy](../examples/games/desk_toy.rs) | Bevy logo as a desk toy using transparent windows! Now with Googly Eyes!
[Game Menu](../examples/games/game_menu.rs) | A simple game menu [Game Menu](../examples/games/game_menu.rs) | A simple game menu

View file

@ -1,4 +1,6 @@
//! Demonstrate stepping through systems in order of execution. //! Demonstrate stepping through systems in order of execution.
//!
//! To run this example, you must enable the `bevy_debug_stepping` feature.
use bevy::{ecs::schedule::Stepping, log::LogPlugin, prelude::*}; use bevy::{ecs::schedule::Stepping, log::LogPlugin, prelude::*};

View file

@ -1,4 +1,6 @@
//! A simplified implementation of the classic game "Breakout". //! A simplified implementation of the classic game "Breakout".
//!
//! Demonstrates Bevy's stepping capabilities if compiled with the `bevy_debug_stepping` feature.
use bevy::{ use bevy::{
math::bounding::{Aabb2d, BoundingCircle, BoundingVolume, IntersectsVolume}, math::bounding::{Aabb2d, BoundingCircle, BoundingVolume, IntersectsVolume},

View file

@ -32,6 +32,11 @@ impl SteppingPlugin {
impl Plugin for SteppingPlugin { impl Plugin for SteppingPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.add_systems(Startup, build_stepping_hint);
if cfg!(not(feature = "bevy_debug_stepping")) {
return;
}
// create and insert our debug schedule into the main schedule order. // create and insert our debug schedule into the main schedule order.
// We need an independent schedule so we have access to all other // We need an independent schedule so we have access to all other
// schedules through the `Stepping` resource // schedules through the `Stepping` resource
@ -52,7 +57,6 @@ impl Plugin for SteppingPlugin {
ui_left: self.left, ui_left: self.left,
systems: Vec::new(), systems: Vec::new(),
}) })
.add_systems(Startup, build_help)
.add_systems( .add_systems(
DebugSchedule, DebugSchedule,
( (
@ -182,10 +186,16 @@ fn build_ui(
)); ));
} }
fn build_help(mut commands: Commands, asset_server: Res<AssetServer>) { fn build_stepping_hint(mut commands: Commands, asset_server: Res<AssetServer>) {
let hint_text = if cfg!(feature = "bevy_debug_stepping") {
"Press ` to toggle stepping mode (S: step system, Space: step frame)"
} else {
"Bevy was compiled without stepping support. Run with `--features=bevy_debug_stepping` to enable stepping."
};
info!("{}", hint_text);
// stepping description box // stepping description box
commands.spawn((TextBundle::from_sections([TextSection::new( commands.spawn((TextBundle::from_sections([TextSection::new(
"Press ` to toggle stepping mode (S: step system, Space: step frame)", hint_text,
TextStyle { TextStyle {
font: asset_server.load(FONT_MEDIUM), font: asset_server.load(FONT_MEDIUM),
font_size: 18.0, font_size: 18.0,