From eb82ec047e4e415f247ffc708df3f4d5464a1f69 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 3 Apr 2024 22:16:02 +0300 Subject: [PATCH] Remove stepping from default features (#12847) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 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 Co-authored-by: François Mockers --- Cargo.toml | 6 +++--- crates/bevy_app/Cargo.toml | 2 +- crates/bevy_ecs/Cargo.toml | 2 +- docs/cargo_features.md | 2 +- examples/README.md | 4 ++-- examples/ecs/system_stepping.rs | 2 ++ examples/games/breakout.rs | 2 ++ examples/games/stepping.rs | 16 +++++++++++++--- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e0c0a790407db..a2915c54f638a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,6 @@ default = [ "default_font", "webgl2", "sysinfo_plugin", - "bevy_debug_stepping", ] # Force dynamic linking, which improves iterative compile times @@ -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 @@ -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 diff --git a/crates/bevy_app/Cargo.toml b/crates/bevy_app/Cargo.toml index 15f511ceb30a2..75136f9db91c2 100644 --- a/crates/bevy_app/Cargo.toml +++ b/crates/bevy_app/Cargo.toml @@ -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] diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index 6e54aaf7359a2..2bdcc2c19c077 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -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" } diff --git a/docs/cargo_features.md b/docs/cargo_features.md index ff4d5313efc3c..573d8b6fbe948 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -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| @@ -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| diff --git a/examples/README.md b/examples/README.md index 7cafb1be7bf43..09f79d6524645 100644 --- a/examples/README.md +++ b/examples/README.md @@ -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 diff --git a/examples/ecs/system_stepping.rs b/examples/ecs/system_stepping.rs index a4e4437362e9e..01b2f7ce71436 100644 --- a/examples/ecs/system_stepping.rs +++ b/examples/ecs/system_stepping.rs @@ -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::*}; diff --git a/examples/games/breakout.rs b/examples/games/breakout.rs index 4e5324b5a0312..1fe1cb17c3346 100644 --- a/examples/games/breakout.rs +++ b/examples/games/breakout.rs @@ -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}, diff --git a/examples/games/stepping.rs b/examples/games/stepping.rs index 61918c330dce6..5c0e433696f80 100644 --- a/examples/games/stepping.rs +++ b/examples/games/stepping.rs @@ -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 @@ -52,7 +57,6 @@ impl Plugin for SteppingPlugin { ui_left: self.left, systems: Vec::new(), }) - .add_systems(Startup, build_help) .add_systems( DebugSchedule, ( @@ -182,10 +186,16 @@ fn build_ui( )); } -fn build_help(mut commands: Commands, asset_server: Res) { +fn build_stepping_hint(mut commands: Commands, asset_server: Res) { + 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,