Boscop / web-view

Rust bindings for webview, a tiny cross-platform library to render web-based GUIs for desktop applications
MIT License
1.91k stars 173 forks source link

Cross-Compiling for ARMv7 #35

Open trembel opened 5 years ago

trembel commented 5 years ago

If I try cross-compiling a test-application I get following error (cross compiling a simple println!("Hello World") works, saying the error comes by trying to compile a webview example):

error: failed to run custom build command for `webview-sys v0.1.0`
process didn't exit successfully: `/home/user/TestApp/target/debug/build/webview-sys-08b7b43d331ebca0/build-script-build` (exit code: 101)
--- stderr
fatal: not a git repository (or any of the parent directories): .git
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CrossCompilation', libcore/result.rs:945:5
richardhozak commented 5 years ago

It seems the webview submodule is not checked out, what command did you use for cross-compilation, did you use something like cross?

RadicalZephyr commented 5 years ago

I'm having a similar issue trying to build for ARMv7 as well. I am simply trying to compile the minimal example as a standalone application. Is it not supported to build this from crates.io?

My build command was simply: cargo build --target=armv7-unknown-linux-gnueabihf. For reference, the project I was trying to build with is here: https://github.com/RadicalZephyr/webkit-app

Let me know if you need any more help with figuring this out. I'm also going to try natively compiling on an arm system (beaglebone black).

RadicalZephyr commented 5 years ago

So, there was more to my error than @cortesis reported above, including here for search indexing:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"webkit2gtk-4.0 >= 2.8\"",
 output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "Package xproto was not found in the pkg-config search path.\nPerhaps you should a$
d the directory containing `xproto.pc\'\nto the PKG_CONFIG_PATH environment variable\nPackage \'xproto\', required by \'xau\', not found\n" } }', libcore/res$
lt.rs:1009:5

I'm building on a Debian system, and I believe the reason for this error message is that the x11proto-core-dev package is arch independent, and thus the file xproto.pc ends up on the native pkgconfig path instead of the one for the cross-build architecture. My solution to this was just to include the default pkgconfig path by adding a PKG_CONFIG_PATH env variable like so:

export PKG_CONFIG_PATH=/usr/share/pkgconfig

I've updated the Dockerfile in my webkit-app repo (linked above), so that repository is a good reference example of how to cross-build web-view.