Building on Amazon Linux - gradescope/pdfium GitHub Wiki

1. Install dependencies

sudo yum groupinstall -y "Development Tools"
sudo yum install -y git-all
sudo yum install -y python
sudo yum install -y libjpeg-turbo-devel
sudo yum install -y freetype-devel

2. Install depot_tools

I've chosen to put it in /opt/depot_tools, which requires chowning that dir since /opt is owned by root.

cd /opt
sudo mkdir depot_tools
sudo chown ec2-user depot_tools
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
echo 'export PATH=/opt/depot_tools:"$PATH"' >> ~/.bashrc

3. Check out repo & switch to pandafium branch

mkdir ~/repo && cd ~/repo
gclient config --unmanaged https://github.com/gradescope/pdfium.git
cd pdfium
git checkout pandafium
gclient sync

4. Configure build

build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
gn gen out/Lambda
gn args out/Lambda # (this will open an editor, settings follow)
Use these build flags:

We're disabling JS and XFA support. We're also disabling building with clang to avoid dependency hell.

use_goma = false                  # Googlers only.
is_debug = false                  # Enable debugging features.
pdf_use_skia = false              # Set true to enable experimental skia backend.

pdf_is_standalone = true          # Set for a non-embedded build.
is_component_build = false        # Disable component build (must be false)
clang_use_chrome_plugins = false  # Currently must be false.
use_sysroot = false               # Currently must be false on Linux.

pdf_enable_xfa = false            # Set false to remove XFA support (implies JS support).
pdf_enable_v8 = false             # Set false to remove Javascript support.
is_clang = false                  # Compile with gcc

5. Build

ninja -C out/Lambda

If you run into issues with missing libs, look in BUILD.gn, which will have been built, in the block starting with executable("pandafium"). You may have to set libs = [ "/usr/lib64/libjpeg.a"].