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 |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 7 | into `//third_party` (even if you end up modifying just a few functions). We do |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 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 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 13 | ## Put the code in //third_party |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 14 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 15 | By default, all code should be checked into [//third_party](../third_party/), |
| 16 | for the reasons given above. Other locations are only appropriate in a few |
| 17 | situations and need explicit approval; don't assume that because there's some |
| 18 | other directory with third_party in the name it's okay to put new things |
| 19 | there. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 20 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 21 | ## Get the code |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 22 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 23 | There are two common ways to depend on third-party code: you can reference a |
| 24 | Git repo directly (via entries in the DEPS file), or you can check in a |
| 25 | snapshot. The former is preferable if you are actively developing in it or need |
| 26 | access to the history; the latter is better if you don't need the full history |
| 27 | of the repo or don't need to pick up every single change. And, of course, if |
| 28 | the code you need isn't in a Git repo, you have to do the latter. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 29 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 30 | ### Pulling the code via DEPS |
| 31 | |
| 32 | If the code is in a Git repo that you want to mirror, please file an [infra git |
| 33 | ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git) |
| 34 | to get the repo mirrored onto chromium.googlesource.com; we don't allow direct |
| 35 | dependencies on non-Google-hosted repositories, so that we can still build |
| 36 | if an external repository goes down.. |
| 37 | |
| 38 | Once the mirror is set up, add an entry to [//DEPS](../DEPS) so that gclient |
| 39 | will pull it in. If the code is only needed on some platforms, add a condition |
| 40 | to the deps entry so that developers on other platforms don't pull in things |
| 41 | they don't need. |
| 42 | |
| 43 | As for specifying the path where the library is fetched, a path like |
| 44 | `//third_party/<project_name>/src` is highly recommended so that you can put |
| 45 | the file like OWNERS or README.chromium at `//third_party/<project_name>`. If |
| 46 | you have a wrong path in DEPS and want to change the path of the existing |
| 47 | library in DEPS, please ask the infrastructure team before committing the |
| 48 | change. |
| 49 | |
| 50 | Lastly, add the new directory to Chromium's `//.gitignore`, so that it won't |
| 51 | show up as untracked files when you run `git status` on the main repository. |
| 52 | |
| 53 | ### Checking in the code directly |
| 54 | |
| 55 | If you are checking in a snapshot, please describe the source in the |
| 56 | README.chromium file, described below. For security reasons, please retrieve |
| 57 | the code as securely as you can, using HTTPS and GPG signatures if available. |
| 58 | If retrieving a tarball, please do not check the tarball itself into the tree, |
| 59 | but do list the source and the SHA-512 hash (for verification) in the |
| 60 | README.chromium and Change List. The SHA-512 hash can be computed via |
| 61 | `sha512sum` or `openssl dgst -sha512`. If retrieving from a git |
| 62 | repository, please list the revision that the code was pulled from. |
| 63 | |
| 64 | If you are checking the files in directly, you do not need an entry in DEPS |
| 65 | and do not need to modify `//.gitignore`. |
| 66 | |
| 67 | ### Checking in large files |
| 68 | |
| 69 | _Accessible to Googlers only. Non-Googlers can email one of the people in |
| 70 | third_party/OWNERS for help. |
| 71 | |
| 72 | See [Moving large files to Google Storage](https://goto.google.com/checking-in-large-files) |
| 73 | |
| 74 | ## Document the code's context |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 75 | |
| 76 | ### Add OWNERS |
| 77 | |
| 78 | Your OWNERS file must include 2 Chromium developer accounts. This will ensure |
| 79 | accountability for maintenance of the code over time. While there isn't always |
| 80 | an ideal or obvious set of people that should go in OWNERS, this is critical for |
| 81 | first-line triage of any issues that crop up in the code. |
| 82 | |
| 83 | As an OWNER, you're expected to: |
| 84 | |
| 85 | * Remove the dependency when/if it is no longer needed |
| 86 | * Update the dependency when a security or stability bug is fixed upstream |
| 87 | * Help ensure the Chrome feature that uses the dependency continues to use the |
| 88 | dependency in the best way, as the feature and the dependency change over |
| 89 | time. |
| 90 | |
| 91 | ### Add a README.chromium |
| 92 | |
| 93 | You need a README.chromium file with information about the project from which |
| 94 | you're re-using code. See |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 95 | [//third_party/README.chromium.template](../third_party/README.chromium.template) |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 96 | for a list of fields to include. A presubmit check will check this has the right |
| 97 | format. |
| 98 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 99 | README.chromium files contain a field indicating whether the package is |
| 100 | security-critical or not. A package is security-critical if it is compiled |
| 101 | into the product and does any of the following: |
| 102 | |
| 103 | * Accepts untrustworthy inputs from the internet |
| 104 | * Parses or interprets complex input formats |
| 105 | * Sends data to internet servers |
| 106 | * Collects new data |
| 107 | * Influences or sets security-related policy (including the user experience) |
| 108 | |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 109 | ### Add a LICENSE file and run related checks |
| 110 | |
| 111 | You need a LICENSE file. Example: |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 112 | [//third_party/libjpeg/LICENSE](../third_party/libjpeg/LICENSE). |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 113 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 114 | Run `//tools/licenses.py scan`; this will complain about incomplete or missing |
| 115 | data for third_party checkins. We use `licenses.py credits` to generate the |
| 116 | about:credits page in Google Chrome builds. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 117 | |
| 118 | If the library will never be shipped as a part of Chrome (e.g. build-time tools, |
| 119 | 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] | 120 | license is not included in about:credits page ([more on this below](#credits)). |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 121 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 122 | ## Get a review |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 123 | |
Aaron Gable | fc8cdad | 2018-01-16 21:02:40 | [diff] [blame] | 124 | All third party additions and substantive changes like re-licensing need the |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 125 | following sign-offs. Some of these are accessible to Googlers only. |
| 126 | Non-Googlers can email one of the people in |
| 127 | [//third_party/OWNERS](../third_party/OWNERS) for help. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 128 | |
Aaron Gable | fc8cdad | 2018-01-16 21:02:40 | [diff] [blame] | 129 | * Get Chrome Eng Review approval. Googlers should see |
| 130 | go/chrome-eng-review. Please include information about the additional |
| 131 | checkout size, build times, and binary sizes. Please also make sure that the |
| 132 | motivation for your project is clear, e.g., a design doc has been circulated. |
| 133 | * Get [email protected] approval. Email the list with relevant details and |
| 134 | a link to the CL. Third party code is a hot spot for security vulnerabilities. |
| 135 | When adding a new package that could potentially carry security risk, make |
| 136 | sure to highlight risk to [email protected]. You may be asked to add |
| 137 | a README.security or, in dangerous cases, README.SECURITY.URGENTLY file. |
Dirk Pranke | 6fb90c0 | 2018-10-17 02:02:20 | [diff] [blame] | 138 | * Add [email protected] as a reviewer on your change. This |
Adam Langley | 88658b3 | 2018-11-20 22:12:47 | [diff] [blame] | 139 | will trigger an automatic round-robin assignment to a reviewer who will check |
| 140 | licensing matters. These reviewers may not be able to +1 a change so look for |
| 141 | verbal approval in the comments. (This list does not receive or deliver |
| 142 | email, so only use it as a reviewer, not for other communication. Internally, |
| 143 | see cl/221704656 for details about how this is configured.) |
| 144 | * Lastly, if all other steps are complete, get a positive code review from a |
| 145 | member of [//third_party/OWNERS](../third_party/OWNERS) to land the change. |
zpeng | 8d6f584a | 2016-12-16 20:50:28 | [diff] [blame] | 146 | |
Dirk Pranke | 6fb90c0 | 2018-10-17 02:02:20 | [diff] [blame] | 147 | Please send separate emails to the eng review and security lists. |
jochen | 893d518 | 2017-01-31 22:01:49 | [diff] [blame] | 148 | |
Dirk Pranke | 568e95c | 2018-11-01 23:41:50 | [diff] [blame] | 149 | Subsequent changes don't normally require third-party-owners or security |
| 150 | approval; you can modify the code as much as you want. When you update code, be |
| 151 | mindful of security-related mailing lists for the project and relevant CVE to |
| 152 | update your package. |
Dirk Pranke | bf4136b | 2018-09-20 22:48:43 | [diff] [blame] | 153 | |
| 154 | ## How we ensure that the right credits are displayed {#credits} |
| 155 | |
| 156 | As we said at the beginning, it is important that Chrome displays the |
| 157 | right credit and attributions for all of the third_party code we use. |
| 158 | |
| 159 | To view this in chrome, you can open chrome://credits. |
| 160 | |
| 161 | That page displays a resource embedded in the browser as part of the |
| 162 | [//components/resources/components_resources.grd](../components/resources/components_resource.grd) |
| 163 | GRIT file; the actual HTML text is generated in the |
| 164 | [//components/resources:about_credits](../components/resources/BUILD.gn) |
| 165 | build target using a template from the output of the |
| 166 | [//tools/licenses.py](../tools/licenses.py) script. Assuming you've followed |
| 167 | the rules above to ensure that you have the proper LICENSE file and it passes |
| 168 | the checks, it'll be included automatically. |