Skip to content

Commit 90da20a

Browse files
Simplify targets handling for system_information_diagnostics
1 parent 27a3a85 commit 90da20a

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use bevy_app::prelude::*;
88
/// * windows,
99
/// * android,
1010
/// * macos
11+
/// * freebsd
1112
///
1213
/// NOT supported when using the `bevy/dynamic` feature even when using previously mentioned targets
1314
#[derive(Default)]
@@ -27,15 +28,7 @@ impl SystemInformationDiagnosticsPlugin {
2728
}
2829

2930
// NOTE: sysinfo fails to compile when using bevy dynamic or on iOS and does nothing on wasm
30-
#[cfg(all(
31-
any(
32-
target_os = "linux",
33-
target_os = "windows",
34-
target_os = "android",
35-
target_os = "macos"
36-
),
37-
not(feature = "dynamic_linking")
38-
))]
31+
#[cfg(all(not(target_os = "ios"), not(feature = "dynamic_linking")))]
3932
pub mod internal {
4033
use bevy_ecs::{prelude::ResMut, system::Local};
4134
use bevy_log::info;
@@ -46,6 +39,10 @@ pub mod internal {
4639
const BYTES_TO_GIB: f64 = 1.0 / 1024.0 / 1024.0 / 1024.0;
4740

4841
pub(crate) fn setup_system(mut diagnostics: ResMut<DiagnosticsStore>) {
42+
if !System::IS_SUPPORTED {
43+
bevy_log::warn!("This platform and/or configuration is not supported!");
44+
return;
45+
}
4946
diagnostics.add(
5047
Diagnostic::new(
5148
super::SystemInformationDiagnosticsPlugin::CPU_USAGE,
@@ -68,6 +65,9 @@ pub mod internal {
6865
mut diagnostics: Diagnostics,
6966
mut sysinfo: Local<Option<System>>,
7067
) {
68+
if !System::IS_SUPPORTED {
69+
return;
70+
}
7171
if sysinfo.is_none() {
7272
*sysinfo = Some(System::new_with_specifics(
7373
RefreshKind::new()
@@ -107,6 +107,9 @@ pub mod internal {
107107
}
108108

109109
pub(crate) fn log_system_info() {
110+
if !System::IS_SUPPORTED {
111+
return;
112+
}
110113
let mut sys = sysinfo::System::new();
111114
sys.refresh_cpu();
112115
sys.refresh_memory();
@@ -131,15 +134,7 @@ pub mod internal {
131134
}
132135
}
133136

134-
#[cfg(not(all(
135-
any(
136-
target_os = "linux",
137-
target_os = "windows",
138-
target_os = "android",
139-
target_os = "macos"
140-
),
141-
not(feature = "dynamic_linking")
142-
)))]
137+
#[cfg(any(target_os = "ios", feature = "dynamic_linking"))]
143138
pub mod internal {
144139
pub(crate) fn setup_system() {
145140
bevy_log::warn!("This platform and/or configuration is not supported!");

0 commit comments

Comments
 (0)