Crates.io | ckia_sys |
lib.rs | ckia_sys |
version | 121.0.0 |
source | src |
created_at | 2024-01-10 14:19:11.198094 |
updated_at | 2024-01-10 14:19:11.198094 |
description | c bindings crate for skia |
homepage | https://github.com/coderedart/ckia_sys.git |
repository | https://github.com/coderedart/ckia_sys.git |
max_upload_size | |
id | 1095251 |
size | 169,107 |
This project will take skia and generate rust bindings for it. It also takes care of building skia.
fast compile times is the highest priority. and we do this by:
cargo install bindgen
# merge extern blocks creates a smaller and denser bindings.rs
# no-layout-tests avoids a lot of tests and makes bindings.rs cleaner. But for sanity, we might generate layout tests first, run cargo test, and then generate bindings without tests to publish.
# -Iskia is necessary to let clang know where to search for include paths.
bindgen --merge-extern-blocks --default-enum-style rust --no-layout-tests -o bindings.rs skia/ckia/src/sk_all.c -- -Iskia/
gr_vk_get_proc
. change its ABI to extern "system"
, so that it can use __stdcall
ABI on windows platforms.Skia exposes a lot of configuration at build time. To avoid dealing with all the complexity, we will only provide pre-built libraries for common "all-purpose" configuration and expect the users to build from scratch when they need some custom build.
you can force building from scratch by enabling build_from_src
feature flag or by setting SKIA_BUILD_FROM_SRC
env var.
If you are using the default build and there's a prebuilt binary available, then
curl
-> to download the pre-built libstar
-> to extract the archives after downloading.Both windows 10 and linux have these by default.
If you are building from source:
git
-> to clone skia repo and depspython
-> to download build deps and run build scriptstar
(optional) -> to package libs before copying them to SKIA_COPY_LIBS
(see below)curl
-> maybe download something that we need like source code packages from github.clang
and clang++
. (LLVM).sccache
or ccache
(optional) -> for caching compiled objects, as cargo clean
will remove everything from target eventually. highly recommended.gn
to bazel
. So, you will probably hit some issues.If you are building from source, then there are a few env variables you might want to set.
name | default | purpose |
---|---|---|
SKIA_CC | clang* | c compiler. clang is preferred by skia |
SKIA_CC_WRAPPER | sccache* or ccache* | improves compile times by using a global cache. highly recommended |
SKIA_CXX | clang++* | c++ compiler. clang++ is preferred by skia |
SKIA_CLANG_WIN (windows only) | C:\Program Files\LLVM* | path to LLVM installation. required for using clang |
SKIA_CLANG_WIN_VERSION (windows only) | SKIA_CLANG_WIN/lib/clang/version** | version of clang to use. ckia_sys will try to use the most recent version in SKIA_CLANG_WIN/lib/clang/. required for using clang |
SKIA_BUILD_FROM_SRC | 0 | if non-zero, tells ckia_sys to build skia from src. provided for convenience as an alternative to feature build_from_src |
SKIA_GN_ARGS (only applies if building from src) | "" | addditional GN args to pass to skia build for custom builds. |
SKIA_COPY_LIBS | "" | tells ckia_sys build system to copy the built binaries to the directory based on the path set in this var. useful in workflows to distribute libs after building it |
SKIA_SRC_DIR | "" | If set, we will use this as the source for the build. |
SKIA_SRC_ARCHIVE_URL | "" | If set, we will use curl to download this archive (.tar.gz), and extract it in OUT_DIR, and use that as the skia src directory. The archive must have a top level folder, which contains the skia sources |
* We will only use that default IF it is avaialable. Otherwise, we will avoid setting that gn arg. eg: we will only use clang
for SKIA_CC
if clang --version
works. otherwise, we would just let skia use the default cc
.
** We will look into LLVM/lib/clang directory, read the versions and set the version to latest we can find. Otherwise, we will just skip setting it.