From a7219e0b70d0d745da7b9cb238436f9d60261112 Mon Sep 17 00:00:00 2001 From: Tomasz Sterna Date: Tue, 15 Sep 2020 21:20:20 +0200 Subject: [PATCH] Make "render" feature optional (#485) --- Cargo.toml | 15 ++++++++------- src/add_default_plugins.rs | 10 ++++++++++ src/lib.rs | 20 +++++++++++++++----- src/prelude.rs | 20 +++++++++++++++++--- 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 522c50561e380..de6d4d9113b97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ default = [ "bevy_gltf", "bevy_wgpu", "bevy_winit", + "render", "dynamic_plugins", "png", "hdr", @@ -34,7 +35,8 @@ dynamic_plugins = [ "bevy_app/dynamic_plugins", "bevy_type_registry/dynamic_plugins", ] - +# Rendering support +render = ["bevy_pbr", "bevy_render", "bevy_sprite", "bevy_text", "bevy_ui"] # Image format support for texture loading (PNG and HDR are enabled by default) png = ["bevy_render/png"] hdr = ["bevy_render/hdr"] @@ -65,21 +67,20 @@ bevy_diagnostic = { path = "crates/bevy_diagnostic", version = "0.1" } bevy_ecs = { path = "crates/bevy_ecs", version = "0.1" } bevy_input = { path = "crates/bevy_input", version = "0.1" } bevy_math = { path = "crates/bevy_math", version = "0.1" } -bevy_pbr = { path = "crates/bevy_pbr", version = "0.1" } bevy_property = { path = "crates/bevy_property", version = "0.1" } -bevy_render = { path = "crates/bevy_render", version = "0.1" } bevy_scene = { path = "crates/bevy_scene", version = "0.1" } -bevy_sprite = { path = "crates/bevy_sprite", version = "0.1" } bevy_transform = { path = "crates/bevy_transform", version = "0.1" } -bevy_text = { path = "crates/bevy_text", version = "0.1" } -bevy_ui = { path = "crates/bevy_ui", version = "0.1" } bevy_utils = { path = "crates/bevy_utils", version = "0.1" } bevy_window = { path = "crates/bevy_window", version = "0.1" } bevy_tasks = { path = "crates/bevy_tasks", version = "0.1" } - # bevy (optional) bevy_audio = { path = "crates/bevy_audio", optional = true, version = "0.1" } bevy_gltf = { path = "crates/bevy_gltf", optional = true, version = "0.1" } +bevy_pbr = { path = "crates/bevy_pbr", optional = true, version = "0.1" } +bevy_render = { path = "crates/bevy_render", optional = true, version = "0.1" } +bevy_sprite = { path = "crates/bevy_sprite", optional = true, version = "0.1" } +bevy_text = { path = "crates/bevy_text", optional = true, version = "0.1" } +bevy_ui = { path = "crates/bevy_ui", optional = true, version = "0.1" } bevy_wgpu = { path = "crates/bevy_wgpu", optional = true, version = "0.1" } bevy_winit = { path = "crates/bevy_winit", optional = true, version = "0.1" } diff --git a/src/add_default_plugins.rs b/src/add_default_plugins.rs index f44ccfcf7cdfb..452494474dd2d 100644 --- a/src/add_default_plugins.rs +++ b/src/add_default_plugins.rs @@ -14,10 +14,20 @@ impl AddDefaultPlugins for AppBuilder { self.add_plugin(bevy_window::WindowPlugin::default()); self.add_plugin(bevy_asset::AssetPlugin::default()); self.add_plugin(bevy_scene::ScenePlugin::default()); + + #[cfg(feature = "bevy_render")] self.add_plugin(bevy_render::RenderPlugin::default()); + + #[cfg(feature = "bevy_sprite")] self.add_plugin(bevy_sprite::SpritePlugin::default()); + + #[cfg(feature = "bevy_pbr")] self.add_plugin(bevy_pbr::PbrPlugin::default()); + + #[cfg(feature = "bevy_ui")] self.add_plugin(bevy_ui::UiPlugin::default()); + + #[cfg(feature = "bevy_text")] self.add_plugin(bevy_text::TextPlugin::default()); #[cfg(feature = "bevy_audio")] diff --git a/src/lib.rs b/src/lib.rs index b0a00b83fabf3..5b8c092afb156 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -48,16 +48,11 @@ pub use bevy_diagnostic as diagnostic; pub use bevy_ecs as ecs; pub use bevy_input as input; pub use bevy_math as math; -pub use bevy_pbr as pbr; pub use bevy_property as property; -pub use bevy_render as render; pub use bevy_scene as scene; -pub use bevy_sprite as sprite; pub use bevy_tasks as tasks; -pub use bevy_text as text; pub use bevy_transform as transform; pub use bevy_type_registry as type_registry; -pub use bevy_ui as ui; pub use bevy_window as window; #[cfg(feature = "bevy_audio")] @@ -66,6 +61,21 @@ pub use bevy_audio as audio; #[cfg(feature = "bevy_gltf")] pub use bevy_gltf as gltf; +#[cfg(feature = "bevy_pbr")] +pub use bevy_pbr as pbr; + +#[cfg(feature = "bevy_render")] +pub use bevy_render as render; + +#[cfg(feature = "bevy_sprite")] +pub use bevy_sprite as sprite; + +#[cfg(feature = "bevy_text")] +pub use bevy_text as text; + +#[cfg(feature = "bevy_ui")] +pub use bevy_ui as ui; + #[cfg(feature = "bevy_winit")] pub use bevy_winit as winit; diff --git a/src/prelude.rs b/src/prelude.rs index 6996f1d07b70d..76a63b94a3c0e 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,9 +1,23 @@ pub use crate::{ app::prelude::*, asset::prelude::*, core::prelude::*, ecs::prelude::*, input::prelude::*, - math::prelude::*, pbr::prelude::*, property::prelude::*, render::prelude::*, scene::prelude::*, - sprite::prelude::*, text::prelude::*, transform::prelude::*, type_registry::RegisterType, - ui::prelude::*, window::prelude::*, AddDefaultPlugins, + math::prelude::*, property::prelude::*, scene::prelude::*, transform::prelude::*, + type_registry::RegisterType, window::prelude::*, AddDefaultPlugins, }; #[cfg(feature = "bevy_audio")] pub use crate::audio::prelude::*; + +#[cfg(feature = "bevy_pbr")] +pub use crate::pbr::prelude::*; + +#[cfg(feature = "bevy_render")] +pub use crate::render::prelude::*; + +#[cfg(feature = "bevy_sprite")] +pub use crate::sprite::prelude::*; + +#[cfg(feature = "bevy_text")] +pub use crate::text::prelude::*; + +#[cfg(feature = "bevy_ui")] +pub use crate::ui::prelude::*;