Skip to content

Commit

Permalink
Fix dynamic linking (on linux) (bevyengine#7333)
Browse files Browse the repository at this point in the history
# Problemo

Some code in bevyengine#5911 and bevyengine#5454 does not compile with dynamic linking enabled.
The code is behind a feature gate to prevent dynamically linked builds from breaking, but it's not quite set up correctly.

## Solution

Forward the `dynamic` feature flag to the `bevy_diagnostic` crate and gate the code behind it.


Co-authored-by: devil-ira <justthecooldude@gmail.com>
  • Loading branch information
2 people authored and ItsDoot committed Feb 1, 2023
1 parent b32ff45 commit 19a56b2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ default = [
]

# Force dynamic linking, which improves iterative compile times
dynamic = ["bevy_dylib"]
dynamic = ["bevy_dylib", "bevy_internal/dynamic"]

# Optional bevy crates
bevy_animation = ["bevy_internal/bevy_animation"]
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_diagnostic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ repository = "https://github.com/bevyengine/bevy"
license = "MIT OR Apache-2.0"
keywords = ["bevy"]

[features]
# Disables diagnostics that are unsupported when Bevy is dynamically linked
dynamic = []

[dependencies]
# bevy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl SystemInformationDiagnosticsPlugin {
target_os = "android",
target_os = "macos"
),
not(feature = "bevy_dynamic_plugin")
not(feature = "dynamic")
))]
pub mod internal {
use bevy_ecs::{prelude::ResMut, system::Local};
Expand Down Expand Up @@ -142,7 +142,7 @@ pub mod internal {
target_os = "android",
target_os = "macos"
),
not(feature = "bevy_dynamic_plugin")
not(feature = "dynamic")
)))]
pub mod internal {
pub(crate) fn setup_system() {
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ bevy_ci_testing = ["bevy_app/bevy_ci_testing", "bevy_render/ci_limits"]
# Enable animation support, and glTF animation loading
animation = ["bevy_animation", "bevy_gltf?/bevy_animation"]

# Used to disable code that is unsupported when Bevy is dynamically linked
dynamic = ["bevy_diagnostic/dynamic"]

[dependencies]
# bevy
bevy_app = { path = "../bevy_app", version = "0.9.0" }
Expand Down

0 comments on commit 19a56b2

Please sign in to comment.