blob: 26b1c9feb23842e3c9a57fa17ac6844cda6bc9e8 [file] [log] [blame] [view]
zpeng8d6f584a2016-12-16 20:50:281# Adding third_party Libraries
2
3[TOC]
4
5Using third party code can save time and is consistent with our values - no need
6to reinvent the wheel! We put all code that isn't written by Chromium developers
Dirk Pranke568e95c2018-11-01 23:41:507into `//third_party` (even if you end up modifying just a few functions). We do
zpeng8d6f584a2016-12-16 20:50:288this to make it easy to track license compliance, security patches, and supply
9the right credit and attributions. It also makes it a lot easier for other
10projects that embed our code to track what is Chromium licensed and what is
11covered by other licenses.
12
Dirk Pranke568e95c2018-11-01 23:41:5013## Put the code in //third_party
zpeng8d6f584a2016-12-16 20:50:2814
Dirk Pranke568e95c2018-11-01 23:41:5015By default, all code should be checked into [//third_party](../third_party/),
16for the reasons given above. Other locations are only appropriate in a few
17situations and need explicit approval; don't assume that because there's some
18other directory with third_party in the name it's okay to put new things
19there.
zpeng8d6f584a2016-12-16 20:50:2820
Dirk Pranke568e95c2018-11-01 23:41:5021## Get the code
zpeng8d6f584a2016-12-16 20:50:2822
Dirk Pranke568e95c2018-11-01 23:41:5023There are two common ways to depend on third-party code: you can reference a
24Git repo directly (via entries in the DEPS file), or you can check in a
25snapshot. The former is preferable if you are actively developing in it or need
26access to the history; the latter is better if you don't need the full history
27of the repo or don't need to pick up every single change. And, of course, if
28the code you need isn't in a Git repo, you have to do the latter.
zpeng8d6f584a2016-12-16 20:50:2829
Dirk Pranke568e95c2018-11-01 23:41:5030### Pulling the code via DEPS
31
32If the code is in a Git repo that you want to mirror, please file an [infra git
33ticket](https://bugs.chromium.org/p/chromium/issues/entry?template=Infra-Git)
34to get the repo mirrored onto chromium.googlesource.com; we don't allow direct
35dependencies on non-Google-hosted repositories, so that we can still build
36if an external repository goes down..
37
38Once the mirror is set up, add an entry to [//DEPS](../DEPS) so that gclient
39will pull it in. If the code is only needed on some platforms, add a condition
40to the deps entry so that developers on other platforms don't pull in things
41they don't need.
42
43As 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
45the file like OWNERS or README.chromium at `//third_party/<project_name>`. If
46you have a wrong path in DEPS and want to change the path of the existing
47library in DEPS, please ask the infrastructure team before committing the
48change.
49
50Lastly, add the new directory to Chromium's `//.gitignore`, so that it won't
51show up as untracked files when you run `git status` on the main repository.
52
53### Checking in the code directly
54
55If you are checking in a snapshot, please describe the source in the
56README.chromium file, described below. For security reasons, please retrieve
57the code as securely as you can, using HTTPS and GPG signatures if available.
58If retrieving a tarball, please do not check the tarball itself into the tree,
59but do list the source and the SHA-512 hash (for verification) in the
60README.chromium and Change List. The SHA-512 hash can be computed via
61`sha512sum` or `openssl dgst -sha512`. If retrieving from a git
62repository, please list the revision that the code was pulled from.
63
64If you are checking the files in directly, you do not need an entry in DEPS
65and 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
70third_party/OWNERS for help.
71
72See [Moving large files to Google Storage](https://goto.google.com/checking-in-large-files)
73
74## Document the code's context
zpeng8d6f584a2016-12-16 20:50:2875
76### Add OWNERS
77
78Your OWNERS file must include 2 Chromium developer accounts. This will ensure
79accountability for maintenance of the code over time. While there isn't always
80an ideal or obvious set of people that should go in OWNERS, this is critical for
81first-line triage of any issues that crop up in the code.
82
83As 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
93You need a README.chromium file with information about the project from which
94you're re-using code. See
Dirk Pranke568e95c2018-11-01 23:41:5095[//third_party/README.chromium.template](../third_party/README.chromium.template)
zpeng8d6f584a2016-12-16 20:50:2896for a list of fields to include. A presubmit check will check this has the right
97format.
98
Dirk Pranke568e95c2018-11-01 23:41:5099README.chromium files contain a field indicating whether the package is
100security-critical or not. A package is security-critical if it is compiled
101into 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
zpeng8d6f584a2016-12-16 20:50:28109### Add a LICENSE file and run related checks
110
111You need a LICENSE file. Example:
Dirk Pranke568e95c2018-11-01 23:41:50112[//third_party/libjpeg/LICENSE](../third_party/libjpeg/LICENSE).
zpeng8d6f584a2016-12-16 20:50:28113
Dirk Pranke568e95c2018-11-01 23:41:50114Run `//tools/licenses.py scan`; this will complain about incomplete or missing
115data for third_party checkins. We use `licenses.py credits` to generate the
116about:credits page in Google Chrome builds.
zpeng8d6f584a2016-12-16 20:50:28117
118If the library will never be shipped as a part of Chrome (e.g. build-time tools,
119testing tools), make sure to set "License File" as "NOT_SHIPPED" so that the
Dirk Prankebf4136b2018-09-20 22:48:43120license is not included in about:credits page ([more on this below](#credits)).
zpeng8d6f584a2016-12-16 20:50:28121
Dirk Pranke568e95c2018-11-01 23:41:50122## Get a review
zpeng8d6f584a2016-12-16 20:50:28123
Aaron Gablefc8cdad2018-01-16 21:02:40124All third party additions and substantive changes like re-licensing need the
Dirk Pranke568e95c2018-11-01 23:41:50125following sign-offs. Some of these are accessible to Googlers only.
126Non-Googlers can email one of the people in
127[//third_party/OWNERS](../third_party/OWNERS) for help.
zpeng8d6f584a2016-12-16 20:50:28128
Aaron Gablefc8cdad2018-01-16 21:02:40129* 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 Pranke6fb90c02018-10-17 02:02:20138* Add [email protected] as a reviewer on your change. This
Adam Langley88658b32018-11-20 22:12:47139 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.
zpeng8d6f584a2016-12-16 20:50:28146
Dirk Pranke6fb90c02018-10-17 02:02:20147Please send separate emails to the eng review and security lists.
jochen893d5182017-01-31 22:01:49148
Dirk Pranke568e95c2018-11-01 23:41:50149Subsequent changes don't normally require third-party-owners or security
150approval; you can modify the code as much as you want. When you update code, be
151mindful of security-related mailing lists for the project and relevant CVE to
152update your package.
Dirk Prankebf4136b2018-09-20 22:48:43153
154## How we ensure that the right credits are displayed {#credits}
155
156As we said at the beginning, it is important that Chrome displays the
157right credit and attributions for all of the third_party code we use.
158
159To view this in chrome, you can open chrome://credits.
160
161That page displays a resource embedded in the browser as part of the
162[//components/resources/components_resources.grd](../components/resources/components_resource.grd)
163GRIT file; the actual HTML text is generated in the
164[//components/resources:about_credits](../components/resources/BUILD.gn)
165build target using a template from the output of the
166[//tools/licenses.py](../tools/licenses.py) script. Assuming you've followed
167the rules above to ensure that you have the proper LICENSE file and it passes
168the checks, it'll be included automatically.