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