Skip to content

Commit

Permalink
Remove bevy_dynamic_plugin
Browse files Browse the repository at this point in the history
It is hard to use the current dynamic plugin system. It doesn't allow
hot code swapping as several OSes don't allow unloading dylibs. It
requires bevy itself to be used as dylib and it requires all other
crates shared between the main game and the plugin to be dylibs.

In the future we may get better plugin support. Whether based on wasm,
or something else. Until then, remove the current dynamic plugin to
avoid making any promises about the current ability to use dynamic
plugins.

If anyone wants to keep using the current dynamic plugin support despite
all it's issues, they can copy the less than 100 lines of code this PR
deletes.
  • Loading branch information
bjorn3 committed Feb 8, 2022
1 parent 56b0e88 commit 672ad27
Show file tree
Hide file tree
Showing 13 changed files with 3 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,13 @@ jobs:
toolchain: stable
- name: Build bevy
run: |
cargo build --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome"
cargo build --no-default-features --features "bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome"
- name: Run examples
run: |
for example in .github/example-run/*.ron; do
example_name=`basename $example .ron`
echo "running $example_name - "`date`
time CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_dynamic_plugin,bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome"
time CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --no-default-features --features "bevy_gilrs,bevy_gltf,bevy_winit,render,png,hdr,x11,bevy_ci_testing,trace,trace_chrome"
sleep 10
done
zip traces.zip trace*.json
Expand Down
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ render = [
# Optional bevy crates
bevy_audio = ["bevy_internal/bevy_audio"]
bevy_core_pipeline = ["bevy_internal/bevy_core_pipeline"]
bevy_dynamic_plugin = ["bevy_internal/bevy_dynamic_plugin"]
bevy_gilrs = ["bevy_internal/bevy_gilrs"]
bevy_gltf = ["bevy_internal/bevy_gltf"]
bevy_pbr = ["bevy_internal/bevy_pbr"]
Expand Down
5 changes: 1 addition & 4 deletions crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ mod schedule_runner;
mod ci_testing;

pub use app::*;
pub use bevy_derive::DynamicPlugin;
pub use bevy_ecs::event::*;
pub use plugin::*;
pub use plugin_group::*;
Expand All @@ -20,9 +19,7 @@ pub use schedule_runner::*;
#[allow(missing_docs)]
pub mod prelude {
#[doc(hidden)]
pub use crate::{
app::App, CoreStage, DynamicPlugin, Plugin, PluginGroup, StartupSchedule, StartupStage,
};
pub use crate::{app::App, CoreStage, Plugin, PluginGroup, StartupSchedule, StartupStage};
}

use bevy_ecs::schedule::StageLabel;
Expand Down
5 changes: 0 additions & 5 deletions crates/bevy_app/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ pub trait Plugin: Any + Send + Sync {
std::any::type_name::<Self>()
}
}

/// Type representing an unsafe function that returns a mutable pointer to a [`Plugin`].
/// Used for dynamically loading plugins. See
/// `bevy_dynamic_plugin/src/loader.rs#dynamically_load_plugin`
pub type CreatePlugin = unsafe fn() -> *mut dyn Plugin;
18 changes: 0 additions & 18 deletions crates/bevy_derive/src/app_plugin.rs

This file was deleted.

7 changes: 0 additions & 7 deletions crates/bevy_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
extern crate proc_macro;

mod app_plugin;
mod bevy_main;
mod enum_variant_meta;
mod modules;
Expand All @@ -9,12 +8,6 @@ use bevy_macro_utils::{derive_label, BevyManifest};
use proc_macro::TokenStream;
use quote::format_ident;

/// Generates a dynamic plugin entry point function for the given `Plugin` type.
#[proc_macro_derive(DynamicPlugin)]
pub fn derive_dynamic_plugin(input: TokenStream) -> TokenStream {
app_plugin::derive_dynamic_plugin(input)
}

#[proc_macro_attribute]
pub fn bevy_main(attr: TokenStream, item: TokenStream) -> TokenStream {
bevy_main::bevy_main(attr, item)
Expand Down
18 changes: 0 additions & 18 deletions crates/bevy_dynamic_plugin/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions crates/bevy_dynamic_plugin/src/lib.rs

This file was deleted.

34 changes: 0 additions & 34 deletions crates/bevy_dynamic_plugin/src/loader.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/bevy_internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ bevy_core_pipeline = { path = "../bevy_core_pipeline", optional = true, version
bevy_gltf = { path = "../bevy_gltf", optional = true, version = "0.6.0" }
bevy_pbr = { path = "../bevy_pbr", optional = true, version = "0.6.0" }
bevy_render = { path = "../bevy_render", optional = true, version = "0.6.0" }
bevy_dynamic_plugin = { path = "../bevy_dynamic_plugin", optional = true, version = "0.6.0" }
bevy_sprite = { path = "../bevy_sprite", optional = true, version = "0.6.0" }
bevy_text = { path = "../bevy_text", optional = true, version = "0.6.0" }
bevy_ui = { path = "../bevy_ui", optional = true, version = "0.6.0" }
Expand Down
6 changes: 0 additions & 6 deletions crates/bevy_internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,5 @@ pub mod winit {
pub use bevy_winit::*;
}

#[cfg(feature = "bevy_dynamic_plugin")]
pub mod dynamic_plugin {
//! Dynamic linking of plugins
pub use bevy_dynamic_plugin::*;
}

#[cfg(target_os = "android")]
pub use ndk_glue;
4 changes: 0 additions & 4 deletions crates/bevy_internal/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ pub use crate::text::prelude::*;
#[cfg(feature = "bevy_ui")]
pub use crate::ui::prelude::*;

#[doc(hidden)]
#[cfg(feature = "bevy_dynamic_plugin")]
pub use crate::dynamic_plugin::*;

#[doc(hidden)]
#[cfg(feature = "bevy_gilrs")]
pub use crate::gilrs::*;
1 change: 0 additions & 1 deletion tools/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crates=(
bevy_ecs
bevy_app
bevy_log
bevy_dynamic_plugin
bevy_reflect/bevy_reflect_derive
bevy_reflect
bevy_asset
Expand Down

0 comments on commit 672ad27

Please sign in to comment.