Skip to content

Commit cb227b1

Browse files
authored
make optional crates for mesh, camera, and light (#19997)
# Objective - nice bevy::camera bevy::mesh bevy::light imports - skip bevy_light in 2d ## Solution - add optional crates to internal - make light only included when building pbr ## Testing - 3d_scene
1 parent 1fb5a62 commit cb227b1

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

crates/bevy_internal/Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ bevy_ui = ["dep:bevy_ui", "bevy_image"]
199199
bevy_ui_render = ["dep:bevy_ui_render"]
200200
bevy_image = ["dep:bevy_image"]
201201

202+
bevy_mesh = ["dep:bevy_mesh", "bevy_image"]
203+
bevy_camera = ["dep:bevy_camera", "bevy_mesh"]
204+
bevy_light = ["dep:bevy_light", "bevy_camera"]
205+
202206
# Used to disable code that is unsupported when Bevy is dynamically linked
203207
dynamic_linking = ["bevy_diagnostic/dynamic_linking"]
204208

@@ -215,7 +219,7 @@ bevy_render = [
215219
"dep:bevy_render",
216220
"bevy_scene?/bevy_render",
217221
"bevy_gizmos?/bevy_render",
218-
"bevy_image",
222+
"bevy_camera",
219223
"bevy_color/wgpu-types",
220224
"bevy_color/encase",
221225
]
@@ -428,6 +432,9 @@ bevy_gizmos = { path = "../bevy_gizmos", optional = true, version = "0.17.0-dev"
428432
bevy_gltf = { path = "../bevy_gltf", optional = true, version = "0.17.0-dev" }
429433
bevy_feathers = { path = "../bevy_feathers", optional = true, version = "0.17.0-dev" }
430434
bevy_image = { path = "../bevy_image", optional = true, version = "0.17.0-dev" }
435+
bevy_mesh = { path = "../bevy_mesh", optional = true, version = "0.17.0-dev" }
436+
bevy_camera = { path = "../bevy_camera", optional = true, version = "0.17.0-dev" }
437+
bevy_light = { path = "../bevy_light", optional = true, version = "0.17.0-dev" }
431438
bevy_input_focus = { path = "../bevy_input_focus", optional = true, version = "0.17.0-dev", default-features = false, features = [
432439
"bevy_reflect",
433440
] }

crates/bevy_internal/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub use bevy_app as app;
2525
pub use bevy_asset as asset;
2626
#[cfg(feature = "bevy_audio")]
2727
pub use bevy_audio as audio;
28+
#[cfg(feature = "bevy_camera")]
29+
pub use bevy_camera as camera;
2830
#[cfg(feature = "bevy_color")]
2931
pub use bevy_color as color;
3032
#[cfg(feature = "bevy_core_pipeline")]
@@ -48,9 +50,13 @@ pub use bevy_image as image;
4850
pub use bevy_input as input;
4951
#[cfg(feature = "bevy_input_focus")]
5052
pub use bevy_input_focus as input_focus;
53+
#[cfg(feature = "bevy_light")]
54+
pub use bevy_light as light;
5155
#[cfg(feature = "bevy_log")]
5256
pub use bevy_log as log;
5357
pub use bevy_math as math;
58+
#[cfg(feature = "bevy_mesh")]
59+
pub use bevy_mesh as mesh;
5460
#[cfg(feature = "bevy_pbr")]
5561
pub use bevy_pbr as pbr;
5662
#[cfg(feature = "bevy_picking")]

crates/bevy_pbr/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ bevy_light = { path = "../bevy_light", version = "0.17.0-dev" }
4444
bevy_image = { path = "../bevy_image", version = "0.17.0-dev" }
4545
bevy_math = { path = "../bevy_math", version = "0.17.0-dev" }
4646
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev" }
47-
bevy_render = { path = "../bevy_render", version = "0.17.0-dev" }
47+
bevy_render = { path = "../bevy_render", features = [
48+
"bevy_light",
49+
], version = "0.17.0-dev" }
4850
bevy_camera = { path = "../bevy_camera", version = "0.17.0-dev" }
4951
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", optional = true }
5052
bevy_transform = { path = "../bevy_transform", version = "0.17.0-dev" }

crates/bevy_render/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev" }
7777
bevy_image = { path = "../bevy_image", version = "0.17.0-dev" }
7878
bevy_mesh = { path = "../bevy_mesh", version = "0.17.0-dev" }
7979
bevy_camera = { path = "../bevy_camera", version = "0.17.0-dev" }
80-
bevy_light = { path = "../bevy_light", version = "0.17.0-dev" }
80+
bevy_light = { path = "../bevy_light", optional = true, version = "0.17.0-dev" }
8181
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false, features = [
8282
"std",
8383
"serialize",

crates/bevy_render/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pub mod sync_world;
5050
pub mod texture;
5151
pub mod view;
5252
pub use bevy_camera::primitives;
53+
#[cfg(feature = "bevy_light")]
5354
mod extract_impls;
5455

5556
/// The render prelude.

0 commit comments

Comments
 (0)