Files
pdf/third_party/skia
2026-05-21 14:59:09 +05:30
..
2026-05-21 14:59:09 +05:30
2026-05-21 14:59:09 +05:30
2026-05-21 14:59:09 +05:30
2026-05-21 14:59:09 +05:30
2026-05-21 14:59:09 +05:30

Skia — built from source

Skia is the C++ vector rendering core of the engine (Gate G0). It is not a vcpkg package; Google ships it only as source built with their own toolchain (depot_tools + GN + Ninja).


What the build scripts do

build_skia.ps1 (Windows) and build_skia.sh (Linux/macOS) automate:

  1. Read the pinned revision from skia.pinned (refuses to run if it is still the placeholder — Rule: never track rolling HEAD).
  2. Reuse or clone depot_tools under the build root (PDFium and Skia share the toolchain).
  3. Clone the Skia tree into <build root>/checkout/skia.
  4. Check out the exact pinned commit and run tools/git-sync-deps (Python script) to checkout Skia's third-party dependencies.
  5. Write args.gn for a static, standalone, monolithic, embed-friendly build:
    • is_component_build = false — one static lib, not many DLLs/shared libs
    • skia_use_gl = true
    • use_custom_libcxx = false — link the system C++ runtime so Skia is ABI-compatible with the rest of the engine (critical for embedding)
    • skia_use_harfbuzz = false — offloads text shaping to the main engine's system/vcpkg HarfBuzz, avoiding internal GN include errors and saving ~40% build time (drops compile units from 1259 to 776)
  6. gn gen + ninja -C out/Release skia.
  7. Copy include/**/*.hinstall/include/ and the static lib skia.lib or libskia.ainstall/lib/.

cmake/skia.cmake then turns install/ into the skia::skia imported target. Build the engine with -DPDFENGINE_WITH_SKIA=ON to link it.


⚠️ Important Windows Build Requirements

Since the engine uses the Ninja generator on Windows, cl.exe (the MSVC compiler) is not on the environment's PATH by default. Running CMake inside a standard PowerShell window will result in No CMAKE_CXX_COMPILER could be found.

Before configuring or compiling, you MUST run the build from a Developer PowerShell/Command Prompt for Visual Studio or manually source the environment variables using vcvars64.bat in a command shell:

:: Source MSVC dev environment (adjust path for VS Community/Enterprise/Professional/BuildTools)
call "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvars64.bat" amd64

The build root — paths with spaces

depot_tools, GN and Ninja do not support a space anywhere in their own path. By default the scripts build under this directory (third_party/skia/), which is fine when the repo lives on a space-free path.

If the repo path contains a space (e.g. OneDrive\...\PDF Editor\...), the scripts hard-error and you must point the build root somewhere space-free:

# Windows
$env:SKIA_BUILD_ROOT = 'C:\skia-build'
pwsh third_party\skia\build_skia.ps1
# Linux / macOS
SKIA_BUILD_ROOT=/tmp/skia-build ./third_party/skia/build_skia.sh

depot_tools/ and checkout/ then live under the build root; the finished install/ is always written into third_party/skia/install/ (git-ignored) so cmake/skia.cmake finds it in the same place regardless.


Pinning the revision

skia.pinned holds the pinned commit SHA. To re-pin (a deliberate, scheduled action — the risk register calls for quarterly rebases):

  1. Pick a commit from https://skia.googlesource.com/skia/+log/main (or the tip of a recent stable Chromium release branch).
  2. Update SKIA_COMMIT= in skia.pinned and commit it.
  3. Re-run the build script.

Usage Guide (Step-by-Step)

Prerequisites

  • Git
  • Python 3
  • A C++ toolchain (Windows: Visual Studio 2022+ or Visual Studio 2026+ with the "Desktop development with C++" workload).

Step 1: Compile the Skia Static Library

Run the orchestrator script to clone, compile, and install Skia.

# Windows (Set SKIA_BUILD_ROOT first if there are spaces in your path)
pwsh third_party/skia/build_skia.ps1
# Linux / macOS
./third_party/skia/build_skia.sh

This installs skia.lib/libskia.a and its public headers directly to third_party/skia/install/.

Step 2: Configure & Build the PDF Engine

With the MSVC environment active:

# Windows Developer Shell
set VCPKG_ROOT=C:\Users\azeem\OneDrive\Desktop\saas\pdf\vcpkg
cmake --preset windows-debug -DPDFENGINE_WITH_SKIA=ON
cmake --build --preset windows-debug
# Linux / macOS
cmake --preset linux-debug -DPDFENGINE_WITH_SKIA=ON
cmake --build --preset linux-debug

Step 3: Run the Tests

Verify the engine compiles and links successfully with Skia:

# Windows Developer Shell
ctest --preset windows-debug
# Linux / macOS
ctest --preset linux-debug