bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Feature-gate all references to `bevy_text` in `bevy_ui`

Open BD103 opened this issue 1 year ago • 2 comments

Objective

  • bevy_ui fails to compile without bevy_text being enabled.
  • Fixes #11363.

Solution

  • Add #[cfg(feature = "bevy_text")] to all items that require it.

I think this change is honestly a bit ugly, but I can't see any other way around it. I considered making bevy_text required, but we agreed on Discord that there were some use cases for bevy_ui without bevy_text. If you have any ideas that decreases the amount of #[cfg(...)]s and #[allow(...)]s, that would be greatly appreciated.

This was tested by running the following commands:

$ cargo clippy -p bevy_ui
$ cargo clippy -p bevy_ui -F bevy_text
$ cargo run -p ci

Changelog

  • Fixed bevy_ui not compiling without bevy_text.

BD103 avatar Jan 17 '24 19:01 BD103

system extract_uinodes should not be behind the bevy_text feature, it can work without changes without bevy_text

I believe I fixed this in b236ab5679287e7f8552fb662d1a2d9753a7651c.

BD103 avatar Jan 18 '24 14:01 BD103

I'm considering moving all of the #[cfg(feature = "bevy_text")] statements to a separate function, that way we only have to use the cfg attribute once.

#[cfg(feature = "bevy_text")]
fn build_text_interop(app: &mut App) {
    app.add_systems(...);
    // etc.
}

BD103 avatar Jan 18 '24 19:01 BD103