Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions crates/bevy_app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ std = [
"bevy_ecs/std",
"dep:ctrlc",
"downcast-rs/std",
"bevy_tasks/std",
"bevy_platform/std",
]

## `critical-section` provides the building blocks for synchronization primitives
## on all platforms, including `no_std`.
critical-section = [
"bevy_tasks/critical-section",
"bevy_ecs/critical-section",
"bevy_platform/critical-section",
"bevy_reflect?/critical-section",
Expand All @@ -64,7 +62,6 @@ critical-section = [
## Note this is currently only applicable on `wasm32` architectures.
web = [
"bevy_platform/web",
"bevy_tasks/web",
"bevy_reflect?/web",
"dep:wasm-bindgen",
"dep:web-sys",
Expand Down
3 changes: 0 additions & 3 deletions crates/bevy_asset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ uuid = { version = "1.13.1", default-features = false, features = ["js"] }
bevy_app = { path = "../bevy_app", version = "0.17.0-dev", default-features = false, features = [
"web",
] }
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", default-features = false, features = [
"web",
] }
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev", default-features = false, features = [
"web",
] }
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_diagnostic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ std = [
"bevy_app/std",
"bevy_platform/std",
"bevy_time/std",
"bevy_tasks/std",
]

## `critical-section` provides the building blocks for synchronization primitives
Expand All @@ -48,7 +47,6 @@ critical-section = [
"bevy_app/critical-section",
"bevy_platform/critical-section",
"bevy_time/critical-section",
"bevy_tasks/critical-section",
]

[dependencies]
Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ async_executor = ["std", "bevy_tasks/async_executor"]
## supported platforms.
std = [
"bevy_reflect?/std",
"bevy_tasks/std",
"bevy_utils/parallel",
"bevy_utils/std",
"bitflags/std",
Expand All @@ -78,7 +77,6 @@ std = [
## `critical-section` provides the building blocks for synchronization primitives
## on all platforms, including `no_std`.
critical-section = [
"bevy_tasks/critical-section",
"bevy_platform/critical-section",
"bevy_reflect?/critical-section",
]
Expand Down
9 changes: 1 addition & 8 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ std = [
"bevy_state?/std",
"bevy_time/std",
"bevy_transform/std",
"bevy_tasks/std",
"bevy_window?/std",
]

Expand All @@ -343,7 +342,6 @@ critical-section = [
"bevy_reflect/critical-section",
"bevy_state?/critical-section",
"bevy_time/critical-section",
"bevy_tasks/critical-section",
]

# Uses the `libm` maths library instead of the one provided in `std` and `core`.
Expand All @@ -367,12 +365,7 @@ async_executor = [

# Enables use of browser APIs.
# Note this is currently only applicable on `wasm32` architectures.
web = [
"bevy_app/web",
"bevy_platform/web",
"bevy_reflect/web",
"bevy_tasks/web",
]
web = ["bevy_app/web", "bevy_platform/web", "bevy_reflect/web"]

hotpatching = ["bevy_app/hotpatching", "bevy_ecs/hotpatching"]

Expand Down
17 changes: 16 additions & 1 deletion crates/bevy_platform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ std = [
"spin/std",
"foldhash/std",
"serde?/std",
"wasm-bindgen-futures?/std",
"futures-channel/std",
"wasm-bindgen?/std",
"js-sys?/std",
]

## Allows access to the `alloc` crate.
Expand All @@ -43,7 +47,14 @@ critical-section = ["dep:critical-section", "portable-atomic/critical-section"]

## Enables use of browser APIs.
## Note this is currently only applicable on `wasm32` architectures.
web = ["dep:web-time", "dep:getrandom"]
web = [
"std",
"dep:web-time",
"dep:getrandom",
"dep:wasm-bindgen-futures",
"dep:wasm-bindgen",
"dep:js-sys",
]

[dependencies]
critical-section = { version = "1.2.0", default-features = false, optional = true }
Expand All @@ -68,6 +79,10 @@ web-time = { version = "1.1", default-features = false, optional = true }
getrandom = { version = "0.2.0", default-features = false, optional = true, features = [
"js",
] }
wasm-bindgen-futures = { version = "0.4", default-features = false, optional = true }
futures-channel = { version = "0.3", default-features = false }
js-sys = { version = "0.3", default-features = false, optional = true }
wasm-bindgen = { version = "0.2", default-features = false, optional = true }

[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies]
portable-atomic = { version = "1", default-features = false, features = [
Expand Down
11 changes: 11 additions & 0 deletions crates/bevy_platform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,14 @@ pub mod prelude {
// * println
// * thread_local
}

/// Re-exports of crates that are useful across Bevy.
/// Not intended for external crates to use.
#[doc(hidden)]
pub mod exports {
crate::cfg::web! {
pub use js_sys;
pub use wasm_bindgen;
pub use wasm_bindgen_futures;
}
}
3 changes: 0 additions & 3 deletions crates/bevy_render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ wasm-bindgen = "0.2"
bevy_app = { path = "../bevy_app", version = "0.17.0-dev", default-features = false, features = [
"web",
] }
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", default-features = false, features = [
"web",
] }
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false, features = [
"web",
] }
Expand Down
50 changes: 19 additions & 31 deletions crates/bevy_tasks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,27 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
default = ["std", "async_executor"]
default = ["async_executor", "futures-lite"]

# Functionality

## Enables multi-threading support.
## Without this feature, all tasks will be run on a single thread.
# Enables multi-threading support.
# Without this feature, all tasks will be run on a single thread.
multi_threaded = [
"std",
"bevy_platform/std",
"dep:async-channel",
"dep:concurrent-queue",
"async_executor",
]

## Uses `async-executor` as a task execution backend.
## This backend is incompatible with `no_std` targets.
async_executor = ["std", "dep:async-executor"]

# Platform Compatibility
# Uses `async-executor` as a task execution backend.
# This backend is incompatible with `no_std` targets.
async_executor = ["bevy_platform/std", "dep:async-executor"]

## 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 = ["futures-lite/std", "async-task/std", "bevy_platform/std"]
# Provide an implementation of `block_on` from `futures-lite`.
futures-lite = ["bevy_platform/std", "futures-lite/std"]

## `critical-section` provides the building blocks for synchronization primitives
## on all platforms, including `no_std`.
critical-section = ["bevy_platform/critical-section"]

## Enables use of browser APIs.
## Note this is currently only applicable on `wasm32` architectures.
web = [
"bevy_platform/web",
"dep:wasm-bindgen-futures",
"dep:pin-project",
"dep:futures-channel",
]
# Use async-io's implementation of block_on instead of futures-lite's implementation.
# This is preferred if your application uses async-io.
async-io = ["bevy_platform/std", "dep:async-io"]

[dependencies]
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false, features = [
Expand All @@ -59,7 +44,6 @@ derive_more = { version = "2", default-features = false, features = [
"deref",
"deref_mut",
] }
cfg-if = "1.0.0"
async-executor = { version = "1.11", optional = true }
async-channel = { version = "2.3.0", optional = true }
async-io = { version = "2.0.0", optional = true }
Expand All @@ -70,9 +54,8 @@ crossbeam-queue = { version = "0.3", default-features = false, features = [
] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = { version = "0.4", optional = true }
pin-project = { version = "1", optional = true }
futures-channel = { version = "0.3", optional = true }
pin-project = { version = "1" }
futures-channel = { version = "0.3", default-features = false }

[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies]
async-task = { version = "4.4.0", default-features = false, features = [
Expand All @@ -85,6 +68,11 @@ atomic-waker = { version = "1", default-features = false, features = [
"portable-atomic",
] }

[dev-dependencies]
futures-lite = { version = "2.0.1", default-features = false, features = [
"std",
] }

[lints]
workspace = true

Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_tasks/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use core::{
};
use derive_more::{Deref, DerefMut};

cfg_if::cfg_if! {
if #[cfg(feature = "async_executor")] {
crate::cfg::async_executor! {
if {
type ExecutorInner<'a> = async_executor::Executor<'a>;
type LocalExecutorInner<'a> = async_executor::LocalExecutor<'a>;
} else {
Expand All @@ -24,8 +24,9 @@ cfg_if::cfg_if! {
}
}

#[cfg(all(feature = "multi_threaded", not(target_arch = "wasm32")))]
pub use async_task::FallibleTask;
crate::cfg::multi_threaded! {
pub use async_task::FallibleTask;
}

/// Wrapper around a multi-threading-aware async executor.
/// Spawning will generally require tasks to be `Send` and `Sync` to allow multiple
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_tasks/src/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn noop_raw_waker() -> RawWaker {
RawWaker::new(core::ptr::null(), &NOOP_WAKER_VTABLE)
}

fn noop_waker() -> Waker {
pub(crate) fn noop_waker() -> Waker {
// SAFETY: the `RawWakerVTable` is just a big noop and doesn't violate any of the rules in `RawWakerVTable`s documentation
// (which talks about retaining and releasing any "resources", of which there are none in this case)
unsafe { Waker::from_raw(noop_raw_waker()) }
Expand Down
Loading
Loading