Add no_std
support to bevy_diagnostic
(#17507)
# Objective - Contributes to #15460 ## Solution - Added required features - Switched from `tracing` to `log` - Fixed imports ## Testing - CI
This commit is contained in:
parent
da57dfb62f
commit
8e6bf0637b
@ -9,26 +9,80 @@ license = "MIT OR Apache-2.0"
|
|||||||
keywords = ["bevy"]
|
keywords = ["bevy"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
# Disables diagnostics that are unsupported when Bevy is dynamically linked
|
default = ["std", "bevy_ecs/default"]
|
||||||
|
|
||||||
|
# Functionality
|
||||||
|
|
||||||
|
## Adds serialization support through `serde`.
|
||||||
|
serialize = [
|
||||||
|
"dep:serde",
|
||||||
|
"bevy_ecs/serialize",
|
||||||
|
"bevy_time/serialize",
|
||||||
|
"bevy_utils/serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
## Disables diagnostics that are unsupported when Bevy is dynamically linked
|
||||||
dynamic_linking = []
|
dynamic_linking = []
|
||||||
sysinfo_plugin = ["sysinfo"]
|
|
||||||
serialize = ["dep:serde"]
|
## Adds integration with `sysinfo`.
|
||||||
|
sysinfo_plugin = ["sysinfo", "dep:bevy_tasks"]
|
||||||
|
|
||||||
|
# Platform Compatibility
|
||||||
|
|
||||||
|
## Allows access to the `std` crate. Enabling this feature will prevent compilation
|
||||||
|
## on `no_std` targets, but provides access to certain additional features on
|
||||||
|
## supported platforms.
|
||||||
|
std = [
|
||||||
|
"serde?/std",
|
||||||
|
"bevy_ecs/std",
|
||||||
|
"bevy_app/std",
|
||||||
|
"bevy_platform_support/std",
|
||||||
|
"bevy_time/std",
|
||||||
|
"bevy_utils/std",
|
||||||
|
"bevy_tasks?/std",
|
||||||
|
]
|
||||||
|
|
||||||
|
## `critical-section` provides the building blocks for synchronization primitives
|
||||||
|
## on all platforms, including `no_std`.
|
||||||
|
critical-section = [
|
||||||
|
"bevy_ecs/critical-section",
|
||||||
|
"bevy_app/critical-section",
|
||||||
|
"bevy_platform_support/critical-section",
|
||||||
|
"bevy_time/critical-section",
|
||||||
|
"bevy_utils/critical-section",
|
||||||
|
"bevy_tasks?/critical-section",
|
||||||
|
]
|
||||||
|
|
||||||
|
## `portable-atomic` provides additional platform support for atomic types and
|
||||||
|
## operations, even on targets without native support.
|
||||||
|
portable-atomic = [
|
||||||
|
"bevy_ecs/portable-atomic",
|
||||||
|
"bevy_app/portable-atomic",
|
||||||
|
"bevy_platform_support/portable-atomic",
|
||||||
|
"bevy_time/portable-atomic",
|
||||||
|
"bevy_utils/portable-atomic",
|
||||||
|
"bevy_tasks?/portable-atomic",
|
||||||
|
]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# bevy
|
# bevy
|
||||||
bevy_app = { path = "../bevy_app", version = "0.16.0-dev" }
|
bevy_app = { path = "../bevy_app", version = "0.16.0-dev", default-features = false }
|
||||||
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
|
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev", default-features = false }
|
||||||
bevy_time = { path = "../bevy_time", version = "0.16.0-dev" }
|
bevy_time = { path = "../bevy_time", version = "0.16.0-dev", default-features = false }
|
||||||
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev" }
|
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev", default-features = false, features = [
|
||||||
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev" }
|
"alloc",
|
||||||
|
] }
|
||||||
|
bevy_tasks = { path = "../bevy_tasks", version = "0.16.0-dev", default-features = false, optional = true }
|
||||||
bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-dev", default-features = false, features = [
|
bevy_platform_support = { path = "../bevy_platform_support", version = "0.16.0-dev", default-features = false, features = [
|
||||||
"std",
|
"alloc",
|
||||||
] }
|
] }
|
||||||
|
|
||||||
# other
|
# other
|
||||||
const-fnv1a-hash = "1.1.0"
|
const-fnv1a-hash = "1.1.0"
|
||||||
serde = { version = "1.0", optional = true }
|
serde = { version = "1.0", default-features = false, features = [
|
||||||
tracing = { version = "0.1", default-features = false, features = ["std"] }
|
"alloc",
|
||||||
|
], optional = true }
|
||||||
|
log = { version = "0.4", default-features = false }
|
||||||
|
|
||||||
# macOS
|
# macOS
|
||||||
[target.'cfg(all(target_os="macos"))'.dependencies]
|
[target.'cfg(all(target_os="macos"))'.dependencies]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use alloc::{borrow::Cow, collections::VecDeque};
|
use alloc::{borrow::Cow, collections::VecDeque, string::String};
|
||||||
use core::{
|
use core::{
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
|
@ -5,11 +5,15 @@
|
|||||||
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
html_logo_url = "https://bevyengine.org/assets/icon.png",
|
||||||
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
html_favicon_url = "https://bevyengine.org/assets/icon.png"
|
||||||
)]
|
)]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
//! This crate provides a straightforward solution for integrating diagnostics in the [Bevy game engine](https://bevyengine.org/).
|
//! This crate provides a straightforward solution for integrating diagnostics in the [Bevy game engine](https://bevyengine.org/).
|
||||||
//! It allows users to easily add diagnostic functionality to their Bevy applications, enhancing
|
//! It allows users to easily add diagnostic functionality to their Bevy applications, enhancing
|
||||||
//! their ability to monitor and optimize their game's.
|
//! their ability to monitor and optimize their game's.
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
mod diagnostic;
|
mod diagnostic;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use super::{Diagnostic, DiagnosticPath, DiagnosticsStore};
|
use super::{Diagnostic, DiagnosticPath, DiagnosticsStore};
|
||||||
|
use alloc::vec::Vec;
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
use bevy_time::{Real, Time, Timer, TimerMode};
|
use bevy_time::{Real, Time, Timer, TimerMode};
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use tracing::{debug, info};
|
use log::{debug, info};
|
||||||
|
|
||||||
/// An App Plugin that logs diagnostics to the console.
|
/// An App Plugin that logs diagnostics to the console.
|
||||||
///
|
///
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::DiagnosticPath;
|
use crate::DiagnosticPath;
|
||||||
|
use alloc::string::String;
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_ecs::resource::Resource;
|
use bevy_ecs::resource::Resource;
|
||||||
|
|
||||||
@ -56,18 +57,24 @@ pub struct SystemInfo {
|
|||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "macos"
|
target_os = "macos"
|
||||||
),
|
),
|
||||||
not(feature = "dynamic_linking")
|
not(feature = "dynamic_linking"),
|
||||||
|
feature = "std",
|
||||||
))]
|
))]
|
||||||
pub mod internal {
|
pub mod internal {
|
||||||
use alloc::sync::Arc;
|
use alloc::{
|
||||||
use bevy_ecs::{prelude::ResMut, system::Local};
|
format,
|
||||||
use std::{sync::Mutex, time::Instant};
|
string::{String, ToString},
|
||||||
|
sync::Arc,
|
||||||
|
vec::Vec,
|
||||||
|
};
|
||||||
use bevy_app::{App, First, Startup, Update};
|
use bevy_app::{App, First, Startup, Update};
|
||||||
use bevy_ecs::resource::Resource;
|
use bevy_ecs::resource::Resource;
|
||||||
|
use bevy_ecs::{prelude::ResMut, system::Local};
|
||||||
|
use bevy_platform_support::time::Instant;
|
||||||
use bevy_tasks::{available_parallelism, block_on, poll_once, AsyncComputeTaskPool, Task};
|
use bevy_tasks::{available_parallelism, block_on, poll_once, AsyncComputeTaskPool, Task};
|
||||||
|
use log::info;
|
||||||
|
use std::sync::Mutex;
|
||||||
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System};
|
use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System};
|
||||||
use tracing::info;
|
|
||||||
|
|
||||||
use crate::{Diagnostic, Diagnostics, DiagnosticsStore};
|
use crate::{Diagnostic, Diagnostics, DiagnosticsStore};
|
||||||
|
|
||||||
@ -200,9 +207,11 @@ pub mod internal {
|
|||||||
target_os = "android",
|
target_os = "android",
|
||||||
target_os = "macos"
|
target_os = "macos"
|
||||||
),
|
),
|
||||||
not(feature = "dynamic_linking")
|
not(feature = "dynamic_linking"),
|
||||||
|
feature = "std",
|
||||||
)))]
|
)))]
|
||||||
pub mod internal {
|
pub mod internal {
|
||||||
|
use alloc::string::ToString;
|
||||||
use bevy_app::{App, Startup};
|
use bevy_app::{App, Startup};
|
||||||
|
|
||||||
pub(super) fn setup_plugin(app: &mut App) {
|
pub(super) fn setup_plugin(app: &mut App) {
|
||||||
@ -210,7 +219,7 @@ pub mod internal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn setup_system() {
|
fn setup_system() {
|
||||||
tracing::warn!("This platform and/or configuration is not supported!");
|
log::warn!("This platform and/or configuration is not supported!");
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for super::SystemInfo {
|
impl Default for super::SystemInfo {
|
||||||
|
@ -166,6 +166,14 @@ impl Prepare for CompileCheckNoStdCommand {
|
|||||||
"Please fix compiler errors in output above for bevy_a11y no_std compatibility.",
|
"Please fix compiler errors in output above for bevy_a11y no_std compatibility.",
|
||||||
));
|
));
|
||||||
|
|
||||||
|
commands.push(PreparedCommand::new::<Self>(
|
||||||
|
cmd!(
|
||||||
|
sh,
|
||||||
|
"cargo check -p bevy_diagnostic --no-default-features --features serialize --target {target}"
|
||||||
|
),
|
||||||
|
"Please fix compiler errors in output above for bevy_diagnostic no_std compatibility.",
|
||||||
|
));
|
||||||
|
|
||||||
commands
|
commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user