You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for the wasm32-unknown-emscripten target
Build is working with emscripten 3.1.1, but requires setting some
environment variables:
EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" EMSDK=~/.asdf/installs/emsdk/3.1.1 cargo build --target wasm32-unknown-emscripten
ERROR_ON_UNDEFINED_SYMBOLS is a workaround for:
warning: ___gxx_personality_v0 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
This error appeared with emscripten 2.0.10 and has yet to be fixed in
rust: rust-lang/rust#85821 (comment)
EMSDK is for building skia-bindings against emscripten's platform
includes.
This is adapted from https://github.com/tuxmark5/rust-skia.
This project provides _up to date_ safe bindings that bridge idiomatic Rust with Skia's C++ API on desktop and mobile platforms, including GPU rendering backends for [Vulkan](https://en.wikipedia.org/wiki/Vulkan_(API)), [Metal](https://en.wikipedia.org/wiki/Metal_(API)), [OpenGL](https://en.wikipedia.org/wiki/OpenGL), and [Direct3D](https://en.wikipedia.org/wiki/Direct3D).
12
+
This project provides _up to date_ safe bindings that bridge idiomatic Rust with Skia's C++ API on desktop and mobile platforms, including GPU rendering backends for [Vulkan](<https://en.wikipedia.org/wiki/Vulkan_(API)>), [Metal](<https://en.wikipedia.org/wiki/Metal_(API)>), [OpenGL](https://en.wikipedia.org/wiki/OpenGL), and [Direct3D](https://en.wikipedia.org/wiki/Direct3D).
13
13
14
14
## Status
15
15
@@ -40,31 +40,29 @@ For other platforms, more information is available at the [OpenSSL crate documen
40
40
41
41
### Platform Support, Build Targets, and Prebuilt Binaries
42
42
43
-
Because building Skia takes a lot of time and needs tools that may be missing, the skia-bindings crate's `build.rs` tries to download prebuilt binaries from [the skia-binaries repository](<https://github.com/rust-skia/skia-binaries/releases>).
43
+
Because building Skia takes a lot of time and needs tools that may be missing, the skia-bindings crate's `build.rs` tries to download prebuilt binaries from [the skia-binaries repository](https://github.com/rust-skia/skia-binaries/releases).
44
44
45
-
| Platform | Binaries |
46
-
| -------- | -------- |
47
-
| Windows |`x86_64-pc-windows-msvc`|
48
-
| Linux Ubuntu 16+<br />CentOS 7, 8 |`x86_64-unknown-linux-gnu`|
There no support for WebAssembly yet. If you'd like to help out, take a look at issue [#39](https://github.com/rust-skia/rust-skia/issues/39).
The supported wrappers, Skia codecs, and additional Skia features are documented in the [skia-safe package's readme](skia-safe/README.md). Prebuilt binaries are available for most feature combinations.
58
56
59
57
## Building
60
58
61
-
If the target platform or feature configuration is not available as a prebuilt binary, skia-bindings' `build.rs` will try to build Skia and generate the Rust bindings.
59
+
If the target platform or feature configuration is not available as a prebuilt binary, skia-bindings' `build.rs` will try to build Skia and generate the Rust bindings.
62
60
63
61
To prepare for that, **LLVM** and **Python 2** are needed:
64
62
65
63
**LLVM**
66
64
67
-
We recommend the version that comes preinstalled with your platform, or, if not available, the [latest official LLVM release](http://releases.llvm.org/download.html). To see which version of LLVM/Clang is installed on your system, use `clang --version`.
65
+
We recommend the version that comes preinstalled with your platform, or, if not available, the [latest official LLVM release](http://releases.llvm.org/download.html). To see which version of LLVM/Clang is installed on your system, use `clang --version`.
68
66
69
67
**Python 2**
70
68
@@ -88,9 +86,9 @@ The build script probes for `python --version` and `python2 --version` and uses
88
86
sudo open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
89
87
```
90
88
91
-
If not installed, the Skia build _may_ fail to build `SkJpegUtility.cpp` and the binding generation _will_ fail with `'TargetConditionals.h' file not found` . Also note that the Command Line Tools _and_ SDK headers _should_ be reinstalled after an update of XCode.
89
+
If not installed, the Skia build _may_ fail to build `SkJpegUtility.cpp` and the binding generation _will_ fail with `'TargetConditionals.h' file not found` . Also note that the Command Line Tools _and_ SDK headers _should_ be reinstalled after an update of XCode.
92
90
93
-
- As an alternative to Apple's XCode LLVM, install LLVM via `brew install llvm` or `brew install llvm` and then set `PATH`, `CPPFLAGS`, and `LDFLAGS` like instructed.
91
+
- As an alternative to Apple's XCode LLVM, install LLVM via `brew install llvm` or `brew install llvm` and then set `PATH`, `CPPFLAGS`, and `LDFLAGS` like instructed.
94
92
95
93
If the environment variables are not set, [bindgen](https://github.com/rust-lang/rust-bindgen) will most likely use the wrong `libclang.dylib` and cause confusing compilation errors (see #228).
96
94
@@ -103,15 +101,15 @@ The build script probes for `python --version` and `python2 --version` and uses
103
101
- Install the [latest LLVM](http://releases.llvm.org/download.html) distribution.
104
102
105
103
If the environment variable `LLVM_HOME` is not defined, the build script will look for LLVM installations located at `C:\Program Files\LLVM\`, `C:\LLVM\`, and `%USERPROFILE%\scoop\apps\llvm\current\`.
106
-
104
+
107
105
-[MSYS2](https://www.msys2.org/):
108
-
106
+
109
107
- Install Python2 with `pacman -S python2`.
110
-
108
+
111
109
- Windows Shell (`Cmd.exe`):
112
-
110
+
113
111
- Download and install Python version 2 from [python.org](https://www.python.org/downloads/release/python-2716/).
- The `CARGO_TARGET_${TARGET}_LINKER` environment variable name [needs to be all uppercase](https://github.com/rust-lang/cargo/issues/1109#issuecomment-386850387).
@@ -212,6 +211,51 @@ _Notes:_
212
211
213
212
Compilation to iOS is supported on macOS targeting the iOS simulator (`--target x86_64-apple-ios`) and 64 bit ARM devices (`--target aarch64-apple-ios`). The ARM64**e** architecture is [not supported yet](https://github.com/rust-lang/rust/issues/73628).
214
213
214
+
### For WebAssembly
215
+
216
+
Install `emscripten` version 3.1.1 or superior.
217
+
218
+
Build with the `wasm32-unknown-emscripten` target (`wasm32-unknown-unknown` is
219
+
unsupported because it is [fundamentally incompatible with linking C code](https://github.com/rustwasm/team/issues/291#issuecomment-645482430):
For situations in which Skia does not build or needs to be configured differently, we support some customization support in `skia-bindings/build.rs`. For more details take a look at the [README of the skia-bindings package](skia-bindings/README.md).
@@ -249,7 +293,8 @@ cargo run -- [OUTPUT_DIR] --driver opengl
249
293
```
250
294
251
295
And to show the drivers that are supported
252
-
```bash
296
+
297
+
```bash
253
298
cargo run -- --help
254
299
```
255
300
@@ -305,5 +350,3 @@ More details can be found at [CONTRIBUTING.md](https://github.com/rust-skia/rust
0 commit comments