Skip to content

Commit

Permalink
Remove stepping from default features (#12847)
Browse files Browse the repository at this point in the history
# 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 <[email protected]>
Co-authored-by: François Mockers <[email protected]>
  • Loading branch information
3 people authored Apr 3, 2024
1 parent 3928d01 commit eb82ec0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ default = [
"default_font",
"webgl2",
"sysinfo_plugin",
"bevy_debug_stepping",
]

# Force dynamic linking, which improves iterative compile times
Expand Down Expand Up @@ -1685,10 +1684,11 @@ wasm = false
name = "system_stepping"
path = "examples/ecs/system_stepping.rs"
doc-scrape-examples = true
required-features = ["bevy_debug_stepping"]

[package.metadata.example.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)"
wasm = false

Expand Down Expand Up @@ -1744,7 +1744,7 @@ doc-scrape-examples = true

[package.metadata.example.breakout]
name = "Breakout"
description = "An implementation of the classic game \"Breakout\""
description = "An implementation of the classic game \"Breakout\"."
category = "Games"
wasm = true

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["bevy"]
[features]
trace = []
bevy_debug_stepping = []
default = ["bevy_reflect", "bevy_debug_stepping"]
default = ["bevy_reflect"]
bevy_reflect = ["dep:bevy_reflect", "bevy_ecs/bevy_reflect"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ categories = ["game-engines", "data-structures"]
trace = []
multi-threaded = ["bevy_tasks/multi-threaded"]
bevy_debug_stepping = []
default = ["bevy_reflect", "bevy_debug_stepping"]
default = ["bevy_reflect"]

[dependencies]
bevy_ptr = { path = "../bevy_ptr", version = "0.14.0-dev" }
Expand Down
2 changes: 1 addition & 1 deletion docs/cargo_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The default feature set enables most of the expected features of a game engine,
|bevy_audio|Provides audio functionality|
|bevy_color|Provides shared color types and operations|
|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_gizmos|Adds support for rendering gizmos|
|bevy_gltf|[glTF](https://www.khronos.org/gltf/) support|
Expand Down Expand Up @@ -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.|
|basis-universal|Basis Universal compressed texture support|
|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_dynamic_plugin|Plugin for dynamic loading (using [libloading](https://crates.io/crates/libloading))|
|bmp|BMP image format support|
Expand Down
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 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

Example | Description
--- | ---
[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!
[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
Expand Down
2 changes: 2 additions & 0 deletions examples/ecs/system_stepping.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! 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::*};

Expand Down
2 changes: 2 additions & 0 deletions examples/games/breakout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! A simplified implementation of the classic game "Breakout".
//!
//! Demonstrates Bevy's stepping capabilities if compiled with the `bevy_debug_stepping` feature.

use bevy::{
math::bounding::{Aabb2d, BoundingCircle, BoundingVolume, IntersectsVolume},
Expand Down
16 changes: 13 additions & 3 deletions examples/games/stepping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ impl SteppingPlugin {

impl Plugin for SteppingPlugin {
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.
// We need an independent schedule so we have access to all other
// schedules through the `Stepping` resource
Expand All @@ -52,7 +57,6 @@ impl Plugin for SteppingPlugin {
ui_left: self.left,
systems: Vec::new(),
})
.add_systems(Startup, build_help)
.add_systems(
DebugSchedule,
(
Expand Down Expand Up @@ -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
commands.spawn((TextBundle::from_sections([TextSection::new(
"Press ` to toggle stepping mode (S: step system, Space: step frame)",
hint_text,
TextStyle {
font: asset_server.load(FONT_MEDIUM),
font_size: 18.0,
Expand Down

0 comments on commit eb82ec0

Please sign in to comment.