40 releases (22 breaking)
|0.40.2||Jul 2, 2021|
|0.39.1||Apr 19, 2021|
|0.38.3||Mar 16, 2021|
|0.36.0||Nov 27, 2020|
|0.19.0||Nov 11, 2019|
#120 in Graphics APIs
5,247 downloads per month
Used in 11 crates (2 directly)
This package contains three components.
- First, full configuration and build support for Skia in
- Additional C bindings to help out bindgen with stuff it has problems with or to work around linker errors. These are
- And a number of functions that are used to download prebuilt binaries.
Building Skia is quite exceptional, a number of prerequisites need to be available and configured properly for the target platform.
To configure and build Skia,
build_support/skia.rs does all the hard work: it pulls
skia/ from Google's repositories and a number of additional dependencies by executing
skia/tools/git-sync-deps with Python. After that, it configures Skia with Google's GN tool, and finally builds it by giving control to the
ninja executable from the
src/shaper.cpp contain the C++ code that Rust needs to interact with Skia's codebase. These files are processed by the Rust's binding generator that uses libclang for the layout computation and also compiled by clang.
If both steps went well, the resulting Rust binding code is written to
src/bindings.rs, and the
skia-bindings library is found in the output directory alongside where Skia was built previously.
By default, and for performance reasons, Skia is built in release mode even when cargo creates debug output. Skia debug builds can be enabled only by explicitly setting the environment variable
Because building Skia and creating the bindings is slow and depend on a number of components that lie outside the Rust ecosystem, we decided to experiment with prebuilt binaries.
Whenever a new version of
rust-skia is built from the
release branch on our CI server, the resulting Skia library,
skia-bindings library, and
bindings.rs are uploaded to the releases tab of the skia-binaries repository.
And whenever the build script detects that
skia-bindings is built from inside a crate and a prebuilt archive is available that matches the repository's hash, platform, and features, it downloads the package, unpacks it, and skips the full build step of Skia and the bindings.
On some systems, the bundled
gn executables may not work (as is on NixOS.) To remedy
this, the executables used can be set using the following environment variables:
In some cases, one may wish to provide an alternate Skia source directory. This can be achieved by
SKIA_SOURCE_DIR, which must be an absolute path to a Skia source directory with all
By default, numerous libraries Skia depends upon are built in addition to Skia itself. In the event
that this is not wanted (say, if the crate is being built as part of a package's build routine,)
this behavior can be disabled by setting the
SKIA_USE_SYSTEM_LIBRARIES environment variable.
Besides of the features
textlayout that can be directly specified when the package is added as a cargo dependency, the Skia build can be customized further in
build.rs by adjusting one of two structs that are defined in
This struct represents the top level build configuration for
skia-bindings and contains a number of individual feature flags.
FinalBuildConfiguration is created from the
BuildConfiguration and contains name value pairs used by GN to parameterize the Skia build and preprocessor defines used to create the
src/bindings.rs file and the