Add no_std
Support to bevy_a11y
(#17505)
# Objective - Contributes to #15460 ## Solution - Add `std` feature gate - Fixed partially used serialisation and reflection features. ## Testing - CI
This commit is contained in:
parent
434bbe6027
commit
9387fcfbf2
@ -8,15 +8,73 @@ repository = "https://github.com/bevyengine/bevy"
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
keywords = ["bevy", "accessibility", "a11y"]
|
keywords = ["bevy", "accessibility", "a11y"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["std", "bevy_reflect", "bevy_ecs/async_executor"]
|
||||||
|
|
||||||
|
# Functionality
|
||||||
|
|
||||||
|
## Adds runtime reflection support using `bevy_reflect`.
|
||||||
|
bevy_reflect = [
|
||||||
|
"dep:bevy_reflect",
|
||||||
|
"bevy_app/bevy_reflect",
|
||||||
|
"bevy_ecs/bevy_reflect",
|
||||||
|
"bevy_input_focus/bevy_reflect",
|
||||||
|
]
|
||||||
|
|
||||||
|
## Adds serialization support through `serde`.
|
||||||
|
serialize = [
|
||||||
|
"dep:serde",
|
||||||
|
"bevy_ecs/serialize",
|
||||||
|
"bevy_input_focus/serialize",
|
||||||
|
"accesskit/serde",
|
||||||
|
]
|
||||||
|
|
||||||
|
# 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 = [
|
||||||
|
"bevy_app/std",
|
||||||
|
"bevy_ecs/std",
|
||||||
|
"bevy_reflect/std",
|
||||||
|
"bevy_input_focus/std",
|
||||||
|
]
|
||||||
|
|
||||||
|
## `critical-section` provides the building blocks for synchronization primitives
|
||||||
|
## on all platforms, including `no_std`.
|
||||||
|
critical-section = [
|
||||||
|
"bevy_app/critical-section",
|
||||||
|
"bevy_ecs/critical-section",
|
||||||
|
"bevy_reflect?/critical-section",
|
||||||
|
"bevy_input_focus/critical-section",
|
||||||
|
]
|
||||||
|
|
||||||
|
## `portable-atomic` provides additional platform support for atomic types and
|
||||||
|
## operations, even on targets without native support.
|
||||||
|
portable-atomic = [
|
||||||
|
"bevy_app/portable-atomic",
|
||||||
|
"bevy_ecs/portable-atomic",
|
||||||
|
"bevy_reflect?/portable-atomic",
|
||||||
|
"bevy_input_focus/portable-atomic",
|
||||||
|
]
|
||||||
|
|
||||||
|
## Uses the `libm` maths library instead of the one provided in `std` and `core`.
|
||||||
|
libm = ["bevy_input_focus/libm"]
|
||||||
|
|
||||||
[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_derive = { path = "../bevy_derive", version = "0.16.0-dev" }
|
bevy_derive = { path = "../bevy_derive", version = "0.16.0-dev" }
|
||||||
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
|
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev", default-features = false }
|
||||||
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev" }
|
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", default-features = false, optional = true }
|
||||||
bevy_input_focus = { path = "../bevy_input_focus", version = "0.16.0-dev" }
|
bevy_input_focus = { path = "../bevy_input_focus", version = "0.16.0-dev", default-features = false }
|
||||||
|
|
||||||
accesskit = "0.17"
|
# other
|
||||||
|
accesskit = { version = "0.17", default-features = false }
|
||||||
|
serde = { version = "1", default-features = false, features = [
|
||||||
|
"alloc",
|
||||||
|
], optional = true }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
workspace = true
|
workspace = true
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
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]
|
||||||
|
|
||||||
//! Accessibility for Bevy
|
//! Accessibility for Bevy
|
||||||
//!
|
//!
|
||||||
@ -13,6 +14,9 @@
|
|||||||
//!
|
//!
|
||||||
//! Make sure to use the same version of `accesskit` as Bevy.
|
//! Make sure to use the same version of `accesskit` as Bevy.
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
extern crate std;
|
||||||
|
|
||||||
extern crate alloc;
|
extern crate alloc;
|
||||||
|
|
||||||
use alloc::sync::Arc;
|
use alloc::sync::Arc;
|
||||||
@ -27,8 +31,21 @@ use bevy_ecs::{
|
|||||||
schedule::SystemSet,
|
schedule::SystemSet,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "bevy_reflect")]
|
||||||
|
use {
|
||||||
|
bevy_ecs::reflect::ReflectResource, bevy_reflect::std_traits::ReflectDefault,
|
||||||
|
bevy_reflect::Reflect,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "serialize")]
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[cfg(all(feature = "bevy_reflect", feature = "serialize"))]
|
||||||
|
use bevy_reflect::{ReflectDeserialize, ReflectSerialize};
|
||||||
|
|
||||||
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
|
/// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`.
|
||||||
#[derive(Event, Deref, DerefMut)]
|
#[derive(Event, Deref, DerefMut)]
|
||||||
|
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||||
pub struct ActionRequest(pub accesskit::ActionRequest);
|
pub struct ActionRequest(pub accesskit::ActionRequest);
|
||||||
|
|
||||||
/// Resource that tracks whether an assistive technology has requested
|
/// Resource that tracks whether an assistive technology has requested
|
||||||
@ -37,6 +54,7 @@ pub struct ActionRequest(pub accesskit::ActionRequest);
|
|||||||
/// Useful if a third-party plugin needs to conditionally integrate with
|
/// Useful if a third-party plugin needs to conditionally integrate with
|
||||||
/// `AccessKit`
|
/// `AccessKit`
|
||||||
#[derive(Resource, Default, Clone, Debug, Deref, DerefMut)]
|
#[derive(Resource, Default, Clone, Debug, Deref, DerefMut)]
|
||||||
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default, Resource))]
|
||||||
pub struct AccessibilityRequested(Arc<AtomicBool>);
|
pub struct AccessibilityRequested(Arc<AtomicBool>);
|
||||||
|
|
||||||
impl AccessibilityRequested {
|
impl AccessibilityRequested {
|
||||||
@ -59,6 +77,12 @@ impl AccessibilityRequested {
|
|||||||
/// accessibility updates instead. Without this, the external library and ECS
|
/// accessibility updates instead. Without this, the external library and ECS
|
||||||
/// will generate conflicting updates.
|
/// will generate conflicting updates.
|
||||||
#[derive(Resource, Clone, Debug, Deref, DerefMut)]
|
#[derive(Resource, Clone, Debug, Deref, DerefMut)]
|
||||||
|
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||||
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Resource))]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "bevy_reflect", feature = "serialize"),
|
||||||
|
reflect(Serialize, Deserialize)
|
||||||
|
)]
|
||||||
pub struct ManageAccessibilityUpdates(bool);
|
pub struct ManageAccessibilityUpdates(bool);
|
||||||
|
|
||||||
impl Default for ManageAccessibilityUpdates {
|
impl Default for ManageAccessibilityUpdates {
|
||||||
@ -88,6 +112,7 @@ impl ManageAccessibilityUpdates {
|
|||||||
/// If the entity doesn't have a parent, or if the immediate parent doesn't have
|
/// If the entity doesn't have a parent, or if the immediate parent doesn't have
|
||||||
/// an `AccessibilityNode`, its node will be an immediate child of the primary window.
|
/// an `AccessibilityNode`, its node will be an immediate child of the primary window.
|
||||||
#[derive(Component, Clone, Deref, DerefMut)]
|
#[derive(Component, Clone, Deref, DerefMut)]
|
||||||
|
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||||
pub struct AccessibilityNode(pub Node);
|
pub struct AccessibilityNode(pub Node);
|
||||||
|
|
||||||
impl From<Node> for AccessibilityNode {
|
impl From<Node> for AccessibilityNode {
|
||||||
@ -98,6 +123,12 @@ impl From<Node> for AccessibilityNode {
|
|||||||
|
|
||||||
/// Set enum for the systems relating to accessibility
|
/// Set enum for the systems relating to accessibility
|
||||||
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
|
||||||
|
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
|
||||||
|
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(feature = "bevy_reflect", feature = "serialize"),
|
||||||
|
reflect(Serialize, Deserialize)
|
||||||
|
)]
|
||||||
pub enum AccessibilitySystem {
|
pub enum AccessibilitySystem {
|
||||||
/// Update the accessibility tree
|
/// Update the accessibility tree
|
||||||
Update,
|
Update,
|
||||||
|
@ -131,7 +131,7 @@ impl Prepare for CompileCheckNoStdCommand {
|
|||||||
sh,
|
sh,
|
||||||
"cargo check -p bevy_window --no-default-features --features libm,bevy_reflect,serialize --target {target}"
|
"cargo check -p bevy_window --no-default-features --features libm,bevy_reflect,serialize --target {target}"
|
||||||
),
|
),
|
||||||
"Please fix compiler errors in output above for bevy_state no_std compatibility.",
|
"Please fix compiler errors in output above for bevy_window no_std compatibility.",
|
||||||
));
|
));
|
||||||
|
|
||||||
commands.push(PreparedCommand::new::<Self>(
|
commands.push(PreparedCommand::new::<Self>(
|
||||||
@ -147,7 +147,7 @@ impl Prepare for CompileCheckNoStdCommand {
|
|||||||
sh,
|
sh,
|
||||||
"cargo check -p bevy_time --no-default-features --features bevy_reflect,serialize --target {target}"
|
"cargo check -p bevy_time --no-default-features --features bevy_reflect,serialize --target {target}"
|
||||||
),
|
),
|
||||||
"Please fix compiler errors in output above for bevy_transform no_std compatibility.",
|
"Please fix compiler errors in output above for bevy_time no_std compatibility.",
|
||||||
));
|
));
|
||||||
|
|
||||||
commands.push(PreparedCommand::new::<Self>(
|
commands.push(PreparedCommand::new::<Self>(
|
||||||
@ -155,7 +155,15 @@ impl Prepare for CompileCheckNoStdCommand {
|
|||||||
sh,
|
sh,
|
||||||
"cargo check -p bevy_input_focus --no-default-features --features libm,serialize,bevy_reflect --target {target}"
|
"cargo check -p bevy_input_focus --no-default-features --features libm,serialize,bevy_reflect --target {target}"
|
||||||
),
|
),
|
||||||
"Please fix compiler errors in output above for bevy_input no_std compatibility.",
|
"Please fix compiler errors in output above for bevy_input_focus no_std compatibility.",
|
||||||
|
));
|
||||||
|
|
||||||
|
commands.push(PreparedCommand::new::<Self>(
|
||||||
|
cmd!(
|
||||||
|
sh,
|
||||||
|
"cargo check -p bevy_a11y --no-default-features --features libm,serialize,bevy_reflect --target {target}"
|
||||||
|
),
|
||||||
|
"Please fix compiler errors in output above for bevy_a11y no_std compatibility.",
|
||||||
));
|
));
|
||||||
|
|
||||||
commands
|
commands
|
||||||
|
Loading…
Reference in New Issue
Block a user