linebender / druid

A data-first Rust-native UI design toolkit.
https://linebender.org/druid/
Apache License 2.0
9.53k stars 568 forks source link

[BUG] Build failure on Wayland + FreeBSD #2283

Closed ngortheone closed 1 year ago

ngortheone commented 1 year ago

Trying to build master branch on FreeBSD with this command

cargo build --no-default-features --features wayland

Gives the following error:

error: could not select an appropriate backend
  --> /home/ngor/.local/cargo/registry/src/github.com-1ecc6299db9ec823/piet-common-0.5.0/src/lib.rs:48:9
   |
48 |         compile_error!("could not select an appropriate backend");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved import `backend`
  --> /home/ngor/.local/cargo/registry/src/github.com-1ecc6299db9ec823/piet-common-0.5.0/src/lib.rs:52:9
   |
52 | pub use backend::*;
   |         ^^^^^^^ use of undeclared crate or module `backend`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `piet-common` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

I am doing something wrong or is this a bug? Thanks

ngortheone commented 1 year ago

This also happens when I follow example from druid book https://linebender.org/druid/get_started.html

ngortheone commented 1 year ago

This seems to be caused by old version of piet-common dependecny .. changing piet-common to latest master branch fixes this issue, but now I have new issue:

/opt/ngor/src/github.com/linebender/druid/druid-shell/wrapper.h:1:10: fatal error: 'xkbcommon/xkbcommon-compose.h' file not found
  thread 'main' panicked at 'Unable to generate bindings: ClangDiagnostic("/opt/ngor/src/github.com/linebender/druid/druid-shell/wrapper.h:1:10: fatal error: 'xkbcommon/xkbcommon-compose.h' file not found\n")', druid-shell/build.rs:53:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Seems that build.rs is broken - it can't find the header file (which is present in the system)

jneem commented 1 year ago

Maybe we should be using the clang_arg function to provide the include path to bindgen. It looks like the include paths should be accessible to us from the calls to probe_library...

ngortheone commented 1 year ago

@jneem yes, my current diff to build.rs:

--- a/druid-shell/build.rs
+++ b/druid-shell/build.rs
@@ -14,7 +14,7 @@ fn main() {
         return;
     }

-    probe_library("xkbcommon").unwrap();
+    let xkbcommon = probe_library("xkbcommon").unwrap();

     #[cfg(feature = "x11")]
     probe_library("xkbcommon-x11").unwrap();
@@ -34,6 +34,12 @@ fn main() {
         // The input header we would like to generate
         // bindings for.
         .header_contents("wrapper.h", &header)
+        .clang_args(
+            xkbcommon
+                .include_paths
+                .iter()
+                .map(|path| format!("-I{}", path.to_string_lossy())),
+        )
         // Tell cargo to invalidate the built crate whenever any of the
         // included header files changed.
         .parse_callbacks(Box::new(bindgen::CargoCallbacks))
@@ -48,7 +54,7 @@ fn main() {
         // we use FILE from libc
         .blocklist_type("FILE")
         .blocklist_type("va_list")
-        .blocklist_type("_.*")
+        //.blocklist_type("_.*")
         .generate()
         .expect("Unable to generate bindings");
jneem commented 1 year ago

And with this patch is it now building on FreeBSD? It seems good to me except for the change to blocklist_type, could you explain that part?

ngortheone commented 1 year ago

.blocklist_type("_.*") was preventing some necessary symbols from being detected, and the build was failing.

jneem commented 1 year ago

Ok, I've committed those changes in #2295