|
1 | 1 | <!-- Add `no_std` support to `bevy` -->
|
2 | 2 | <!-- https://github.com/bevyengine/bevy/pull/17955 -->
|
3 | 3 |
|
4 |
| -<!-- TODO --> |
| 4 | +Bevy now has support for `no_std` targets, allowing it to be used on a much wider range of platforms. |
| 5 | + |
| 6 | +This has been functionality [discussed] going back over 4 years, but was initially dropped to avoid the added complexity managing `no_std` support can bring. |
| 7 | +To be `no_std` compatible, your crate and _all_ of its dependencies must also be `no_std`. |
| 8 | +Coordinating that kind of support across over a hundred dependencies was just not feasible, let alone losing access to Rust's standard library. |
| 9 | + |
| 10 | +Since then, Rust's support for `no_std` has evolved dramatically with support for critical APIs such as [`Error`] coming in [Rust 1.81]. |
| 11 | +Starting with tracking issue [#15460] and a [`no_std` Working Group], Bevy's various crates were individually made `no_std` compatible where possible. |
| 12 | +To aid this effort, [`bevy_platform_support`] was developed with the goal of providing opinionated alternatives to `std` items. |
| 13 | + |
| 14 | +This effort reached a substantial milestone during the development of Bevy 0.16: support for `no_std` in our main `bevy` crate. |
| 15 | +To use Bevy on a `no_std` platform, simply disable default features and use Bevy just like any other `no_std` dependency. |
| 16 | + |
| 17 | +```toml |
| 18 | +[dependencies] |
| 19 | +bevy = { version = "0.16", default-features = false } |
| 20 | +``` |
| 21 | + |
| 22 | +Note that not all of Bevy's features are compatible with `no_std` yet. |
| 23 | +Rendering, audio, and assets are notable missing APIs that you will need to find an alternative for that's suitable for your platform. |
| 24 | +But, Bevy's powerful [`Plugin`] system allows the community to build back support for that functionality for their particular platforms. |
| 25 | + |
| 26 | +For those community members working on libraries for Bevy, we encourage you to try out `no_std` support if you can! |
| 27 | +There's a new [`no_std` library] example which demonstrates how to make a crate that is compatible with `std` and `no_std` users, with detailed comments and advice. |
| 28 | +During the release candidate period, quite a few libraries have successfully experimented with `no_std` support, such as [`bevy_rand`] and [`bevy_replicon`]. |
| 29 | + |
| 30 | +Determining what `no_std` targets support Bevy is still a work in progress. |
| 31 | +But early reports from users have shown Bevy working on bare-metal desktops, embedded devices, and even retro consoles such as the GameBoy Advance. |
| 32 | + |
| 33 | +If you have an unusual platform you'd like to try getting Bevy working on, check out the [`#unusual-platforms`] channel on Bevy's Discord server for advice! |
| 34 | + |
| 35 | +[`Error`]: https://doc.rust-lang.org/stable/core/error/trait.Error.html |
| 36 | +[#15460]: https://github.com/bevyengine/bevy/issues/15460 |
| 37 | +[`no_std` Working Group]: https://discord.com/channels/691052431525675048/1303128171352293410 |
| 38 | +[`bevy_platform_support`]: https://crates.io/crates/bevy_platform_support/ |
| 39 | +[`#unusual-platforms`]: https://discord.com/channels/691052431525675048/1284885928837517432 |
| 40 | +[discussed]: https://github.com/bevyengine/bevy/discussions/705 |
| 41 | +[`Plugin`]: https://docs.rs/bevy/latest/bevy/app/trait.Plugin.html |
| 42 | +[Rust 1.81]: https://releases.rs/docs/1.81.0/#stabilized-apis |
| 43 | +[`no_std` library]: https://github.com/bevyengine/bevy/tree/main/examples/no_std/library |
| 44 | +[`bevy_replicon`]: https://github.com/projectharmonia/bevy_replicon/tree/bevy-0.16-dev |
| 45 | +[`bevy_rand`]: https://github.com/Bluefinger/bevy_rand |
0 commit comments