emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
20.7k stars 1.5k forks source link

Allow compiling for Unix native with no X11 linkage #3335

Open mrpathos opened 9 months ago

mrpathos commented 9 months ago

Is your feature request related to a problem? Please describe.

I'm using egui to build for an embedded linux platform with no x11 support. Trying to get egui to link with no x11 inclusion using glow was extremely complicated, so I switched to wgpu. The remaining x11 inclusion came from the egui-winit "clipboard" feature and wasn't optional / I couldn't fix that in my own Cargo.toml.

Building for wgpu with egui-winit "clipboard" and "links" features removed successfully yields an x11-free binary.

Describe the solution you'd like

I already forked the repo to test stuff out, but submitting an issue as per the PR requirements doc. Adding a feature to eframe that itself just includes ["egui-winit/clipboard", "egui-winit/links"], and removing those features from the non-wasm dependencies section fixes this problem. It's not a perfect solution because enabling that feature on a non-native platform will probably fail to compile, but Rust's support for per-feature-per-platform dependencies is not robust and I wasn't able to figure out how to make that work.

mrpathos commented 9 months ago

Note that this is against head of master. I just moved back to 0.22.0 for my fork and it takes significantly more modification to link without x11 getting pulled in. So this is at least getting easier! :)

emilk commented 9 months ago

I'm glad to hear it! The fastest way to get this fully resolves is probably to open some PRs ;)

flosse commented 4 months ago

@mrpathos Could you share the modifications you made?