Skip to content

Commit a362c27

Browse files
authored
Fix crates not building individually (#12948)
# Objective - `cargo check --workspace` appears to merge features and dependencies together, so it does not catch some issues where dependencies are not properly feature-gated. - The issues **are** caught, though, by running `cd $crate && cargo check`. ## Solution - Manually check each crate for issues. ```shell # Script used for i in crates/bevy_* do pushd $i cargo check popd done ``` - `bevy_color` had an issue where it used `#[derive(Pod, Zeroable)]` without using `bytemuck`'s `derive` feature. - The `FpsOverlayPlugin` in `bevy_dev_tools` uses `bevy_ui`'s `bevy_text` integration without properly enabling `bevy_text` as a feature. - `bevy_gizmos`'s `light` module was not properly feature-gated behind `bevy_pbr`. - ~~Lights appear to only be implemented in `bevy_pbr` and not `bevy_sprite`, so I think this is the right call. Can I get a confirmation by a gizmos person?~~ Confirmed :) - `bevy_gltf` imported `SmallVec`, but only used it if `bevy_animation` was enabled. - There was another issue, but it was more challenging to solve than the `smallvec` one. Run `cargo check -p bevy_gltf` and it will raise an issue about `animation_roots`. <details> <summary><code>bevy_gltf</code> errors</summary> ```shell error[E0425]: cannot find value `animation_roots` in this scope --> crates/bevy_gltf/src/loader.rs:608:26 | 608 | &animation_roots, | ^^^^^^^^^^^^^^^ not found in this scope warning: variable does not need to be mutable --> crates/bevy_gltf/src/loader.rs:1015:5 | 1015 | mut animation_context: Option<AnimationContext>, | ----^^^^^^^^^^^^^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default For more information about this error, try `rustc --explain E0425`. warning: `bevy_gltf` (lib) generated 1 warning error: could not compile `bevy_gltf` (lib) due to 1 previous error; 1 warning emitted ``` </details> --- ## Changelog - Fixed `bevy_color`, `bevy_dev_tools`, and `bevy_gizmos` so they can now compile by themselves.
1 parent 380b35c commit a362c27

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

crates/bevy_color/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ bevy_math = { path = "../bevy_math", version = "0.14.0-dev" }
1313
bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev", features = [
1414
"bevy",
1515
] }
16-
bytemuck = "1"
16+
bytemuck = { version = "1", features = ["derive"] }
1717
serde = { version = "1.0", features = ["derive"], optional = true }
1818
thiserror = "1.0"
1919
wgpu-types = { version = "0.19", default-features = false, optional = true }

crates/bevy_dev_tools/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ bevy_reflect = { path = "../bevy_reflect", version = "0.14.0-dev" }
3030
bevy_render = { path = "../bevy_render", version = "0.14.0-dev" }
3131
bevy_time = { path = "../bevy_time", version = "0.14.0-dev" }
3232
bevy_transform = { path = "../bevy_transform", version = "0.14.0-dev" }
33-
bevy_ui = { path = "../bevy_ui", version = "0.14.0-dev" }
33+
bevy_ui = { path = "../bevy_ui", version = "0.14.0-dev", features = [
34+
"bevy_text",
35+
] }
3436
bevy_utils = { path = "../bevy_utils", version = "0.14.0-dev" }
3537
bevy_window = { path = "../bevy_window", version = "0.14.0-dev" }
3638
bevy_text = { path = "../bevy_text", version = "0.14.0-dev" }

crates/bevy_gizmos/src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ pub mod circles;
3838
pub mod config;
3939
pub mod gizmos;
4040
pub mod grid;
41-
pub mod light;
4241
pub mod primitives;
4342

43+
#[cfg(feature = "bevy_pbr")]
44+
pub mod light;
45+
4446
#[cfg(feature = "bevy_sprite")]
4547
mod pipeline_2d;
4648
#[cfg(feature = "bevy_pbr")]
@@ -56,10 +58,12 @@ pub mod prelude {
5658
GizmoLineJoint, GizmoLineStyle,
5759
},
5860
gizmos::Gizmos,
59-
light::{LightGizmoColor, LightGizmoConfigGroup, ShowLightGizmo},
6061
primitives::{dim2::GizmoPrimitive2d, dim3::GizmoPrimitive3d},
6162
AppGizmoBuilder,
6263
};
64+
65+
#[cfg(feature = "bevy_pbr")]
66+
pub use crate::light::{LightGizmoColor, LightGizmoConfigGroup, ShowLightGizmo};
6367
}
6468

6569
use aabb::AabbGizmoPlugin;
@@ -96,6 +100,7 @@ use config::{
96100
GizmoMeshConfig,
97101
};
98102
use gizmos::GizmoStorage;
103+
#[cfg(feature = "bevy_pbr")]
99104
use light::LightGizmoPlugin;
100105
use std::{any::TypeId, mem};
101106

@@ -131,8 +136,10 @@ impl Plugin for GizmoPlugin {
131136
.init_resource::<LineGizmoHandles>()
132137
// We insert the Resource GizmoConfigStore into the world implicitly here if it does not exist.
133138
.init_gizmo_group::<DefaultGizmoConfigGroup>()
134-
.add_plugins(AabbGizmoPlugin)
135-
.add_plugins(LightGizmoPlugin);
139+
.add_plugins(AabbGizmoPlugin);
140+
141+
#[cfg(feature = "bevy_pbr")]
142+
app.add_plugins(LightGizmoPlugin);
136143

137144
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
138145
return;

crates/bevy_gltf/src/loader.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::{vertex_attributes::convert_attribute, Gltf, GltfExtras, GltfNode};
2+
#[cfg(feature = "bevy_animation")]
23
use bevy_animation::{AnimationTarget, AnimationTargetId};
34
use bevy_asset::{
45
io::Reader, AssetLoadError, AssetLoader, AsyncReadExt, Handle, LoadContext, ReadAssetBytesError,
@@ -44,7 +45,8 @@ use gltf::{
4445
Material, Node, Primitive, Semantic,
4546
};
4647
use serde::{Deserialize, Serialize};
47-
use smallvec::{smallvec, SmallVec};
48+
#[cfg(feature = "bevy_animation")]
49+
use smallvec::SmallVec;
4850
use std::io::Error;
4951
use std::{
5052
collections::VecDeque,
@@ -1032,7 +1034,7 @@ fn load_node(
10321034
// This is an animation root. Make a new animation context.
10331035
animation_context = Some(AnimationContext {
10341036
root: node.id(),
1035-
path: smallvec![],
1037+
path: SmallVec::new(),
10361038
});
10371039
}
10381040

0 commit comments

Comments
 (0)