1# PDFium 2 3## Prerequisites 4 5Get the chromium depot tools via the instructions at 6http://www.chromium.org/developers/how-tos/install-depot-tools (this provides 7the gclient utility needed below). 8 9Also install Python, Subversion, and Git and make sure they're in your path. 10 11 12### Windows development 13 14PDFium uses the same build tool as Chromium: 15 16#### Open source contributors 17Please refer to [Chromium's Visual Studio set up](https://chromium.googlesource.com/chromium/src/+/master/docs/windows_build_instructions.md#visual-studio) 18for requirements and instructions on build environment configuration. 19 20Run `set DEPOT_TOOLS_WIN_TOOLCHAIN=0`, or set that variable in your global 21environment. 22 23Compilation is done through ninja, **not** Visual Studio. 24 25### CPU Architectures supported 26 27The default architecture for Windows, Linux, and Mac is "`x64`". On Windows, 28"`x86`" is also supported. GN parameter "`target_cpu = "x86"`" can be used to 29override the default value. If you specify Android build, the default CPU 30architecture will be "`arm`". 31 32It is expected that there are still some places lurking in the code which will 33not function properly on big-endian architectures. Bugs and/or patches are 34welcome, however providing this support is **not** a priority at this time. 35 36#### Google employees 37 38Run: `download_from_google_storage --config` and follow the 39authentication instructions. **Note that you must authenticate with your 40@google.com credentials**. Enter "0" if asked for a project-id. 41 42Once you've done this, the toolchain will be installed automatically for 43you in the [Generate the build files](#GenBuild) step below. 44 45The toolchain will be in `depot_tools\win_toolchain\vs_files\<hash>`, and windbg 46can be found in `depot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers`. 47 48If you want the IDE for debugging and editing, you will need to install 49it separately, but this is optional and not needed for building PDFium. 50 51## Get the code 52 53The name of the top-level directory does not matter. In our examples, we use 54"repo". This directory must not have been used before by `gclient config` as 55each directory can only house a single gclient configuration. 56 57``` 58mkdir repo 59cd repo 60gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git 61gclient sync 62cd pdfium 63``` 64 65Additional build dependencies need to be installed by running: 66 67``` 68./build/install-build-deps.sh 69``` 70 71## Generate the build files 72 73We use GN to generate the build files and 74[Ninja](http://martine.github.io/ninja/) 75to execute the build files. Both of these are included with the 76depot\_tools checkout. 77 78### Selecting build configuration 79 80PDFium may be built either with or without JavaScript support, and with 81or without XFA forms support. Both of these features are enabled by 82default. Also note that the XFA feature requires JavaScript. 83 84Configuration is done by executing `gn args <directory>` to configure the build. 85This will launch an editor in which you can set the following arguments. 86A typical `<directory>` name is `out/Debug`. 87 88``` 89use_goma = true # Googlers only. Make sure goma is installed and running first. 90is_debug = true # Enable debugging features. 91 92pdf_use_skia = false # Set true to enable experimental skia backend. 93pdf_use_skia_paths = false # Set true to enable experimental skia backend (paths only). 94 95pdf_enable_xfa = true # Set false to remove XFA support (implies JS support). 96pdf_enable_v8 = true # Set false to remove Javascript support. 97pdf_is_standalone = true # Set for a non-embedded build. 98is_component_build = false # Disable component build (must be false) 99 100clang_use_chrome_plugins = false # Currently must be false. 101``` 102 103Note, you must set `pdf_is_standalone = true` if you want the sample 104applications like `pdfium_test` to build. 105 106When complete the arguments will be stored in `<directory>/args.gn`, and 107GN will automatically use the new arguments to generate build files. 108Should your files fail to generate, please double-check that you have set 109use\_sysroot as indicated above. 110 111## Building the code 112 113You can build the sample program by running: `ninja -C <directory> pdfium_test` 114You can build the entire product (which includes a few unit tests) by running: 115`ninja -C <directory> pdfium_all`. 116 117## Running the sample program 118 119The pdfium\_test program supports reading, parsing, and rasterizing the pages of 120a .pdf file to .ppm or .png output image files (windows supports two other 121formats). For example: `<directory>/pdfium_test --ppm path/to/myfile.pdf`. Note 122that this will write output images to `path/to/myfile.pdf.<n>.ppm`. 123 124## Testing 125 126There are currently several test suites that can be run: 127 128 * pdfium\_unittests 129 * pdfium\_embeddertests 130 * testing/tools/run\_corpus\_tests.py 131 * testing/tools/run\_javascript\_tests.py 132 * testing/tools/run\_pixel\_tests.py 133 134It is possible the tests in the `testing` directory can fail due to font 135differences on the various platforms. These tests are reliable on the bots. If 136you see failures, it can be a good idea to run the tests on the tip-of-tree 137checkout to see if the same failures appear. 138 139## Code Coverage 140 141Code coverage reports for PDFium can be generated in Linux development 142environments. Details can be found [here](/docs/code-coverage.md). 143 144## Waterfall 145 146The current health of the source tree can be found at 147http://build.chromium.org/p/client.pdfium/console 148 149## Community 150 151There are several mailing lists that are setup: 152 153 * [PDFium](https://groups.google.com/forum/#!forum/pdfium) 154 * [PDFium Reviews](https://groups.google.com/forum/#!forum/pdfium-reviews) 155 * [PDFium Bugs](https://groups.google.com/forum/#!forum/pdfium-bugs) 156 157Note, the Reviews and Bugs lists are typically read-only. 158 159## Bugs 160 161 We use this 162[bug tracker](https://code.google.com/p/pdfium/issues/list), but for security 163bugs, please use [Chromium's security bug template] 164(https://code.google.com/p/chromium/issues/entry?template=Security%20Bug) 165and add the "Cr-Internals-Plugins-PDF" label. 166 167## Contributing code 168 169For contributing code, we will follow 170[Chromium's process](http://dev.chromium.org/developers/contributing-code) 171as much as possible. The main exceptions are: 172 1731. Code has to conform to the existing style and not Chromium/Google style. 1742. PDFium uses a different tool for code reviews, and credentials for 175the tool need to be generated before uploading a CL. 1763. PDFium is currently holding at C++11 compatibility, rejecting features that 177are only present in C++14 (onto which Chromium is now slowly moving). 178