aweinstock314 / rust-clipboard

System Clipboard interfacing library in Rust
Apache License 2.0
368 stars 75 forks source link

Fix compile error on wasm32-unknown-emscripten target #62

Closed iceiix closed 5 years ago

iceiix commented 5 years ago

rust-clipboard fails to build with the wasm32-unknown-emscripten target since it tries to build X clipboard support:

$ cargo build --target wasm32-unknown-emscripten
   Compiling xcb v0.8.2                                                                                                                                                      
error: failed to run custom build command for `xcb v0.8.2`                                                                                                                   
process didn't exit successfully: `rust-clipboard/target/debug/build/xcb-f6f24f9a96d825ba/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Unable to find build dependency python3: Os { code: 2, kind: NotFound, message: "No such file or directory" }', libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Since emscripten is recognized as "unix", but like macos and android it doesn't have an X11 clipboard, this pull request adds "emscripten" to the target_os exclusion for cfg unix:

#[cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten"))))]

and the crate compiles with no errors

iceiix commented 5 years ago

Note this doesn't add any real support for clipboards on the web, but that could be added later as another enhancement (https://www.w3.org/TR/clipboard-apis/); this PR is only about getting it to compile

iceiix commented 5 years ago

@aweinstock314 Thanks for the merge! Could you publish a new release on crates.io? (until then I can depend on the git revision)