blob: 98b34dde7a3dbccef7e1ea6000a7671a2e392bf8 [file] [log] [blame] [view]
Yang Guo03e780e2020-06-17 10:18:091# Workflows
2
3## Checkouts
4
5In order to make changes to DevTools frontend, build, run, test, and submit changes, several workflows exist. Having [depot_tools](https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up) set up is a common prerequisite.
6
7### Standalone checkout
8
9As a standalone project, Chrome DevTools frontend can be checked out and built independently from Chromium. The main advantage is not having to check out and build Chromium.
10
11However, to run layout tests, you need to use the [integrated checkout](#Integrated-checkout).
12
13#### Checking out source
14
15To check out the source for DevTools frontend only, follow these steps:
16
17```bash
18mkdir devtools
19cd devtools
20fetch devtools-frontend
21```
22
23#### Build
24
25To build, follow these steps:
26
27```bash
28cd devtools-frontend
29gn gen out/Default
30autoninja -C out/Default
31```
32
Tim van der Lippef407ef22021-02-04 13:56:3833The resulting build artifacts can be found in `out/Default/gen/front_end`.
Yang Guo03e780e2020-06-17 10:18:0934
35#### Update to latest
36
37To update to latest tip of tree version:
38
39```bash
40git fetch origin
41git checkout origin/master
42gclient sync
43```
44
45#### Run in a pre-built Chromium
46
47You can run a [build](#Build) of DevTools frontend in a pre-built Chromium in order to avoid the expensive Chromium build. For example, you can use the latest version of Chrome Canary, or the downloaded binary in `third_party/chrome`.
48
49##### Running from file system
50
51This works with Chromium 79 or later.
52**(Requires `brew install coreutils` on Mac.)**
53
54```bash
Tim van der Lippef407ef22021-02-04 13:56:3855<path-to-chrome>/chrome --custom-devtools-frontend=file://$(realpath out/Default/gen/front_end)
Yang Guo03e780e2020-06-17 10:18:0956```
57
Tim van der Lippef407ef22021-02-04 13:56:3858Note that `$(realpath out/Default/gen/front_end)` expands to the absolute path to build artifacts for DevTools frontend.
Yang Guo03e780e2020-06-17 10:18:0959
60Open DevTools via F12 on Windows/Linux or Cmd+Option+I on Mac.
61
Jan Scheffler698810c2020-10-28 10:17:1662If you get errors along the line of `Uncaught TypeError: Cannot read property 'setInspectedTabId'` you probably specified an incorrect path - the path has to be absolute. On Mac and Linux, the file url will start with __three__ slashes: `file:///Users/...`.
63
Yang Guo03e780e2020-06-17 10:18:0964Tip: You can inspect DevTools with DevTools by undocking DevTools and then opening a second instance of DevTools (F12 on Windows/Linux, Cmd+Option+I on Mac).
65
66##### Running from remote URL
67
68This works with Chromium 85 or later.
69
Tim van der Lippef407ef22021-02-04 13:56:3870Serve the content of `out/Default/gen/front_end` on a web server, e.g. via `python -m http.server`.
Yang Guo03e780e2020-06-17 10:18:0971
72Then point to that web server when starting Chromium, for example:
73
74```bash
75<path-to-chrome>/chrome --custom-devtools-frontend=http://localhost:8000/
76```
77
78Open DevTools via F12 on Windows/Linux or Cmd+Option+I on Mac.
79
80##### Running in hosted mode
81
Tim van der Lippef407ef22021-02-04 13:56:3882Serve the content of `out/Default/gen/front_end` on a web server, e.g. via `python -m http.server`.
Yang Guo03e780e2020-06-17 10:18:0983
84Then point to that web server when starting Chromium, for example:
85
86```bash
87<path-to-chrome>/chrome --custom-devtools-frontend=http://localhost:8000/ --remote-debugging-port=9222
88```
89
90In a regular Chrome tab, go to the URL `http://localhost:9222#custom=true`. It lists URLs that can be copied to new Chrome tabs to inspect individual debug targets.
91
92### Integrated checkout
93
94The integrated workflow offers the best of both worlds, and allows for working on both Chromium and DevTools frontend side-by-side. This is strongly recommended for folks working primarily on DevTools.
95
96This workflow will ensure that your local setup is equivalent to how Chromium infrastructure tests your change. It comes in two flavors.
97
98A full [Chromium checkout](#Chromium-checkout) is a pre-requisite for the following steps.
99
100#### Remove existing devtools-frontend sub-repository
101
102First, you need to remove the existing devtools-frontend sub-repo from the Chromium checkout in `chromium/src/`.
103
104In `chromium/src`, run `gclient sync` to make sure you have installed all required submodules.
105
106```bash
107gclient sync
108```
109
110Then, disable `gclient sync` for DevTools frontend inside of Chromium by editing `.gclient` config. From `chromium/src/`, run
111
112```bash
113vim $(gclient root)/.gclient
114```
115
116In the `custom_deps` section, insert this line:
117
118```python
119"src/third_party/devtools-frontend/src": None,
120```
121
122Then run
123
124```bash
125gclient sync -D
126```
127
128This removes the DevTools frontend dependency. We now create a symlink to refer to the standalone checkout (execute in `chromium/src` and make sure that `third_party/devtools-frontend` exists):
129
130**(Note that the folder names do NOT include the trailing slash)**
131
132Following this step, there are two approaches to integrating the standalone devtools.
133
134#### Flavor 1: separate gclient projects
135
136The first approach is to have separate gclient projects, one for each repository, and manually
137create a symlink. First, get a checkout of [DevTools frontend](#Standalone-checkout).
138
139To then create the symlink:
140
141```bash
142ln -s path/to/standalone/devtools-frontend third_party/devtools-frontend/src
143```
144
145Running `gclient sync` in `chromium/src/` will update dependencies for the Chromium checkout.
146Running `gclient sync` in `chromium/src/third_party/devtools-frontend/src` will update dependencies for the standalone checkout.
147
148#### Flavor 2: a single gclient project
149
150The second approach is to have a single gclient project that automatically gclient sync's all dependencies for both repositories
151
152After removing your devtools dependency, modify the .gclient file for `chromium/src`
153to add the devtools project and a hook to automatically symlink (comments are optional):
154
155```python
156solutions = [
157 {
158 # Chromium src project
159 "url": "https://chromium.googlesource.com/chromium/src.git",
160 "managed": False,
161 "name": "src",
162 "custom_deps": {
163 "src/third_party/devtools-frontend/src": None,
164 },
165 "custom_vars": {},
166 },
167 {
168 # devtools-frontend project
169 "name": "devtools-frontend",
170 "url": "https://chromium.googlesource.com/devtools/devtools-frontend",
171 "custom_deps": {}
172 }
173]
174```
175
176Run `gclient sync` once in `chromium/src/` to get the new devtools frontend checkout.
177
178To automatically symlink between `devtools-frontend` and `chromium/src`, you can add the following
179hook to your `.gclient` file to manage your `chromium/src` repository after your list of solutions.
180
181```python
182hooks = [
183 {
184 # Ensure devtools is symlinked in the correct location on every gclient sync
185 'name': 'Symlink Depot Tools',
186 'pattern': '.',
187 'action': [
188 'python',
189 '<path>/<to>/devtools-frontend/scripts/deps/ensure_symlink.py',
190 '<path>/<to>/chromium/src',
191 '<path>/<to>/devtools-frontend'
192 ],
193 }
194]
195```
196
197Running `gclient sync` anywhere within `chromium/src/` or `chromium/src/third_party/devtools-frontend/src` will update dependencies for both checkouts. Running `gclient sync -D` will not remove your symlink.
198
199### Chromium checkout
200
201DevTools frontend can also be developed as part of the full Chromium checkout.
202This workflow can be used to make small patches to DevTools as a Chromium engineer.
203However, it is different to our infrastructure setup and how to execute general maintenance work, and therefore discouraged.
204
205#### Checking out source
206
207Follow [instructions](https://www.chromium.org/developers/how-tos/get-the-code) to check out Chromium. DevTools frontend can be found under `third_party/devtools-frontend/src/`.
208
209#### Build
210
Tim van der Lippef407ef22021-02-04 13:56:38211Refer to [instructions](https://www.chromium.org/developers/how-tos/get-the-code) to build Chromium.
212To only build DevTools frontend, use `devtools_frontend_resources` as build target.
213The resulting build artifacts for DevTools frontend can be found in `out/Default/gen/third_party/devtools-frontend/src/front_end`.
Yang Guo03e780e2020-06-17 10:18:09214
215#### Run
216
217Run Chrome with bundled DevTools frontend:
218
219```bash
220out/Default/chrome
221```
222
223## Test
224
225### DevTools frontend
226
227Test are available by running scripts in `scripts/test/`. Please refer to the [overview document](https://docs.google.com/document/d/1c2KLKoFMqLB2A9sNAHIhYb70XFyfBUBs5BZSYfQAT-Y/edit). The current test status can be seen at the [test waterfall](https://ci.chromium.org/p/devtools-frontend/g/main/console).
228
229### Layout tests
230
231After building content shell as part of Chromium, we can also run layout tests that are relevant for DevTools frontend:
232
233```bash
234autoninja -C out/Default content_shell
Alfonso Castañoae3dc892020-10-16 10:54:47235third_party/blink/tools/run_web_tests.py -t Default http/tests/devtools
Yang Guo03e780e2020-06-17 10:18:09236```
237
238## Creating a change
239
240Usual [steps](https://chromium.googlesource.com/chromium/src/+/master/docs/contributing.md#creating-a-change) for creating a change work out of the box, when executed in the DevTools frontend repository.
241
242## Managing dependencies
243
244- To sync dependencies from Chromium to DevTools frontend, use `scripts/deps/roll_deps.py && npm run generate-protocol-resources`.
245
246The following scripts run as AutoRollers, but can be manually invoked if desired:
247
248- To roll the HEAD commit of DevTools frontend into Chromium, use `scripts/deps/roll_to_chromium.py`.
249- To update DevTools frontend's DEPS, use `roll-dep`.
250
Mathias Bynens5a8fc1f2020-08-24 07:40:12251## Merges and cherry-picks
Yang Guo03e780e2020-06-17 10:18:09252
Mathias Bynens5a8fc1f2020-08-24 07:40:12253_Merge request/approval is handled by Chromium Release Managers. DevTools follows [The Zen of Merge Requests](https://www.chromium.org/developers/the-zen-of-merge-requests). In exceptional cases please get in touch with [email protected]._
Yang Guo03e780e2020-06-17 10:18:09254
255Step-by-step guide on how to merge:
256
Mathias Bynensa8c87072020-08-31 14:32:172571. Request approval to merge by adding the `Merge-Request-XX` label to the relevant crbug. A bot will come by and either ask for more info ([example](https://bugs.chromium.org/p/chromium/issues/detail?id=1123307#c1)) or approve the request.
Mathias Bynens5a8fc1f2020-08-24 07:40:122581. Backmerges are done to the `chromium/xxxx` (e.g. `chromium/3979`) branch on the DevTools frontend repo.
259 Use <https://chromiumdash.appspot.com/branches> or [Omahaproxy](https://omahaproxy.appspot.com/)
260 to find out what branch a major Chromium version has (column `true_branch`).
2611. Open the to-be-merged commit in Gerrit
262 ([example](https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1928912)).
2631. Click the hamburger menu on the top right and select Cherry pick”.
2641. Select the branch to merge to e.g. `chromium/3968`.
2651. The cherry-pick CL is created
266 ([example](https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1928913)).
2671. Get it reviewed if necessary.
Mathias Bynensa8c87072020-08-31 14:32:172681. Once merge request approval is granted (see step 1), click the hamburger menu on the cherry-pick CL and select Submit”. (Setting the Commit-Queue bit (+2) has no effect because these branches dont have a commit queue.)
Mathias Bynens5a8fc1f2020-08-24 07:40:122691. Done.
Yang Guo03e780e2020-06-17 10:18:09270
271## Useful Commands
272
273### `git cl format --js`
274
275Formats all code using clang-format.
276
277### `npm run check`
278
279Runs all static analysis checks on DevTools code.