Skip to content

Commit

Permalink
Make dynamic_linking a no-op on wasm targets (#12672)
Browse files Browse the repository at this point in the history
# 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>
  • Loading branch information
james7132 and BD103 authored Apr 24, 2024
1 parent f1d1491 commit 538d699
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 538d699

Please sign in to comment.