PDFium — built from source
PDFium is the parser + base-rendering core of the engine (Rule R1). It is not a vcpkg package; Google ships it only as source built with their own toolchain (depot_tools + GN + Ninja). The timeline flags this as "the single biggest Day-1 risk — budget a full day for depot_tools quirks."
What the build scripts do
build_pdfium.ps1 (Windows) and build_pdfium.sh (Linux/macOS) automate:
- Read the pinned revision from
pdfium.pinned(refuses to run if it is still the placeholder — Rule: never track rolling HEAD). - Clone
depot_toolsunder the build root and run its Windows bootstrap (fetches bundled git + python via CIPD). gclient config+gclient syncthe PDFium tree into<build root>/checkout/.- Check out the exact pinned commit and re-sync its DEPS.
- Write
args.gnfor a static, standalone, monolithic, embed-friendly build:is_component_build = false— one static lib, not many DLLspdf_is_standalone = truepdf_enable_v8 = false,pdf_enable_xfa = false— no JS / XFA in v1pdf_use_skia = false— we drive Skia ourselves lateruse_custom_libcxx = false— link the system C++ runtime so PDFium is ABI-compatible with the rest of the engine (critical for embedding)pdf_use_partition_alloc = false
gn gen+ninja -C out/Release pdfium.- Copy
public/*.h→install/include/and the static lib →install/lib/.
cmake/pdfium.cmake then turns install/ into the pdfium::pdfium imported
target. Build the engine with -DPDFENGINE_WITH_PDFIUM=ON to link it.
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/pdfium/), 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:PDFIUM_BUILD_ROOT = 'C:\pdfium-build'
pwsh third_party\pdfium\build_pdfium.ps1
# Linux / macOS
PDFIUM_BUILD_ROOT=/tmp/pdfium-build ./third_party/pdfium/build_pdfium.sh
depot_tools/ and checkout/ then live under the build root; the finished
install/ is always written into third_party/pdfium/install/ (git-ignored)
so cmake/pdfium.cmake finds it in the same place regardless.
Pinning the revision
pdfium.pinned holds the pinned commit SHA. It is currently pinned to a
specific main-branch commit. To re-pin (a deliberate, scheduled action — the
risk register calls for quarterly rebases):
- Pick a commit from https://pdfium.googlesource.com/pdfium/+log/main (or the
tip of a recent
chromium/NNNNrelease branch). - Update
PDFIUM_COMMIT=inpdfium.pinnedand commit it. - Re-run the build script.
Usage
Prerequisites: Git, Python 3, and a C++ toolchain (Windows: Visual Studio 2022+ with the "Desktop development with C++" workload).
# Windows — set PDFIUM_BUILD_ROOT first if the repo path has a space (see above)
pwsh third_party\pdfium\build_pdfium.ps1
# Linux / macOS
./third_party/pdfium/build_pdfium.sh
Expect the first run to take a long time — the gclient sync alone pulls
several GB, and the compile is lengthy. depot_tools/, checkout/, and
install/ are all git-ignored.
Troubleshooting
'C:\...\PDF' is not recognized/ GN or Ninja path errors — a space in the build-root path. SetPDFIUM_BUILD_ROOTto a space-free location.gclient syncaborts with "uncommitted changes" — git'score.autocrlfrewrote a dependency checkout. The scripts already injectcore.autocrlf=falseper-process; if you bypass them, set it yourself.- depot_tools
git/pythonnot found — depot_tools was not bootstrapped. The scripts runbootstrap\win_tools.bat; do not setDEPOT_TOOLS_UPDATE=0, which suppresses that bootstrap.