Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change bevy_internal to be a 'thinner facade' #2851

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,7 @@ impl App {
/// ## Example
/// ```
/// # use bevy_app::{prelude::*, PluginGroupBuilder};
/// #
/// # // Dummy created to avoid using bevy_internal, which pulls in to many dependencies.
/// # struct MinimalPlugins;
/// # impl PluginGroup for MinimalPlugins {
/// # fn build(&mut self, group: &mut PluginGroupBuilder){;}
/// # }
/// #
/// # use bevy_app::NoopPluginGroup as MinimalPlugins;
/// App::new()
/// .add_plugins(MinimalPlugins);
/// ```
Expand All @@ -779,22 +773,18 @@ impl App {
/// ## Example
/// ```
/// # use bevy_app::{prelude::*, PluginGroupBuilder};
/// #
/// # // Dummies created to avoid using bevy_internal which pulls in to many dependencies.
/// # struct DefaultPlugins;
/// # impl PluginGroup for DefaultPlugins {
/// # fn build(&mut self, group: &mut PluginGroupBuilder){
/// # group.add(bevy_log::LogPlugin::default());
/// # }
/// # }
/// #
/// # use bevy_app::NoopPluginGroup as DefaultPlugins;
///
/// # struct MyOwnPlugin;
/// # impl Plugin for MyOwnPlugin {
/// # fn build(&self, app: &mut App){;}
/// # fn build(&self, app: &mut App){}
/// # }
/// #
/// App::new()
/// .add_plugins_with(DefaultPlugins, |group| {
/// # // This is hidden since it would be included in DefaultPlugins if we used
/// # // the default version
/// # group.add(bevy_log::LogPlugin::default());
/// group.add_before::<bevy_log::LogPlugin, _>(MyOwnPlugin)
/// });
/// ```
Expand Down
15 changes: 15 additions & 0 deletions crates/bevy_app/src/plugin_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,18 @@ impl PluginGroupBuilder {
}
}
}

/// A plugin group which doesn't do anything. Useful for examples:
DJMcNab marked this conversation as resolved.
Show resolved Hide resolved
/// ```rust
/// # use bevy_app::prelude::*;
/// use bevy_app::NoopPluginGroup as MinimalPlugins;
///
/// fn main(){
/// App::new().add_plugins(MinimalPlugins).run();
/// }
/// ```
pub struct NoopPluginGroup;

impl PluginGroup for NoopPluginGroup {
fn build(&mut self, _: &mut PluginGroupBuilder) {}
}
184 changes: 56 additions & 128 deletions crates/bevy_internal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,143 +1,71 @@
/// `use bevy::prelude::*;` to import common components, bundles, and plugins.
pub mod prelude;

mod default_plugins;
#[doc(hidden)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does #![doc(hidden)] at the top of the file work? And should it even be hidden at all if most users likely won't look at the docs of this crate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, maybe it not being hidden would be fine? The #![doc(hidden)] at the top of the file would also hide MinimalPlugins and DefaultPlugins

pub use default_plugins::*;

pub mod app {
//! Build bevy apps, create plugins, and read events.
pub use bevy_app::*;
}

pub mod asset {
//! Load and store assets and resources for Apps.
pub use bevy_asset::*;
}

pub mod core {
//! Contains core plugins and utilities for time.
pub use bevy_core::*;
}

pub mod diagnostic {
//! Useful diagnostic plugins and types for bevy apps.
pub use bevy_diagnostic::*;
}

pub mod ecs {
//! Bevy's entity-component-system.
pub use bevy_ecs::*;
}

pub mod input {
//! Resources and events for inputs, e.g. mouse/keyboard, touch, gamepads, etc.
pub use bevy_input::*;
}

pub mod log {
//! Logging capabilities
pub use bevy_log::*;
}

pub mod math {
//! Math types (Vec3, Mat4, Quat, etc) and helpers.
pub use bevy_math::*;
}

pub mod reflect {
// TODO: remove these renames once TypeRegistryArc is no longer required
//! Type reflection used for dynamically interacting with rust types.
pub use bevy_reflect::{
TypeRegistry as TypeRegistryInternal, TypeRegistryArc as TypeRegistry, *,
};
}

pub mod scene {
//! Save/load collections of entities and components to/from file.
pub use bevy_scene::*;
}

pub mod tasks {
//! Pools for async, IO, and compute tasks.
pub use bevy_tasks::*;
}

pub mod transform {
//! Local and global transforms (e.g. translation, scale, rotation).
pub use bevy_transform::*;
}

pub mod utils {
pub use bevy_utils::*;
}

pub mod window {
//! Configuration, creation, and management of one or more windows.
pub use bevy_window::*;
}

#[doc(hidden)]
pub use bevy_app;
#[doc(hidden)]
pub use bevy_asset;
#[cfg(feature = "bevy_audio")]
pub mod audio {
//! Provides types and plugins for audio playback.
pub use bevy_audio::*;
}

#[doc(hidden)]
pub use bevy_audio;
#[doc(hidden)]
pub use bevy_core;
#[doc(hidden)]
pub use bevy_derive;
#[doc(hidden)]
pub use bevy_diagnostic;
#[cfg(feature = "bevy_dynamic_plugin")]
#[doc(hidden)]
pub use bevy_dynamic_plugin;
#[doc(hidden)]
pub use bevy_ecs;
#[cfg(feature = "bevy_gilrs")]
pub mod gilrs {
pub use bevy_gilrs::*;
}

#[doc(hidden)]
pub use bevy_gilrs;
#[cfg(feature = "bevy_gltf")]
pub mod gltf {
//! Support for GLTF file loading.
pub use bevy_gltf::*;
}

#[doc(hidden)]
pub use bevy_gltf;
#[doc(hidden)]
pub use bevy_input;
#[doc(hidden)]
pub use bevy_log;
#[doc(hidden)]
pub use bevy_math;
#[cfg(feature = "bevy_pbr")]
pub mod pbr {
//! Physically based rendering.
pub use bevy_pbr::*;
}

#[doc(hidden)]
pub use bevy_pbr;
#[doc(hidden)]
pub use bevy_reflect;
#[cfg(feature = "bevy_render")]
pub mod render {
//! Cameras, meshes, textures, shaders, and pipelines.
pub use bevy_render::*;
}

#[doc(hidden)]
pub use bevy_render;
#[doc(hidden)]
pub use bevy_scene;
#[cfg(feature = "bevy_sprite")]
pub mod sprite {
//! Items for sprites, rects, texture atlases, etc.
pub use bevy_sprite::*;
}

#[doc(hidden)]
pub use bevy_sprite;
#[doc(hidden)]
pub use bevy_tasks;
#[cfg(feature = "bevy_text")]
pub mod text {
//! Text drawing, styling, and font assets.
pub use bevy_text::*;
}

#[doc(hidden)]
pub use bevy_text;
#[doc(hidden)]
pub use bevy_transform;
#[cfg(feature = "bevy_ui")]
pub mod ui {
//! User interface components and widgets.
pub use bevy_ui::*;
}

#[cfg(feature = "bevy_winit")]
pub mod winit {
pub use bevy_winit::*;
}

#[doc(hidden)]
pub use bevy_ui;
#[doc(hidden)]
pub use bevy_utils;
#[cfg(feature = "bevy_wgpu")]
pub mod wgpu {
//! A render backend utilizing [wgpu](https://wgpu.rs/).
pub use bevy_wgpu::*;
}

#[cfg(feature = "bevy_dynamic_plugin")]
pub mod dynamic_plugin {
pub use bevy_dynamic_plugin::*;
}
#[doc(hidden)]
pub use bevy_wgpu;
#[doc(hidden)]
pub use bevy_window;
#[cfg(feature = "bevy_winit")]
#[doc(hidden)]
pub use bevy_winit;

#[cfg(target_os = "android")]
#[doc(hidden)]
pub use ndk_glue;
5 changes: 1 addition & 4 deletions crates/bevy_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["bevy"]
bevy_app = { path = "../bevy_app", version = "0.5.0" }
bevy_utils = { path = "../bevy_utils", version = "0.5.0" }

tracing-subscriber = {version = "0.2.22", features = ["registry"]}
tracing-subscriber = { version = "0.2.22", features = ["registry"] }
tracing-chrome = { version = "0.3.1", optional = true }
tracing-tracy = { version = "0.7.0", optional = true }

Expand All @@ -23,6 +23,3 @@ android_log-sys = "0.2.0"
[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1.6"
tracing-wasm = "0.2"

[dev-dependencies]
bevy_internal = { path = "../bevy_internal", version = "0.5.0" }
13 changes: 11 additions & 2 deletions crates/bevy_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use tracing_subscriber::{prelude::*, registry::Registry, EnvFilter};
///
/// You can configure this plugin using the resource [`LogSettings`].
/// ```no_run
/// # use bevy_internal::DefaultPlugins;
/// # use bevy_app::NoopPluginGroup as DefaultPlugins;
/// # use bevy_app::App;
/// # use bevy_log::LogSettings;
/// # use bevy_utils::tracing::Level;
Expand All @@ -49,7 +49,16 @@ use tracing_subscriber::{prelude::*, registry::Registry, EnvFilter};
/// If you want to setup your own tracing collector, you should disable this
/// plugin from `DefaultPlugins` with [`App::add_plugins_with`]:
/// ```no_run
/// # use bevy_internal::DefaultPlugins;
/// # // Dummies created to avoid using bevy_internal which pulls in to many dependencies.
DJMcNab marked this conversation as resolved.
Show resolved Hide resolved
/// # // Note that we can't use NoopPluginGroup here, since we need to add LogPlugin, and
/// # // keep the group on the same line
/// # use bevy_app::{PluginGroup, PluginGroupBuilder};
/// # struct DefaultPlugins;
/// # impl PluginGroup for DefaultPlugins {
/// # fn build(&mut self, group: &mut PluginGroupBuilder){
/// # group.add(bevy_log::LogPlugin::default());
/// # }
/// # }
/// # use bevy_app::App;
/// # use bevy_log::LogPlugin;
/// fn main() {
Expand Down
17 changes: 10 additions & 7 deletions crates/bevy_macro_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ impl Default for BevyManifest {
impl BevyManifest {
pub fn get_path(&self, name: &str) -> syn::Path {
const BEVY: &str = "bevy";
const BEVY_INTERNAL: &str = "bevy_internal";

let is_bevy = self
.manifest
.package
.as_ref()
.map(|it| it.name == BEVY)
.unwrap_or(false);

let find_in_deps = |deps: &DepsSet| -> Option<syn::Path> {
let package = if let Some(dep) = deps.get(BEVY) {
dep.package().unwrap_or(BEVY)
} else if let Some(dep) = deps.get(BEVY_INTERNAL) {
dep.package().unwrap_or(BEVY_INTERNAL)
let package = if is_bevy {
BEVY
} else {
return None;
deps.get(BEVY)?.package().unwrap_or(BEVY)
};

let mut path = get_path(package);
Expand All @@ -42,7 +46,6 @@ impl BevyManifest {
}
Some(path)
};

let deps = self.manifest.dependencies.as_ref();
let deps_dev = self.manifest.dev_dependencies.as_ref();

Expand Down
Loading