Skip to content

Commit 7826313

Browse files
AxiomaticSemanticsebolamockersf
authored
Make sysinfo diagnostic plugin optional (#12164)
# Objective - Fixes #11929 - make sysinfo plugin optional ## Solution - added features to allow for conditional compilation --- ## Migration Guide - For users who disable default features of bevy and wish to enable the diagnostic plugin, add `sysinfo_plugin` to your bevy features list. --------- Co-authored-by: ebola <dev@axiomatic> Co-authored-by: François <mockersf@gmail.com>
1 parent c13de09 commit 7826313

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,16 @@ default = [
7777
"tonemapping_luts",
7878
"default_font",
7979
"webgl2",
80+
"sysinfo_plugin",
8081
"bevy_debug_stepping",
8182
]
8283

8384
# Force dynamic linking, which improves iterative compile times
8485
dynamic_linking = ["dep:bevy_dylib", "bevy_internal/dynamic_linking"]
8586

87+
# Enables system information diagnostic plugin
88+
sysinfo_plugin = ["bevy_internal/sysinfo_plugin"]
89+
8690
# Provides animation functionality
8791
bevy_animation = ["bevy_internal/bevy_animation", "bevy_color"]
8892

crates/bevy_diagnostic/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ keywords = ["bevy"]
1111
[features]
1212
# Disables diagnostics that are unsupported when Bevy is dynamically linked
1313
dynamic_linking = []
14+
sysinfo_plugin = ["sysinfo"]
15+
features = []
1416

1517
[dependencies]
1618
# bevy
@@ -26,13 +28,13 @@ const-fnv1a-hash = "1.1.0"
2628
# MacOS
2729
[target.'cfg(all(target_os="macos"))'.dependencies]
2830
# Some features of sysinfo are not supported by apple. This will disable those features on apple devices
29-
sysinfo = { version = "0.30.0", default-features = false, features = [
31+
sysinfo = { version = "0.30.0", optional = true, default-features = false, features = [
3032
"apple-app-store",
3133
] }
3234

3335
# Only include when not bevy_dynamic_plugin and on linux/windows/android
3436
[target.'cfg(any(target_os = "linux", target_os = "windows", target_os = "android"))'.dependencies]
35-
sysinfo = { version = "0.30.0", default-features = false }
37+
sysinfo = { version = "0.30.0", optional = true, default-features = false }
3638

3739
[lints]
3840
workspace = true

crates/bevy_diagnostic/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,27 @@ mod diagnostic;
99
mod entity_count_diagnostics_plugin;
1010
mod frame_time_diagnostics_plugin;
1111
mod log_diagnostics_plugin;
12+
#[cfg(feature = "sysinfo_plugin")]
1213
mod system_information_diagnostics_plugin;
1314

14-
use bevy_app::prelude::*;
1515
pub use diagnostic::*;
16+
1617
pub use entity_count_diagnostics_plugin::EntityCountDiagnosticsPlugin;
1718
pub use frame_time_diagnostics_plugin::FrameTimeDiagnosticsPlugin;
1819
pub use log_diagnostics_plugin::LogDiagnosticsPlugin;
20+
#[cfg(feature = "sysinfo_plugin")]
1921
pub use system_information_diagnostics_plugin::SystemInformationDiagnosticsPlugin;
2022

23+
use bevy_app::prelude::*;
24+
2125
/// Adds core diagnostics resources to an App.
2226
#[derive(Default)]
2327
pub struct DiagnosticsPlugin;
2428

2529
impl Plugin for DiagnosticsPlugin {
26-
fn build(&self, app: &mut App) {
27-
app.init_resource::<DiagnosticsStore>().add_systems(
30+
fn build(&self, _app: &mut App) {
31+
#[cfg(feature = "sysinfo_plugin")]
32+
_app.init_resource::<DiagnosticsStore>().add_systems(
2833
Startup,
2934
system_information_diagnostics_plugin::internal::log_system_info,
3035
);

crates/bevy_internal/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ trace_tracy_memory = ["bevy_log/trace_tracy_memory"]
2525
wgpu_trace = ["bevy_render/wgpu_trace"]
2626
detailed_trace = ["bevy_utils/detailed_trace"]
2727

28+
sysinfo_plugin = ["bevy_diagnostic/sysinfo_plugin"]
29+
2830
# Image format support for texture loading (PNG and HDR are enabled by default)
2931
exr = ["bevy_render/exr"]
3032
hdr = ["bevy_render/hdr"]

docs/cargo_features.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The default feature set enables most of the expected features of a game engine,
3434
|ktx2|KTX2 compressed texture support|
3535
|multi-threaded|Enables multithreaded parallelism in the engine. Disabling it forces all engine tasks to run on a single thread.|
3636
|png|PNG image format support|
37+
|sysinfo_plugin|Enables system information diagnostic plugin|
3738
|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.|
3839
|vorbis|OGG/VORBIS audio format support|
3940
|webgl2|Enable some limitations to be able to use WebGL2. Please refer to the [WebGL2 and WebGPU](https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu) section of the examples README for more information on how to run Wasm builds with WebGPU.|

0 commit comments

Comments
 (0)