rust-windowing / softbuffer

Softbuffer integrates with the raw-window-handle crate to allow writing to a window in a cross-platform way while using the very high quality dedicated window management libraries that are available in the Rust ecosystem.
Apache License 2.0
272 stars 43 forks source link

Cannot compile on android #211

Open Quackdoc opened 3 weeks ago

Quackdoc commented 3 weeks ago

Partially related to #44 I am trying to compile some rust application targeting termux (x11) and am getting the below errors. I have tried both compiling within termux, as well as on my desktop

command: cargo build --target x86_64-linux-android

Error log ```rust error[E0392]: parameter `D` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:33:20 | 33 | pub struct Context { | ^ unused parameter | = help: consider removing `D`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `D` to be a const parameter, use `const D: usize` instead error[E0392]: parameter `D` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:74:20 | 74 | pub struct Surface { | ^ unused parameter | = help: consider removing `D`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `D` to be a const parameter, use `const D: usize` instead error[E0392]: parameter `W` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:74:23 | 74 | pub struct Surface { | ^ unused parameter | = help: consider removing `W`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `W` to be a const parameter, use `const W: usize` instead error[E0392]: parameter `'a` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:197:19 | 197 | pub struct Buffer<'a, D, W> { | ^^ unused parameter | = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` error[E0392]: parameter `D` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:197:23 | 197 | pub struct Buffer<'a, D, W> { | ^ unused parameter | = help: consider removing `D`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `D` to be a const parameter, use `const D: usize` instead error[E0392]: parameter `W` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:197:26 | 197 | pub struct Buffer<'a, D, W> { | ^ unused parameter | = help: consider removing `W`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `W` to be a const parameter, use `const W: usize` instead error[E0392]: parameter `D` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/backend_dispatch.rs:180:6 | 180 | => | ^ unused parameter | = help: consider removing `D`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `D` to be a const parameter, use `const D: usize` instead error[E0392]: parameter `W` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/backend_dispatch.rs:180:9 | 180 | => | ^ unused parameter | = help: consider removing `W`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `W` to be a const parameter, use `const W: usize` instead error[E0392]: parameter `'a` is never used --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/backend_dispatch.rs:119:40 | 119 | pub(crate) enum BufferDispatch<'a, $dgen, $wgen> { | ^^ unused parameter ... 179 | / make_dispatch! { 180 | | => 181 | | #[cfg(x11_platform)] 182 | | X11(Rc>, backends::x11::X11Impl, backends::x11::BufferImpl<'a, D, W>), ... | 194 | | Orbital(D, backends::orbital::OrbitalImpl, backends::orbital::BufferImpl<'a, D, W>), 195 | | } | |_- in this macro invocation | = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` = note: this error originates in the macro `make_dispatch` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0283]: type annotations needed --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:83:15 | 83 | match SurfaceDispatch::new(window, &context.context_impl) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `D` declared on the trait `SurfaceInterface` | = note: cannot satisfy `_: HasDisplayHandle` = help: the following types implement trait `HasDisplayHandle`: NoDisplayHandle Box DisplayHandle<'a> Rc Arc &H &mut H note: required by a bound in `backend_interface::SurfaceInterface::new` --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/backend_interface.rs:15:38 | 15 | pub(crate) trait SurfaceInterface { | ^^^^^^^^^^^^^^^^ required by this bound in `SurfaceInterface::new` ... 21 | fn new(window: W, context: &Self::Context) -> Result> | --- required by a bound in this associated function error[E0282]: type annotations needed --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:137:12 | 137 | Ok(Buffer { | ____________^ 138 | | buffer_impl: self.surface_impl.buffer_mut()?, 139 | | _marker: PhantomData, 140 | | }) | |_________^ cannot infer type of the type parameter `D` declared on the struct `Buffer` | help: consider specifying the generic arguments | 137 | Ok(Buffer:: { | ++++++++ error[E0283]: type annotations needed --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:147:14 | 147 | self.window() | ^^^^^^ cannot infer type for type parameter `D` | = note: cannot satisfy `_: HasDisplayHandle` = help: the following types implement trait `HasDisplayHandle`: NoDisplayHandle Box DisplayHandle<'a> Rc Arc &H &mut H note: required by a bound in `Surface::::window` --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:80:9 | 80 | impl Surface { | ^^^^^^^^^^^^^^^^ required by this bound in `Surface::::window` ... 101 | pub fn window(&self) -> &W { | ------ required by a bound in this associated function error[E0282]: type annotations needed --> /home/quack/.cargo/registry/src/index.crates.io-6f17d22bba15001f/softbuffer-0.4.2/src/lib.rs:156:23 | 156 | self.window().window_handle() | ^^^^^^^^^^^^^ cannot infer type for type parameter `W` Some errors have detailed explanations: E0282, E0283, E0392. For more information about an error, try `rustc --explain E0282`. error: could not compile `softbuffer` (lib) due to 13 previous errors warning: build failed, waiting for other jobs to finish... ```
ids1024 commented 3 weeks ago

Those "parameter D is never used" errors are a result of building with no backends. Since neither the X or Wayland backend are being built for "android".

It would be possible to fix those, but it still wouldn't "work" without any backends.

You should be able to run aarch64-unknown-linux-gnu or maybe aarch64-unknown-linux-musl binaries on Android, I guess? Then it will compile with the needed backends.

Quackdoc commented 3 weeks ago

we can compile musl and gnu binaries to kinda run on termux but it's spotty at best.

I did however try and build the x11 backend, but it seems like this will be a process of going through various crates and see where they fail like rustix

ids1024 commented 3 weeks ago

I think it would be good to support X11/Wayland backends on any platform that can support them. It's a little unclear how best to do that though.

We could just enable the X11 backend when compiled for Android, but presumably if a native Android backend were added, we'd want it to not be default. Likewise, we probably don't want to always build the X11 backend on macOS.

Ideally, it would be good to have the x11 and wayland features default on Linux, but non-default on macOS or Android. But Rust doesn't seem to currently have a way to do that.

TheYahton commented 3 weeks ago

Since neither the X or Wayland backend are being built for "android".

https://github.com/termux/termux-x11

Quackdoc commented 3 weeks ago

Since neither the X or Wayland backend are being built for "android".

https://github.com/termux/termux-x11

yes, and there is also wayland support. in two forms, one being nested compositors, and another being work done with wlroots and termux-gui. When I find the time I will try to tackle x11 possibly. wayland is a lower priority, but also something I want to do. but ofc this is time permitting