Skip to content

Commit

Permalink
Add no_std support to bevy_window (#17031)
Browse files Browse the repository at this point in the history
# Objective

- Contributes to #15460

## Solution

- Added the following features:
  - `std` (default)
  - `bevy_reflect` (default)
  - `libm`

## Testing

- CI

## Notes

- `bevy_reflect` was previously always enabled, which isn't how most
other crates handle reflection. I've brought this in line with how most
crates gate `bevy_reflect`. This is where the majority of the changes
come from in this PR.

---------

Co-authored-by: Alice Cecile <[email protected]>
  • Loading branch information
bushrat011899 and alice-i-cecile authored Jan 1, 2025
1 parent 4058bfa commit 10e113d
Show file tree
Hide file tree
Showing 9 changed files with 305 additions and 180 deletions.
67 changes: 56 additions & 11 deletions crates/bevy_window/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,69 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
serialize = ["serde", "smol_str/serde", "bevy_ecs/serialize"]
default = ["std", "bevy_reflect"]

# Functionality

## Adds runtime reflection support using `bevy_reflect`.
bevy_reflect = [
"dep:bevy_reflect",
"bevy_app/bevy_reflect",
"bevy_ecs/bevy_reflect",
"bevy_input/bevy_reflect",
]

## Adds serialization support through `serde`.
serialize = [
"serde",
"smol_str/serde",
"bevy_ecs/serialize",
"bevy_input/serialize",
]

# 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_input/std",
"bevy_math/std",
"bevy_reflect?/std",
"serde?/std",
"raw-window-handle/std",
]

## Uses the `libm` maths library instead of the one provided in `std` and `core`.
libm = ["bevy_math/libm"]

[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.15.0-dev" }
bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev" }
bevy_input = { path = "../bevy_input", version = "0.15.0-dev" }
bevy_math = { path = "../bevy_math", version = "0.15.0-dev" }
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", features = [
bevy_app = { path = "../bevy_app", version = "0.15.0-dev", default-features = false }
bevy_ecs = { path = "../bevy_ecs", version = "0.15.0-dev", default-features = false }
bevy_input = { path = "../bevy_input", version = "0.15.0-dev", default-features = false }
bevy_math = { path = "../bevy_math", version = "0.15.0-dev", default-features = false }
bevy_reflect = { path = "../bevy_reflect", version = "0.15.0-dev", default-features = false, features = [
"glam",
"smol_str",
] }
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev" }
], optional = true }
bevy_utils = { path = "../bevy_utils", version = "0.15.0-dev", default-features = false }

# other
serde = { version = "1.0", features = ["derive"], optional = true }
raw-window-handle = "0.6"
smol_str = "0.2"
serde = { version = "1.0", features = [
"alloc",
"derive",
], default-features = false, optional = true }
raw-window-handle = { version = "0.6", features = [
"alloc",
], default-features = false }
smol_str = { version = "0.2", default-features = false }
log = { version = "0.4", default-features = false }
spin = { version = "0.9.8", default-features = false, features = [
"spin_mutex",
] }

[target.'cfg(target_os = "android")'.dependencies]
android-activity = "0.6"
Expand Down
Loading

0 comments on commit 10e113d

Please sign in to comment.