zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 1 | # Adding third_party Libraries |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | Using third party code can save time and is consistent with our values - no need |
| 6 | to reinvent the wheel! We put all code that isn't written by Chromium developers |
| 7 | into src/third_party (even if you end up modifying just a few functions). We do |
| 8 | this to make it easy to track license compliance, security patches, and supply |
| 9 | the right credit and attributions. It also makes it a lot easier for other |
| 10 | projects that embed our code to track what is Chromium licensed and what is |
| 11 | covered by other licenses. |
| 12 | |
| 13 | ## Get the Code |
| 14 | |
| 15 | When you find code you want to use, get it. This often means downloading: from |
| 16 | Sourceforge, from the hosting feature of Google Code, or from somewhere else. |
| 17 | Sometimes it can mean negotiating a license with another company and receiving |
| 18 | the code another way. Please describe the source in the README.chromium file, |
| 19 | described below. For security reasons, please retrieve the code as securely as |
| 20 | you can, using HTTPS and GPG signatures if available. If retrieving a tarball, |
| 21 | please do not check the tarball itself into the tree, but do list the source and |
| 22 | the SHA-512 hash (for verification) in the README.chromium and Change List. The |
| 23 | SHA-512 hash can be computed via the `shasum (sha512sum)` or `openssl` |
| 24 | utilities. If retrieving from a git repository, please list the SHA-512 hash. |
| 25 | |
| 26 | ## Put the Code in (the right) third_party |
| 27 | |
| 28 | By default, all code should be checked into |
| 29 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/). |
| 30 | It is OK to have third_party subdirectories that are not top-level (e.g. |
| 31 | src/net/third_party), but don't add more third_party directories than necessary. |
| 32 | |
| 33 | ## Document the Code's Context |
| 34 | |
| 35 | ### Add OWNERS |
| 36 | |
| 37 | Your OWNERS file must include 2 Chromium developer accounts. This will ensure |
| 38 | accountability for maintenance of the code over time. While there isn't always |
| 39 | an ideal or obvious set of people that should go in OWNERS, this is critical for |
| 40 | first-line triage of any issues that crop up in the code. |
| 41 | |
| 42 | As an OWNER, you're expected to: |
| 43 | |
| 44 | * Remove the dependency when/if it is no longer needed |
| 45 | * Update the dependency when a security or stability bug is fixed upstream |
| 46 | * Help ensure the Chrome feature that uses the dependency continues to use the |
| 47 | dependency in the best way, as the feature and the dependency change over |
| 48 | time. |
| 49 | |
| 50 | ### Add a README.chromium |
| 51 | |
| 52 | You need a README.chromium file with information about the project from which |
| 53 | you're re-using code. See |
| 54 | [README.chromium.template](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/README.chromium.template) |
| 55 | for a list of fields to include. A presubmit check will check this has the right |
| 56 | format. |
| 57 | |
| 58 | ### Add a LICENSE file and run related checks |
| 59 | |
| 60 | You need a LICENSE file. Example: |
| 61 | [third_party/libjpeg/LICENSE](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/libjpeg/LICENSE?revision=42288&view=markup). |
| 62 | |
| 63 | Run the following scripts: |
| 64 | |
| 65 | * `src/tools/licenses.py scan` - This will complain about incomplete or missing |
| 66 | data for third_party checkins. We use 'licenses.py credits' to generate the |
| 67 | about:credits page in Google Chrome builds. |
| 68 | * `src/tools/checklicenses/checklicenses.py` - See below for info how to handle |
| 69 | possible failures. |
| 70 | * If you are adding code that will be present in the content layer, please make |
| 71 | sure that the license used is compliant with Android tree requirements because |
| 72 | this code will also be used in Android WebView. You need to run |
| 73 | `src/android_webview/tools/webview_licenses.py scan` |
| 74 | |
| 75 | See the ["Odds n' Ends"](adding_to_third_party.md#Odds-n_Ends) Section below if |
| 76 | you run into any failures running these. |
| 77 | |
| 78 | If the library will never be shipped as a part of Chrome (e.g. build-time tools, |
| 79 | testing tools), make sure to set "License File" as "NOT_SHIPPED" so that the |
| 80 | license is not included in about:credits page. |
| 81 | |
| 82 | ### Modify DEPS |
| 83 | |
| 84 | If the code is applicable and will be compiled on all supported Chromium |
derat | 8171050 | 2017-02-22 17:57:55 | [diff] [blame^] | 85 | platforms (Windows, Mac, Linux, Chrome OS, iOS, Android), check it in to |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 86 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/). |
| 87 | |
| 88 | If the code is only applicable to certain platforms, check it in to |
| 89 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/) |
| 90 | and add an entry to the |
| 91 | [DEPS](http://src.chromium.org/viewvc/chrome/trunk/src/DEPS) file that causes |
| 92 | the code to be checked out from src/third_party into src/third_party by gclient. |
| 93 | |
| 94 | _Explanation: Checking it into src/third_party causes all developers to need to |
| 95 | check out your code. This wastes disk space cause syncing to take longer for |
| 96 | developers that don't need your code. When all platforms really do need the |
| 97 | code, checking it in to src/third_party allows some slight improvements over |
| 98 | DEPS._ |
| 99 | |
| 100 | As for specifying the path where the library is fetched, a path like |
| 101 | `src/third_party/<project_name>/src` is highly recommended so that you can put |
| 102 | the file like OWNERS or README.chromium at `third_party/<project_name>`. If you |
| 103 | have a wrong path in DEPS and want to change the path of the existing library in |
| 104 | DEPS, please ask the infrastructure team before committing the change. |
| 105 | |
zpeng | 2d0d3d8 | 2016-12-16 21:48:21 | [diff] [blame] | 106 | ### Checking in large files |
| 107 | _Accessible to Googlers only. Non-Googlers can email one of the people in |
| 108 | third_party/OWNERS for help._ |
| 109 | |
| 110 | See [Moving large files to Google Storage](https://goto.google.com/checking-in-large-files) |
| 111 | |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 112 | ## Setting up ignore |
| 113 | |
| 114 | If your code is synced via DEPS, you should add the new directory to Chromium's |
| 115 | `.gitignore`. This is necessary because Chromium's main git repository already |
| 116 | contains |
| 117 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/) |
| 118 | and the project synced via DEPS is nested inside of it and its files regarded as |
| 119 | untracked. That is, anyone running `git status` from `src/` would see a clutter. |
| 120 | Your project's files are tracked by your repository, not Chromium's, so make |
| 121 | sure the directory is listed in Chromium's `.gitignore`. |
| 122 | |
| 123 | ## Get a Review |
| 124 | |
| 125 | All third party additions and substantive changes like re-licensing need the |
| 126 | following sign-offs. Some of these are accessible to Googlers only. Non-Googlers |
| 127 | can email one of the people in third_party/OWNERS for help. |
| 128 | |
jochen | 893d518 | 2017-01-31 22:01:49 | [diff] [blame] | 129 | * Chrome Eng Review. Googlers should see go/chrome-eng-review (please include information about the additional checkout size, build times, and binary sizes. Please also make sure that the motivation for your project is clear, e.g., a design doc has been circulated). |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 130 | * [email protected] (ping the list with relevant |
| 131 | details and a link to the CL). |
| 132 | * [email protected] (ping the list with relevant details and a link to the |
| 133 | CL). |
| 134 | |
jochen | 893d518 | 2017-01-31 22:01:49 | [diff] [blame] | 135 | Please send separate emails to the three lists. |
| 136 | |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 137 | Third party code is a hot spot for security vulnerabilities. When adding a new |
| 138 | package that could potentially carry security risk, make sure to highlight risk |
| 139 | to [email protected]. You may be asked to add a README.security or, in |
| 140 | dangerous cases, README.SECURITY.URGENTLY file. When you update your code, be |
| 141 | mindful of security-related mailing lists for the project and relevant CVE to |
| 142 | update your package. |
| 143 | |
| 144 | Subsequent changes don't require third-party-owners approval; you can modify the |
| 145 | code as much as you want. |
| 146 | |
| 147 | ## Ask the infrastructure team to add a git mirror for the dependency (or |
| 148 | configure the git repo, if using googlesource.com) |
| 149 | |
| 150 | Before committing the DEPS, you need to ask the infra team to create a git |
| 151 | mirror for your dependency. [Create a |
| 152 | ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git) |
| 153 | for infra and ask the infra team. |
| 154 | |
| 155 | If you are using a git repo from googlesource.com then you must ensure that the |
| 156 | repository is configured to give the build bots unlimited quota, or else the |
| 157 | builders will fail to checkout with an "Over Quota" error. [Create a |
| 158 | ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git) |
| 159 | for infra and ask the infra team what needs to be done. Note that you'll need |
| 160 | unlimited quota for at least two role accounts. See the quota status of |
| 161 | `boringssl` as an example. |
| 162 | |
| 163 | ## Odds n' Ends |
| 164 | |
| 165 | ### Handling `licenses_check (checklicenses.py)` failures |
| 166 | |
| 167 | This is needed for [Issue |
| 168 | 28291](http://code.google.com/p/chromium/issues/detail?id=28291): Pass the |
| 169 | Ubuntu license check script: |
| 170 | |
| 171 | __If the failure looks like ... ... the right action is to ... __ |
| 172 | |
| 173 | * 'filename' has non-whitelisted license 'UNKNOWN' |
| 174 | * Ideally make the licensecheck.pl script recognize the license of that |
| 175 | file. Often this requires __adding a license header__. Does it have |
| 176 | license header? If it's third party code, ask the upstream project to make |
| 177 | sure all their files have license headers. If the license header is there |
| 178 | but is not recognized, we should try to patch licensecheck.pl. If in |
| 179 | doubt please contact [email protected] |
| 180 | * 'filename' has non-whitelisted license 'X' and X is BSD-compatible |
| 181 | * Add the license X to WHITELISTED_LICENSES in checklicenses.py . Make sure |
| 182 | to respect the OWNERS of that file. You must get an approval before |
| 183 | landing. CLs violating this requirement may be reverted. |
| 184 | * 'filename' has non-whitelisted license 'X' and X is not BSD-compatible (i.e. |
| 185 | GPL) |
| 186 | * Do you really need to add those files? Chromium is BSD-licensed so the |
| 187 | resulting binaries can't use GPL code. Ideally we just shouldn't have |
| 188 | those files at all in the tree. If in doubt, please ask [email protected] |
| 189 | |
| 190 | ### Handling `webview_licenses.py` failures |
| 191 | |
| 192 | __If the failure looks like ... ... the right action is to ... __ |
| 193 | |
| 194 | * Missing license file |
| 195 | * Make sure that the license file is present. It should be called 'LICENSE', |
| 196 | or otherwise README.chromium file must point to it explicitly. |
| 197 | * The following files contain a third-party license but are not in a listed |
| 198 | third-party directory... |
| 199 | * Check if it's a false positive (e.g. 'copyright' word used in a string |
| 200 | literal), if so, update |
| 201 | [src/tools/copyright_scanner/third_party_files_whitelist.txt](https://code.google.com/p/chromium/codesearch#chromium/src/tools/copyright_scanner/third_party_files_whitelist.txt) |
| 202 | file. Otherwise, please move the code into third_party. |