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. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 68 | |
| 69 | If the library will never be shipped as a part of Chrome (e.g. build-time tools, |
| 70 | testing tools), make sure to set "License File" as "NOT_SHIPPED" so that the |
Dirk Pranke | bf4136b | 2018-09-20 22:48:43 | [diff] [blame^] | 71 | license is not included in about:credits page ([more on this below](#credits)). |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 72 | |
| 73 | ### Modify DEPS |
| 74 | |
| 75 | If the code is applicable and will be compiled on all supported Chromium |
derat | 8171050 | 2017-02-22 17:57:55 | [diff] [blame] | 76 | platforms (Windows, Mac, Linux, Chrome OS, iOS, Android), check it in to |
Aaron Gable | 4bfae418 | 2017-12-19 00:11:01 | [diff] [blame] | 77 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/). |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 78 | |
| 79 | If the code is only applicable to certain platforms, check it in to |
| 80 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/) |
| 81 | and add an entry to the |
| 82 | [DEPS](http://src.chromium.org/viewvc/chrome/trunk/src/DEPS) file that causes |
| 83 | the code to be checked out from src/third_party into src/third_party by gclient. |
| 84 | |
| 85 | _Explanation: Checking it into src/third_party causes all developers to need to |
| 86 | check out your code. This wastes disk space cause syncing to take longer for |
| 87 | developers that don't need your code. When all platforms really do need the |
| 88 | code, checking it in to src/third_party allows some slight improvements over |
| 89 | DEPS._ |
| 90 | |
| 91 | As for specifying the path where the library is fetched, a path like |
| 92 | `src/third_party/<project_name>/src` is highly recommended so that you can put |
| 93 | the file like OWNERS or README.chromium at `third_party/<project_name>`. If you |
| 94 | have a wrong path in DEPS and want to change the path of the existing library in |
| 95 | DEPS, please ask the infrastructure team before committing the change. |
| 96 | |
zpeng | 2d0d3d8 | 2016-12-16 21:48:21 | [diff] [blame] | 97 | ### Checking in large files |
Aaron Gable | 4bfae418 | 2017-12-19 00:11:01 | [diff] [blame] | 98 | |
zpeng | 2d0d3d8 | 2016-12-16 21:48:21 | [diff] [blame] | 99 | _Accessible to Googlers only. Non-Googlers can email one of the people in |
| 100 | third_party/OWNERS for help._ |
| 101 | |
| 102 | See [Moving large files to Google Storage](https://goto.google.com/checking-in-large-files) |
| 103 | |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 104 | ## Setting up ignore |
| 105 | |
| 106 | If your code is synced via DEPS, you should add the new directory to Chromium's |
| 107 | `.gitignore`. This is necessary because Chromium's main git repository already |
| 108 | contains |
| 109 | [src/third_party](http://src.chromium.org/viewvc/chrome/trunk/src/third_party/) |
| 110 | and the project synced via DEPS is nested inside of it and its files regarded as |
| 111 | untracked. That is, anyone running `git status` from `src/` would see a clutter. |
| 112 | Your project's files are tracked by your repository, not Chromium's, so make |
| 113 | sure the directory is listed in Chromium's `.gitignore`. |
| 114 | |
| 115 | ## Get a Review |
| 116 | |
Aaron Gable | fc8cdad | 2018-01-16 21:02:40 | [diff] [blame] | 117 | All third party additions and substantive changes like re-licensing need the |
| 118 | following sign-offs. Some of these are accessible to Googlers only. Non-Googlers |
| 119 | can email one of the people in third_party/OWNERS for help. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 120 | |
Aaron Gable | fc8cdad | 2018-01-16 21:02:40 | [diff] [blame] | 121 | * Get Chrome Eng Review approval. Googlers should see |
| 122 | go/chrome-eng-review. Please include information about the additional |
| 123 | checkout size, build times, and binary sizes. Please also make sure that the |
| 124 | motivation for your project is clear, e.g., a design doc has been circulated. |
| 125 | * Get [email protected] approval. Email the list with relevant details and |
| 126 | a link to the CL. Third party code is a hot spot for security vulnerabilities. |
| 127 | When adding a new package that could potentially carry security risk, make |
| 128 | sure to highlight risk to [email protected]. You may be asked to add |
| 129 | a README.security or, in dangerous cases, README.SECURITY.URGENTLY file. |
Aaron Gable | 1170e81 | 2018-01-16 19:00:44 | [diff] [blame] | 130 | * Add [email protected] as a reviewer on your change. This |
| 131 | will trigger an automatic round-robin assignment of the review to an |
| 132 | appropriate reviewer. This list does not receive or deliver email, so only |
| 133 | use it as a reviewer, not for other communication. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 134 | |
Aaron Gable | 1170e81 | 2018-01-16 19:00:44 | [diff] [blame] | 135 | Please send separate emails to the eng review and security lists. |
jochen | 893d518 | 2017-01-31 22:01:49 | [diff] [blame] | 136 | |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 137 | Subsequent changes don't require third-party-owners approval; you can modify the |
Aaron Gable | fc8cdad | 2018-01-16 21:02:40 | [diff] [blame] | 138 | code as much as you want. When you update code, be mindful of security-related |
| 139 | mailing lists for the project and relevant CVE to update your package. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 140 | |
Aaron Gable | 4bfae418 | 2017-12-19 00:11:01 | [diff] [blame] | 141 | ## Ask the infrastructure team to add a git mirror for the dependency |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 142 | |
| 143 | Before committing the DEPS, you need to ask the infra team to create a git |
| 144 | mirror for your dependency. [Create a |
| 145 | ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git) |
| 146 | for infra and ask the infra team. |
| 147 | |
| 148 | If you are using a git repo from googlesource.com then you must ensure that the |
| 149 | repository is configured to give the build bots unlimited quota, or else the |
| 150 | builders will fail to checkout with an "Over Quota" error. [Create a |
| 151 | ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git) |
| 152 | for infra and ask the infra team what needs to be done. Note that you'll need |
| 153 | unlimited quota for at least two role accounts. See the quota status of |
| 154 | `boringssl` as an example. |
Dirk Pranke | bf4136b | 2018-09-20 22:48:43 | [diff] [blame^] | 155 | |
| 156 | ## How we ensure that the right credits are displayed {#credits} |
| 157 | |
| 158 | As we said at the beginning, it is important that Chrome displays the |
| 159 | right credit and attributions for all of the third_party code we use. |
| 160 | |
| 161 | To view this in chrome, you can open chrome://credits. |
| 162 | |
| 163 | That page displays a resource embedded in the browser as part of the |
| 164 | [//components/resources/components_resources.grd](../components/resources/components_resource.grd) |
| 165 | GRIT file; the actual HTML text is generated in the |
| 166 | [//components/resources:about_credits](../components/resources/BUILD.gn) |
| 167 | build target using a template from the output of the |
| 168 | [//tools/licenses.py](../tools/licenses.py) script. Assuming you've followed |
| 169 | the rules above to ensure that you have the proper LICENSE file and it passes |
| 170 | the checks, it'll be included automatically. |