Skip to content

Latest commit

 

History

History
executable file
·
312 lines (212 loc) · 8.16 KB

BUILD.adoc

File metadata and controls

executable file
·
312 lines (212 loc) · 8.16 KB

How to build resvg

Intro

resvg doesn’t include a 2D graphics library and uses external ones. Their support is implemented separately, therefore we call them backends. You can build them separately or together.
At the moment, there are four backends: Qt, cairo, Skia and raqote.

Since resvg is a Rust library, you should build it via cargo.
To enable a backend use the --features option:

# Build with a Qt backend
cargo build --release --features="qt-backend"
# or with a cairo backend
cargo build --release --features="cairo-backend"
# or with a raqote backend
cargo build --release --features="raqote-backend"
# or with a skia backend
cargo build --release --features="skia-backend"
# or with all
cargo build --release --all-features

Dependencies

  • The library requires the latest stable Rust.

  • All backends depend on harfbuzz, which will be built automatically by cargo and will be linked statically. CMake is required as a build-time dependency.

  • The Qt backend requires only QtCore and QtGui libraries.
    Technically, any Qt 5 version should work, but we only support Qt >= 5.6.

  • The cairo backend requires cairo >= 1.12.

  • The raqote backend doesn’t require any external dependencies.

  • The skia backend requires the Skia itself.

  • (Linux, runtime) fontconfig. Specifically fc-match.

Windows

Qt backend via MSVC

Install:

Build using x64 Native Tools Command Prompt for VS 2017 shell:

set PATH=%userprofile%\.cargo\bin;%PATH%
set QT_DIR=C:\Qt\5.12.0\msvc2017_64
rustup.exe default stable-x86_64-pc-windows-msvc

cargo.exe build --release --features "qt-backend"

Instead of msvc2017_64 you can use any other Qt MSVC build. Even 32-bit one. We are using Qt 5.12.0 just for example.

Qt backend via MinGW

Install:

Build using cmd.exe:

set PATH=C:\Qt\5.12.0\mingw73_64\bin;C:\Qt\Tools\mingw730_64\bin;%userprofile%\.cargo\bin;%PATH%
set QT_DIR=C:\Qt\5.12.0\mingw73_64
rustup.exe default stable-x86_64-pc-windows-gnu

cargo.exe build --release --features "qt-backend"

Instead of mingw73_64 you can use any other Qt mingw build. We are using Qt 5.12.0 just for example.

cairo backend via MSYS2

Install stable-x86_64-pc-windows-gnu Rust target. And then:

pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-cairo
rustup default stable-x86_64-pc-windows-gnu

cargo build --release --features "cairo-backend"

You can use i686 target in the same way.

raqote backend via MSVC

Install:

  • stable-x86_64-pc-windows-msvc Rust target.

  • CMake (required to build harfbuzz).

Build using x64 Native Tools Command Prompt for VS 2017 shell:

set PATH=%userprofile%\.cargo\bin;C:\Program Files\CMake\bin;%PATH%
rustup.exe default stable-x86_64-pc-windows-msvc

cargo.exe build --release --features "raqote-backend"

raqote backend via MSYS2

Install stable-x86_64-pc-windows-gnu Rust target. And then:

# install harfbuzz dependencies:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake
rustup default stable-x86_64-pc-windows-gnu

cargo build --release --features "raqote-backend"

You can use i686 target in the same way.

Skia backend via MSVC

Install:

  • stable-x86_64-pc-windows-msvc Rust target.

  • CMake (required to build harfbuzz).

  • Skia itself (we assume that you have already built one).

SKIA_DIR should point to a Skia directory that contains the Skia include directory. SKIA_LIB_DIR should point to a Skia directory that contains skia.dll.

Build using x64 Native Tools Command Prompt for VS 2017 shell:

set PATH=%userprofile%\.cargo\bin;C:\Program Files\CMake\bin;%PATH%
set SKIA_DIR=path
set SKIA_LIB_DIR=path
rustup.exe default stable-x86_64-pc-windows-msvc

cargo.exe build --release --features "skia-backend"

Linux

Qt backend

Install Qt 5 and harfbuzz using your distributive’s package manager.

On Ubuntu you can install them via:

sudo apt install qtbase5-dev libharfbuzz-dev

Build resvg:

cargo build --release --features "qt-backend"

If you don’t want to use a system Qt, you can alter it with the PKG_CONFIG_PATH variable.

PKG_CONFIG_PATH='/path_to_qt/lib/pkgconfig' cargo build --release --features "qt-backend"

cairo backend

Install cairo and harfbuzz using your distributive’s package manager.

On Ubuntu you can install them via:

sudo apt install libcairo2-dev libharfbuzz-dev

Build resvg:

cargo build --release --features "cairo-backend"

raqote backend

Install harfbuzz using your distributive’s package manager.

On Ubuntu you can install it via:

sudo apt install libharfbuzz-dev

Build resvg:

cargo build --release --features "raqote-backend"

Skia backend

We assume that you have already built Skia itself.

Install harfbuzz using your distributive’s package manager.

On Ubuntu you can install it via:

sudo apt install libharfbuzz-dev

SKIA_DIR should point to a Skia directory that contains the Skia include directory. SKIA_LIB_DIR should point to a Skia directory that contains libskia.so.

SKIA_DIR=path SKIA_LIB_DIR=path cargo build --release --features "skia-backend"

macOS

Qt backend

Using homebrew:

brew install qt

QT_DIR=/usr/local/opt/qt cargo build --release --features "qt-backend"
QT_DIR=/Users/$USER/Qt/5.12.0/clang_64 cargo build --release --features "qt-backend"

We are using Qt 5.12.0 just for example.

cairo backend

Using homebrew:

brew install cairo

cargo build --release --features "cairo-backend"

raqote backend

cargo build --release --features "raqote-backend"

Skia backend

We assume that you have already built Skia itself.

Install harfbuzz using Homebrew via:

brew install harfbuzz

SKIA_DIR should point to a Skia directory that contains the Skia include directory. SKIA_LIB_DIR should point to a Skia directory that contains libskia.dylib.

SKIA_DIR=path SKIA_LIB_DIR=path cargo build --release --features "skia-backend"

For maintainers

resvg consists of 4 parts:

All of them are optional and each one, except usvg, can be built with a specific backend.

No need to build rendersvg for each backend separately since it has a CLI switch to choose which one to use in runtime. Not sure how the Rust library can be packaged, but the C libraries should probably be built separately.

So the final package can look like this:

/bin/rendersvg (does not depend on libresvg-*.so)
/bin/usvg (completely optional)
/include/resvg/resvg.h (from capi/include)
/include/resvg/ResvgQt.h (from capi/include, only for Qt backend)
/lib/libresvg-cairo.so
/lib/libresvg-qt.so
/lib/libresvg-raqote.so
/lib/libresvg-skia.so