Makes reflect an explicit flag#796
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes Copper’s runtime reflection support explicitly opt-in via a reflect Cargo feature, reducing the default dependency footprint (notably bevy_reflect) while keeping code that derives/uses Reflect compiling via a no-op fallback derive when reflection is disabled.
Changes:
- Introduce a
reflectfeature across core crates and propagate it through examples/components that rely on task introspection. - Make
bevy_reflectoptional and addcu29-reflect-deriveas a fallback no-op#[derive(Reflect)]when reflection is disabled. - Add compile-time gating/behavior changes around reflection helpers and debug introspection.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| examples/cu_reflect_demo/Cargo.toml | Enable reflect feature for demo dependencies that require reflection. |
| examples/cu_debug_session/Cargo.toml | Enable reflect to support debug/introspection example. |
| examples/cu_bridge_test/Cargo.toml | Add a reflect feature and gate a binary behind required-features. |
| core/cu29_runtime/tests/sim_bridge.rs | Remove direct bevy_reflect import in tests to align with optional reflection. |
| core/cu29_runtime/src/reflect.rs | Add reflect feature gating and provide non-reflect fallback traits/types and schema dump behavior. |
| core/cu29_runtime/src/payload.rs | Gate bevy_reflect import for optional reflection. |
| core/cu29_runtime/src/debug.rs | Return a clear error when task introspection is used without reflect. |
| core/cu29_runtime/Cargo.toml | Make bevy_reflect optional and add reflect feature; add cu29-reflect-derive dep. |
| core/cu29_reflect_derive/src/lib.rs | New no-op Reflect derive proc-macro for non-reflect builds. |
| core/cu29_reflect_derive/Cargo.toml | New proc-macro crate manifest for cu29-reflect-derive. |
| core/cu29_clock/src/lib.rs | Make Reflect derive conditional via cfg_attr(feature = "reflect", ...). |
| core/cu29_clock/Cargo.toml | Make bevy_reflect optional and add a reflect feature. |
| core/cu29/src/lib.rs | Export ReflectTypePath in the prelude. |
| core/cu29/Cargo.toml | Add top-level reflect feature that enables runtime + clock reflection. |
| components/tasks/cu_pid/src/lib.rs | Switch bounds to ReflectTypePath to avoid requiring reflection when disabled. |
| components/tasks/cu_pid/Cargo.toml | Add reflect feature forwarding to cu29/reflect and drop direct bevy_reflect dep. |
| Cargo.toml | Add the new core/cu29_reflect_derive workspace member and workspace dependency. |
Comments suppressed due to low confidence (1)
core/cu29_runtime/src/reflect.rs:99
dump_type_registry_schemacallsformat("{info:#?}")without invoking theformat!macro (missing!). This won’t compile when thereflectfeature is enabled; use theformat!macro (or otherwise build the string) instead.
.iter()
.map(|registration| {
let info = registration.type_info();
(info.type_path(), format!("{info:#?}"))
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
yeah this is for a circular dep reason |
# Conflicts: # components/tasks/cu_pid/src/lib.rs # core/cu29/src/lib.rs # core/cu29_clock/Cargo.toml # core/cu29_clock/src/lib.rs # core/cu29_runtime/Cargo.toml # core/cu29_runtime/src/debug.rs # core/cu29_runtime/src/reflect.rs # examples/cu_reflect_demo/Cargo.toml
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Related issues
Changes
Testing
just std-cijust lintcargo +stable nextest run --workspace --all-targetsChecklist
Breaking changes (if any)
Additional context