Make dynamic_linking a no-op on wasm targets (#12672)

# Objective
Resolve #10054.

## Solution
Make dynamic linking a no-op by omitting it from the dependency tree on
wasm targets.

To test this, try `cargo build --lib --target wasm32-unknown-unknown
--features bevy/dynamic_linking` with and without this PR.

Might need to update the book on the website to explain this when this
makes it into a release.

Co-Authored By: @daxpedda

---------

Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com>
This commit is contained in:
James Liu 2024-04-23 21:49:38 -07:00 committed by GitHub
parent f1d1491126
commit 538d699994
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View file

@ -330,9 +330,12 @@ meshlet_processor = ["bevy_internal/meshlet_processor"]
ios_simulator = ["bevy_internal/ios_simulator"]
[dependencies]
bevy_dylib = { path = "crates/bevy_dylib", version = "0.14.0-dev", default-features = false, optional = true }
bevy_internal = { path = "crates/bevy_internal", version = "0.14.0-dev", default-features = false }
# WASM does not support dynamic linking.
[target.'cfg(not(target_family = "wasm"))'.dependencies]
bevy_dylib = { path = "crates/bevy_dylib", version = "0.14.0-dev", default-features = false, optional = true }
[dev-dependencies]
rand = "0.8.0"
rand_chacha = "0.3.1"

View file

@ -48,6 +48,7 @@
pub use bevy_internal::*;
#[cfg(feature = "dynamic_linking")]
// WASM does not support dynamic linking.
#[cfg(all(feature = "dynamic_linking", not(target_family = "wasm")))]
#[allow(unused_imports)]
use bevy_dylib;