# Objective - Contributes to #15460 ## Solution - Added the following features: - `std` (default) - `bevy_tasks` (default) - `downcast ` (default) - `portable-atomic` - `critical-section` - `downcast` and `bevy_tasks` are now optional dependencies for `bevy_app`. ## Testing - CI - Personal UEFI and Raspberry Pi Pico demo applications compile and run against this branch ## Draft Release Notes Bevy's application framework now supports `no_std` platforms. Following up on `bevy_ecs` gaining `no_std` support, `bevy_app` extends the functionality available on these targets to include the powerful `App` and `Plugin` abstractions. With this, library authors now have the option of making their plugins `no_std` compatible, or even offering plugins specifically to improve Bevy on certain embedded platforms! To start making a `no_std` compatible plugin, simply disable default features when including `bevy_app`: ```toml [dependencies] bevy_app = { version = "0.16", default-features = false } ``` We encourage library authors to do this anyway, as it can also help with compile times and binary size on all platforms. Keep an eye out for future `no_std` updates as we continue to improve the parity between `std` and `no_std`. We look forward to seeing what kinds of applications are now possible with Bevy! ## Notes - `downcast-rs` is optional as it isn't compatible with `portable-atomic`. I will investigate making a PR upstream to add support for this functionality, as it should be very straightforward. - In line with the `bevy_ecs` no-std-ification, I've added documentation to all features, and grouped them as well. - ~~Creating this PR in draft while CI runs and so I can polish before review.~~ --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
116 lines
4.1 KiB
Rust
116 lines
4.1 KiB
Rust
use crate::{Flag, Prepare, PreparedCommand};
|
|
use argh::FromArgs;
|
|
use xshell::cmd;
|
|
|
|
/// Checks that the project compiles for a `no_std` target.
|
|
/// Note that this tool will attempt to install the target via rustup.
|
|
/// This can be skipped by passing the "--skip-install" flag.
|
|
#[derive(FromArgs)]
|
|
#[argh(subcommand, name = "compile-check-no-std")]
|
|
pub struct CompileCheckNoStdCommand {
|
|
/// the target to check against.
|
|
/// Defaults to "x86_64-unknown-none"
|
|
#[argh(option, default = "Self::default().target")]
|
|
target: String,
|
|
/// skip attempting the installation of the target.
|
|
#[argh(switch)]
|
|
skip_install: bool,
|
|
}
|
|
|
|
impl Default for CompileCheckNoStdCommand {
|
|
fn default() -> Self {
|
|
Self {
|
|
target: String::from("x86_64-unknown-none"),
|
|
skip_install: false,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Prepare for CompileCheckNoStdCommand {
|
|
fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec<PreparedCommand<'a>> {
|
|
let target = self.target.as_str();
|
|
let mut commands = Vec::new();
|
|
|
|
if !self.skip_install {
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(sh, "rustup target add {target}"),
|
|
"Unable to add the required target via rustup, is it spelled correctly?",
|
|
));
|
|
}
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_ptr --no-default-features --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_ptr no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_utils --no-default-features --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_utils no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_mikktspace --no-default-features --features libm --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_mikktspace no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_reflect --no-default-features --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_reflect no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_math --no-default-features --features libm --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_math no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_color --no-default-features --features libm --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_color no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_tasks --no-default-features --features edge_executor,critical-section --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_tasks no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_ecs --no-default-features --features edge_executor,critical-section,bevy_debug_stepping,bevy_reflect --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_ecs no_std compatibility.",
|
|
));
|
|
|
|
commands.push(PreparedCommand::new::<Self>(
|
|
cmd!(
|
|
sh,
|
|
"cargo check -p bevy_app --no-default-features --features bevy_reflect --target {target}"
|
|
),
|
|
"Please fix compiler errors in output above for bevy_app no_std compatibility.",
|
|
));
|
|
|
|
commands
|
|
}
|
|
}
|