dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 1 | # PDFium |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 2 | |
| 3 | ## Prerequisites |
| 4 | |
| 5 | Get the chromium depot tools via the instructions at |
| 6 | http://www.chromium.org/developers/how-tos/install-depot-tools (this provides |
dsinclair | 719a7a7 | 2016-05-16 08:11:18 -0700 | [diff] [blame] | 7 | the gclient utility needed below). |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 8 | |
| 9 | Also install Python, Subversion, and Git and make sure they're in your path. |
| 10 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 11 | |
weili | da4ff18 | 2016-10-31 13:19:08 -0700 | [diff] [blame] | 12 | ### Windows development |
weili | e7ca8ba | 2016-04-29 12:04:30 -0700 | [diff] [blame] | 13 | |
| 14 | PDFium uses a similar Windows toolchain as Chromium: |
| 15 | |
| 16 | #### Open source contributors |
| 17 | Visual Studio 2015 Update 2 or later is highly recommended. |
| 18 | |
| 19 | Run `set DEPOT_TOOLS_WIN_TOOLCHAIN=0`, or set that variable in your global |
| 20 | environment. |
| 21 | |
| 22 | Compilation is done through ninja, **not** Visual Studio. |
| 23 | |
weili | da4ff18 | 2016-10-31 13:19:08 -0700 | [diff] [blame] | 24 | ### CPU Architectures supported |
| 25 | |
| 26 | The default architecture for Windows, Linux, and Mac is "`x64`". On Windows, |
| 27 | "`x86`" is also supported. GN parameter "`target_cpu = "x86"`" can be used to |
| 28 | override the default value. If you specify Android build, the default CPU |
| 29 | architecture will be "`arm`". |
| 30 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 31 | |
weili | e7ca8ba | 2016-04-29 12:04:30 -0700 | [diff] [blame] | 32 | #### Google employees |
| 33 | |
| 34 | Run: `download_from_google_storage --config` and follow the |
| 35 | authentication instructions. **Note that you must authenticate with your |
| 36 | @google.com credentials**. Enter "0" if asked for a project-id. |
| 37 | |
| 38 | Once you've done this, the toolchain will be installed automatically for |
| 39 | you in [the step](#GenBuild) below. |
| 40 | |
| 41 | The toolchain will be in `depot_tools\win_toolchain\vs_files\<hash>`, and windbg |
| 42 | can be found in `depot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers`. |
| 43 | |
| 44 | If you want the IDE for debugging and editing, you will need to install |
| 45 | it separately, but this is optional and not needed for building PDFium. |
| 46 | |
| 47 | |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 48 | ## Get the code |
| 49 | |
Oliver Chang | 5a21e14 | 2015-10-21 15:19:20 -0700 | [diff] [blame] | 50 | The name of the top-level directory does not matter. In our examples, we use |
| 51 | "repo". This directory must not have been used before by `gclient config` as |
| 52 | each directory can only house a single gclient configuration. |
| 53 | |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 54 | ``` |
Oliver Chang | 5a21e14 | 2015-10-21 15:19:20 -0700 | [diff] [blame] | 55 | mkdir repo |
| 56 | cd repo |
| 57 | gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 58 | gclient sync |
Oliver Chang | 5a21e14 | 2015-10-21 15:19:20 -0700 | [diff] [blame] | 59 | cd pdfium |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 60 | ``` |
| 61 | |
weili | e7ca8ba | 2016-04-29 12:04:30 -0700 | [diff] [blame] | 62 | ##<a name="GenBuild"></a> Generate the build files |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 63 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 64 | We use GN to generate the build files and |
| 65 | [Ninja](http://martine.github.io/ninja/) (also included with the depot\_tools |
| 66 | checkout) to execute the build files. |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 67 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 68 | ``` |
| 69 | gn gen <directory> |
| 70 | ``` |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 71 | |
weili | da4ff18 | 2016-10-31 13:19:08 -0700 | [diff] [blame] | 72 | ### Selecting build configuration |
Tom Sepez | d43654a | 2016-02-04 15:36:13 -0800 | [diff] [blame] | 73 | |
| 74 | PDFium may be built either with or without JavaScript support, and with |
| 75 | or without XFA forms support. Both of these features are enabled by |
| 76 | default. Also note that the XFA feature requires JavaScript. |
| 77 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 78 | Configuration is done by executing `gn args <directory>` to configure the build. |
dsinclair | 719a7a7 | 2016-05-16 08:11:18 -0700 | [diff] [blame] | 79 | This will launch an editor in which you can set the following arguments. |
Oliver Chang | 14591ce | 2015-11-03 13:12:46 -0800 | [diff] [blame] | 80 | |
| 81 | ``` |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 82 | use_goma = true # Googlers only. |
| 83 | is_debug = true # Enable debugging features. |
| 84 | |
| 85 | pdf_use_skia = false # Set true to enable experimental skia backend. |
caryclark | af177fe | 2016-11-16 10:10:03 -0800 | [diff] [blame] | 86 | pdf_use_skia_paths = false # Set true to enable experimental skia backend (paths only). |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 87 | |
thestig | 543651f | 2016-09-01 07:11:45 -0700 | [diff] [blame] | 88 | pdf_enable_xfa = true # Set false to remove XFA support (implies JS support). |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 89 | pdf_enable_v8 = true # Set false to remove Javascript support. |
| 90 | pdf_is_standalone = true # Set for a non-embedded build. |
npm | 21ce1a6 | 2016-08-31 07:53:08 -0700 | [diff] [blame] | 91 | is_component_build = false # Disable component build (must be false) |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 92 | |
thestig | 543651f | 2016-09-01 07:11:45 -0700 | [diff] [blame] | 93 | clang_use_chrome_plugins = false # Currently must be false. |
| 94 | use_sysroot = false # Currently must be false on Linux. |
Oliver Chang | 14591ce | 2015-11-03 13:12:46 -0800 | [diff] [blame] | 95 | ``` |
| 96 | |
dsinclair | 719a7a7 | 2016-05-16 08:11:18 -0700 | [diff] [blame] | 97 | Note, you must set `pdf_is_standalone = true` if you want the sample |
| 98 | applications like `pdfium_test` to build. |
| 99 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 100 | When complete the arguments will be stored in `<directory>/args.gn`. |
| 101 | |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 102 | ## Building the code |
| 103 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 104 | If you used Ninja, you can build the sample program by: |
| 105 | `ninja -C <directory>/pdfium_test` You can build the entire product (which |
| 106 | includes a few unit tests) by: `ninja -C <directory>`. |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 107 | |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 108 | |
| 109 | ## Running the sample program |
| 110 | |
| 111 | The pdfium\_test program supports reading, parsing, and rasterizing the pages of |
dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 112 | a .pdf file to .ppm or .png output image files (windows supports two other |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 113 | formats). For example: `<directory>/pdfium_test --ppm path/to/myfile.pdf`. Note |
dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 114 | that this will write output images to `path/to/myfile.pdf.<n>.ppm`. |
| 115 | |
| 116 | ## Testing |
| 117 | |
| 118 | There are currently several test suites that can be run: |
| 119 | |
| 120 | * pdfium\_unittests |
| 121 | * pdfium\_embeddertests |
| 122 | * testing/tools/run\_corpus\_tests.py |
| 123 | * testing/tools/run\_javascript\_tests.py |
| 124 | * testing/tools/run\_pixel\_tests.py |
| 125 | |
| 126 | It is possible the tests in the `testing` directory can fail due to font |
| 127 | differences on the various platforms. These tests are reliable on the bots. If |
| 128 | you see failures, it can be a good idea to run the tests on the tip-of-tree |
| 129 | checkout to see if the same failures appear. |
Tom Sepez | 20ab023 | 2015-09-22 08:52:52 -0700 | [diff] [blame] | 130 | |
| 131 | ## Waterfall |
| 132 | |
| 133 | The current health of the source tree can be found at |
| 134 | http://build.chromium.org/p/client.pdfium/console |
| 135 | |
dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 136 | ## Community |
| 137 | |
| 138 | There are several mailing lists that are setup: |
| 139 | |
| 140 | * [PDFium](https://groups.google.com/forum/#!forum/pdfium) |
| 141 | * [PDFium Reviews](https://groups.google.com/forum/#!forum/pdfium-reviews) |
| 142 | * [PDFium Bugs](https://groups.google.com/forum/#!forum/pdfium-bugs) |
| 143 | |
| 144 | Note, the Reviews and Bugs lists are typically read-only. |
| 145 | |
| 146 | ## Bugs |
| 147 | |
dsinclair | ab522f9 | 2016-05-04 11:23:52 -0700 | [diff] [blame] | 148 | We use this |
dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 149 | [bug tracker](https://code.google.com/p/pdfium/issues/list), but for security |
| 150 | bugs, please use [Chromium's security bug template] |
| 151 | (https://code.google.com/p/chromium/issues/entry?template=Security%20Bug) |
| 152 | and add the "Cr-Internals-Plugins-PDF" label. |
| 153 | |
| 154 | ## Contributing code |
| 155 | |
| 156 | For contributing code, we will follow |
| 157 | [Chromium's process](http://dev.chromium.org/developers/contributing-code) |
tandrii | a560806 | 2016-03-24 13:11:53 -0700 | [diff] [blame] | 158 | as much as possible. The main exceptions is: |
dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 159 | |
| 160 | 1. Code has to conform to the existing style and not Chromium/Google style. |
dan sinclair | 1e27a0e | 2015-10-16 11:59:22 -0400 | [diff] [blame] | 161 | |