blob: 0f2d22fa2e1dbb3dfaac98d7c97ddedb842a073a [file] [log] [blame] [view]
dpranke1a70d0c2016-12-01 02:42:291# Checking out and Building Chromium for Windows
2
Bruce Dawson4d1de592017-09-08 00:24:003There are instructions for other platforms linked from the
dpranke1a70d0c2016-12-01 02:42:294[get the code](get_the_code.md) page.
tfarina502f3882016-03-23 12:48:105
dpranke1a70d0c2016-12-01 02:42:296## Instructions for Google Employees
7
8Are you a Google employee? See
scottmg292538ae2017-01-12 00:10:559[go/building-chrome-win](https://goto.google.com/building-chrome-win) instead.
dpranke0ae7cad2016-11-30 07:47:5810
11[TOC]
12
13## System requirements
14
15* A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly
16 recommended.
dpranke4b470c5b2017-01-19 17:38:0417* At least 100GB of free disk space on an NTFS-formatted hard drive. FAT32
18 will not work, as some of the Git packfiles are larger than 4GB.
Bruce Dawson97367b72017-10-18 00:47:4919* An appropriate version of Visual Studio, as described below.
Bruce Dawson52c749c2020-12-03 16:44:2620* Windows 10 or newer.
brettwc25693b32016-05-26 01:11:5221
tfarina502f3882016-03-23 12:48:1022## Setting up Windows
23
dpranke0ae7cad2016-11-30 07:47:5824### Visual Studio
tfarina502f3882016-03-23 12:48:1025
Bruce Dawsond95ceb62023-02-17 01:39:3026Chromium requires [Visual Studio 2022](https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-notes) (>=17.0.0)
27to build. Visual Studio can also be used to debug Chromium.
Raul Tambre1bb5c1a2018-12-29 00:57:1228The clang-cl compiler is used but Visual Studio's header files, libraries, and
29some tools are required. Visual Studio Community Edition should work if its
30license is appropriate for you. You must install the "Desktop development with
31C++" component and the "MFC/ATL support" sub-components. This can be done from
32the command line by passing these arguments to the Visual Studio installer (see
33below for ARM64 instructions):
Bruce Dawson1c0979a62017-09-13 17:47:2134```shell
Bruce Dawsone42d7642018-12-10 23:50:0035$ PATH_TO_INSTALLER.EXE ^
36--add Microsoft.VisualStudio.Workload.NativeDesktop ^
37--add Microsoft.VisualStudio.Component.VC.ATLMFC ^
38--includeRecommended
Bruce Dawson1c0979a62017-09-13 17:47:2139```
pwnall43b43ba2016-08-22 19:29:2940
Bruce Dawsone42d7642018-12-10 23:50:0041If you want to build for ARM64 Win32 then some extra arguments are needed. The
42full set for that case is:
43```shell
44$ PATH_TO_INSTALLER.EXE ^
45--add Microsoft.VisualStudio.Workload.NativeDesktop ^
46--add Microsoft.VisualStudio.Component.VC.ATLMFC ^
47--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^
48--add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ^
49--includeRecommended
50```
51
Bruce Dawsond95ceb62023-02-17 01:39:3052-You must have the version 10.0.22621.0 [Windows 11 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/)
Peter Kasting64c67dd2022-05-12 18:11:5153installed. This can be installed separately or by checking the appropriate box
54in the Visual Studio Installer.
Bruce Dawsone9f20fff2018-03-03 01:58:3855
Bruce Dawson9f043062023-02-07 01:38:5756The 10.0.22621.755 (Windows 11) SDK Debugging Tools must also be installed. This
57version of the Debugging tools is needed in order to support reading the
58large-page PDBs that Chrome uses to allow greater-than 4 GiB PDBs.
Robert Sesekc8ffa1b2017-08-04 19:55:2259
dpranke0ae7cad2016-11-30 07:47:5860## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1061
dpranke1a70d0c2016-12-01 02:42:2962Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
Eric Waldmanc469ba7b2022-03-02 20:33:0063and extract it somewhere (eg: C:\src\depot_tools).
tfarina502f3882016-03-23 12:48:1064
dpranke0ae7cad2016-11-30 07:47:5865*** note
66**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
67this will not extract the hidden “.git” folder which is necessary for
Bruce Dawson4d1de592017-09-08 00:24:0068depot_tools to autoupdate itself. You can use “Extract all…” from the
dpranke0ae7cad2016-11-30 07:47:5869context menu though.
70***
tfarina502f3882016-03-23 12:48:1071
Bruce Dawson4d1de592017-09-08 00:24:0072Add depot_tools to the start of your PATH (must be ahead of any installs of
Eric Waldmanc469ba7b2022-03-02 20:33:0073Python. Note that environment variable names are case insensitive).
74
75Assuming you unzipped the bundle to C:\src\depot_tools, open:
tfarina502f3882016-03-23 12:48:1076
dpranke0ae7cad2016-11-30 07:47:5877Control Panel → System and Security → System → Advanced system settings
tfarina502f3882016-03-23 12:48:1078
dpranke4b470c5b2017-01-19 17:38:0479If you have Administrator access, Modify the PATH system variable and
80put `C:\src\depot_tools` at the front (or at least in front of any directory
81that might already have a copy of Python or Git).
tfarina502f3882016-03-23 12:48:1082
dpranke4b470c5b2017-01-19 17:38:0483If you don't have Administrator access, you can add a user-level PATH
Eric Waldmanc469ba7b2022-03-02 20:33:0084environment variable by opening:
85
86Control Panel → System and Security → System → Search for "Edit environment variables for your account"
87
88Add `C:\src\depot_tools` at the front. Note: If your system PATH has a Python in it, you will be out of luck.
dpranke0ae7cad2016-11-30 07:47:5889
Wan-Teh Chang03912872022-03-14 23:07:3490Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN environment variable in the same way, and set
dpranke0ae7cad2016-11-30 07:47:5891it to 0. This tells depot_tools to use your locally installed version of Visual
Aaron Gabledad9e0f2020-01-09 19:38:5292Studio (by default, depot_tools will try to use a google-internal version).
dpranke0ae7cad2016-11-30 07:47:5893
Bruce Dawsond95ceb62023-02-17 01:39:3094You may also have to set variable `vs2022_install` to your installation path of
95Visual Studio 2022, like
96`set vs2022_install=C:\Program Files\Microsoft Visual Studio\2022\Professional`.
Andreas Papacharalampous1d22c9612020-06-13 23:11:1797
Reilly Grant07ff22e2021-10-19 19:21:2098From a cmd.exe shell, run:
99
100```shell
101$ gclient
102```
103
104On first run, gclient will install all the Windows-specific bits needed to work
105with the code, including msysgit and python.
dpranke0ae7cad2016-11-30 07:47:58106
107* If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell),
108 it may appear to run properly, but msysgit, python, and other tools
109 may not get installed correctly.
110* If you see strange errors with the file system on the first run of gclient,
Yuma Takaid4809d552022-02-15 03:48:19111 you may want to [disable Windows Indexing](https://tortoisesvn.net/faq.html#cantmove2).
dpranke0ae7cad2016-11-30 07:47:58112
Will Harris1c8f89c2021-03-08 22:53:43113## Check python install
114
Bruce Dawson4d1de592017-09-08 00:24:00115After running gclient open a command prompt and type `where python` and
116confirm that the depot_tools `python.bat` comes ahead of any copies of
117python.exe. Failing to ensure this can lead to overbuilding when
dpranke0ae7cad2016-11-30 07:47:58118using gn - see [crbug.com/611087](https://crbug.com/611087).
119
Will Harris1c8f89c2021-03-08 22:53:43120[App Execution Aliases](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions#alias)
121can conflict with other installations of python on the system so disable
122these for 'python.exe' and 'python3.exe' by opening 'App execution aliases'
123section of Control Panel and unticking the boxes next to both of these
124that point to 'App Installer'.
125
dpranke0ae7cad2016-11-30 07:47:58126## Get the code
127
Leonard Mosescu718c9ac2017-06-20 18:06:32128First, configure Git:
129
130```shell
131$ git config --global user.name "My Name"
132$ git config --global user.email "[email protected]"
133$ git config --global core.autocrlf false
134$ git config --global core.filemode false
135$ git config --global branch.autosetuprebase always
136```
137
sdy93387fa2016-12-01 01:03:44138Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:58139this whatever you like and put it wherever you like, as
140long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:58141
sdy93387fa2016-12-01 01:03:44142```shell
143$ mkdir chromium && cd chromium
144```
145
146Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58147dependencies.
148
sdy93387fa2016-12-01 01:03:44149```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30150$ fetch chromium
sdy93387fa2016-12-01 01:03:44151```
dpranke0ae7cad2016-11-30 07:47:58152
153If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44154adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58155
Bruce Dawson2c83223e2022-10-25 21:08:22156Expect the command to take over an hour on even a fast connection, and many
157hours on slower ones. You should configure your PC so that it doesn't sleep
158or hibernate during the fetch or else errors may occur. If errors occur while
159fetching sub-repos then you can start over, or you may be able to correct them
160by going to the chromium/src directory and running this command:
161
162```shell
163$ gclient sync
164```
dpranke0ae7cad2016-11-30 07:47:58165
sdy93387fa2016-12-01 01:03:44166When `fetch` completes, it will have created a hidden `.gclient` file and a
167directory called `src` in the working directory. The remaining instructions
168assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58169
sdy93387fa2016-12-01 01:03:44170```shell
171$ cd src
172```
dpranke0ae7cad2016-11-30 07:47:58173
sdy93387fa2016-12-01 01:03:44174*Optional*: You can also [install API
175keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
176build to talk to some Google services, but this is not necessary for most
177development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58178
dpranke1a70d0c2016-12-01 02:42:29179## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58180
Tom Bridgwatereef401542018-08-17 00:54:43181Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Andrew Williamsbbc1a1e2021-07-21 01:51:22182a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md)
Tom Bridgwatereef401542018-08-17 00:54:43183to generate `.ninja` files. You can create any number of *build directories*
184with different configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58185
sdy93387fa2016-12-01 01:03:44186```shell
Andrew Williamsfa9b7d62023-03-20 15:48:28187$ gn gen out\Default
sdy93387fa2016-12-01 01:03:44188```
dpranke0ae7cad2016-11-30 07:47:58189
sdy93387fa2016-12-01 01:03:44190* You only have to run this once for each new build directory, Ninja will
191 update the build files as needed.
192* You can replace `Default` with another name, but
193 it should be a subdirectory of `out`.
Aaron Gabledad9e0f2020-01-09 19:38:52194* For other build arguments, including release settings or using an alternate
195 version of Visual Studio, see [GN build
sdy93387fa2016-12-01 01:03:44196 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58197 The default will be a debug component build matching the current host
198 operating system and CPU.
Tom Bridgwatereef401542018-08-17 00:54:43199* For more info on GN, run `gn help` on the command line or read the [quick
Andrew Williamsbbc1a1e2021-07-21 01:51:22200 start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md).
Juan Cruz Viotti9c7622d2021-06-30 00:27:23201
dpranke0ae7cad2016-11-30 07:47:58202### Faster builds
tfarina502f3882016-03-23 12:48:10203
dpranke0ae7cad2016-11-30 07:47:58204* Reduce file system overhead by excluding build directories from
205 antivirus and indexing software.
206* Store the build tree on a fast disk (preferably SSD).
brucedawsoncfc7fd52017-07-06 18:41:01207* The more cores the better (20+ is not excessive) and lots of RAM is needed
208(64 GB is not excessive).
tfarina502f3882016-03-23 12:48:10209
brucedawsoncfc7fd52017-07-06 18:41:01210There are some gn flags that can improve build speeds. You can specify these
211in the editor that appears when you create your output directory
Andrew Williamsfa9b7d62023-03-20 15:48:28212(`gn args out\Default`) or on the gn gen command line
213(`gn gen out\Default --args="is_component_build = true is_debug = true"`).
brucedawsoncfc7fd52017-07-06 18:41:01214Some helpful settings to consider using include:
Bruce Dawson2c83223e2022-10-25 21:08:22215* `is_component_build = true` - this uses more, smaller DLLs, and may avoid
216having to relink chrome.dll after every change.
Bruce Dawsonfcd3deb12017-07-28 17:12:20217* `enable_nacl = false` - this disables Native Client which is usually not
218needed for local builds.
Bruce Dawson2c83223e2022-10-25 21:08:22219* `target_cpu = "x86"` - x86 builds may be slightly faster than x64 builds. Note
220that if you set this but don't set `enable_nacl = false` then build times may
221get worse.
James Cook26699a92019-03-12 22:23:10222* `blink_symbol_level = 0` - turn off source-level debugging for
brucedawsoncfc7fd52017-07-06 18:41:01223blink to reduce build times, appropriate if you don't plan to debug blink.
Bruce Dawson63e0be72021-11-29 20:34:41224* `v8_symbol_level = 0` - turn off source-level debugging for v8 to reduce
225build times, appropriate if you don't plan to debug v8.
brucedawsoncfc7fd52017-07-06 18:41:01226
Bruce Dawson817f47fb2020-05-01 22:29:08227In order to speed up linking you can set `symbol_level = 1` or
228`symbol_level = 0` - these options reduce the work the compiler and linker have
229to do. With `symbol_level = 1` the compiler emits file name and line number
230information so you can still do source-level debugging but there will be no
231local variable or type information. With `symbol_level = 0` there is no
232source-level debugging but call stacks still have function names. Changing
233`symbol_level` requires recompiling everything.
brucedawsoncfc7fd52017-07-06 18:41:01234
Bruce Dawsone9f20fff2018-03-03 01:58:38235In addition, Google employees should use goma, a distributed compilation system.
236Detailed information is available internally but the relevant gn arg is:
237* `use_goma = true`
brucedawsoncfc7fd52017-07-06 18:41:01238
239To get any benefit from goma it is important to pass a large -j value to ninja.
Bruce Dawsone9f20fff2018-03-03 01:58:38240A good default is 10\*numCores to 20\*numCores. If you run autoninja then it
241will automatically pass an appropriate -j value to ninja for goma or not.
242
243```shell
244$ autoninja -C out\Default chrome
245```
brucedawsoncfc7fd52017-07-06 18:41:01246
247When invoking ninja specify 'chrome' as the target to avoid building all test
248binaries as well.
249
250Still, builds will take many hours on many machines.
dpranke0ae7cad2016-11-30 07:47:58251
Juan Cruz Viotti9c7622d2021-06-30 00:27:23252#### Use SCCACHE
253
254You might be able to use [sccache](https://github.com/mozilla/sccache) for the
255build process by enabling the following arguments:
256
257* `cc_wrapper = "sccache"` - assuming the `sccache` binary is in your `%PATH%`
258* `chrome_pgo_phase = 0`
259
Bruce Dawsone9f20fff2018-03-03 01:58:38260### Why is my build slow?
261
262Many things can make builds slow, with Windows Defender slowing process startups
263being a frequent culprit. Have you ensured that the entire Chromium src
Bruce Dawson0bbe2d42018-03-06 19:45:55264directory is excluded from antivirus scanning (on Google machines this means
Bruce Dawsone9f20fff2018-03-03 01:58:38265putting it in a ``src`` directory in the root of a drive)? Have you tried the
266different settings listed above, including different link settings and -j
267values? Have you asked on the chromium-dev mailing list to see if your build is
268slower than expected for your machine's specifications?
269
Bruce Dawson89390172019-05-08 09:51:18270The next step is to gather some data. If you set the ``NINJA_SUMMARIZE_BUILD``
Bruce Dawsonb9988e92019-09-16 17:01:10271environment variable to 1 then ``autoninja`` will do three things. First, it
272will set the [NINJA_STATUS](https://ninja-build.org/manual.html#_environment_variables)
Bruce Dawson89390172019-05-08 09:51:18273environment variable so that ninja will print additional information while
274building Chrome. It will show how many build processes are running at any given
275time, how many build steps have completed, how many build steps have completed
276per second, and how long the build has been running, as shown here:
Bruce Dawsone9f20fff2018-03-03 01:58:38277
278```shell
Bruce Dawson89390172019-05-08 09:51:18279$ set NINJA_SUMMARIZE_BUILD=1
Bruce Dawsone9f20fff2018-03-03 01:58:38280$ autoninja -C out\Default base
281ninja: Entering directory `out\Default'
282[1 processes, 86/86 @ 2.7/s : 31.785s ] LINK(DLL) base.dll base.dll.lib base.dll.pdb
283```
284
Bruce Dawson89390172019-05-08 09:51:18285This makes slow process creation immediately obvious and lets you tell quickly
286if a build is running more slowly than normal.
287
288In addition, setting ``NINJA_SUMMARIZE_BUILD=1`` tells ``autoninja`` to print a
289build performance summary when the build completes, showing the slowest build
290steps and slowest build-step types, as shown here:
Bruce Dawsone9f20fff2018-03-03 01:58:38291
292```shell
293$ set NINJA_SUMMARIZE_BUILD=1
294$ autoninja -C out\Default base
Bruce Dawson2721f0b2019-11-08 18:41:27295Longest build steps:
296 0.1 weighted s to build obj/base/base/trace_log.obj (6.7 s elapsed time)
297 0.2 weighted s to build nasm.exe, nasm.exe.pdb (0.2 s elapsed time)
298 0.3 weighted s to build obj/base/base/win_util.obj (12.4 s elapsed time)
299 1.2 weighted s to build base.dll, base.dll.lib (1.2 s elapsed time)
300Time by build-step type:
301 0.0 s weighted time to generate 6 .lib files (0.3 s elapsed time sum)
302 0.1 s weighted time to generate 25 .stamp files (1.2 s elapsed time sum)
303 0.2 s weighted time to generate 20 .o files (2.8 s elapsed time sum)
304 1.7 s weighted time to generate 4 PEFile (linking) files (2.0 s elapsed
305time sum)
306 23.9 s weighted time to generate 770 .obj files (974.8 s elapsed time sum)
30726.1 s weighted time (982.9 s elapsed time sum, 37.7x parallelism)
308839 build steps completed, average of 32.17/s
Bruce Dawsone9f20fff2018-03-03 01:58:38309```
310
Bruce Dawson2721f0b2019-11-08 18:41:27311The "weighted" time is the elapsed time of each build step divided by the number
312of tasks that were running in parallel. This makes it an excellent approximation
313of how "important" a slow step was. A link that is entirely or mostly serialized
314will have a weighted time that is the same or similar to its elapsed time. A
315compile that runs in parallel with 999 other compiles will have a weighted time
316that is tiny.
317
Bruce Dawson0bbe2d42018-03-06 19:45:55318You can also generate these reports by manually running the script after a build:
319
320```shell
321$ python depot_tools\post_build_ninja_summary.py -C out\Default
322```
323
Bruce Dawsonb9988e92019-09-16 17:01:10324Finally, setting ``NINJA_SUMMARIZE_BUILD=1`` tells autoninja to tell Ninja to
325report on its own overhead by passing "-d stats". This can be helpful if, for
326instance, process creation (which shows up in the StartEdge metric) is making
327builds slow, perhaps due to antivirus interference due to clang-cl not being in
328an excluded directory:
Bruce Dawsone9f20fff2018-03-03 01:58:38329
330```shell
Bruce Dawsonb9988e92019-09-16 17:01:10331$ set NINJA_SUMMARIZE_BUILD=1
332$ autoninja -C out\Default base
Bruce Dawsone9f20fff2018-03-03 01:58:38333metric count avg (us) total (ms)
334.ninja parse 3555 1539.4 5472.6
335canonicalize str 1383032 0.0 12.7
336canonicalize path 1402349 0.0 11.2
337lookup node 1398245 0.0 8.1
338.ninja_log load 2 118.0 0.2
339.ninja_deps load 2 67.5 0.1
340node stat 2516 29.6 74.4
341depfile load 2 1132.0 2.3
342StartEdge 88 3508.1 308.7
343FinishCommand 87 1670.9 145.4
344CLParser::Parse 45 1889.1 85.0
345```
346
Bruce Dawsonb9988e92019-09-16 17:01:10347You can also get a visual report of the build performance with
348[ninjatracing](https://github.com/nico/ninjatracing). This converts the
Chunbo Huaea6a9cf2022-07-20 03:01:10349.ninja_log file into a .json file which can be loaded into [chrome://tracing](chrome://tracing):
Bruce Dawsonb9988e92019-09-16 17:01:10350
351```shell
352$ python ninjatracing out\Default\.ninja_log >build.json
353```
354
dpranke0ae7cad2016-11-30 07:47:58355## Build Chromium
356
Max Morozf5b31fcd2018-08-10 21:55:48357Build Chromium (the "chrome" target) with Ninja using the command:
dpranke0ae7cad2016-11-30 07:47:58358
dpranke1a70d0c2016-12-01 02:42:29359```shell
Max Morozf5b31fcd2018-08-10 21:55:48360$ autoninja -C out\Default chrome
dpranke1a70d0c2016-12-01 02:42:29361```
dpranke0ae7cad2016-11-30 07:47:58362
Max Morozf5b31fcd2018-08-10 21:55:48363`autoninja` is a wrapper that automatically provides optimal values for the
364arguments passed to `ninja`.
365
dpranke0ae7cad2016-11-30 07:47:58366You can get a list of all of the other build targets from GN by running
Andrew Williamsfa9b7d62023-03-20 15:48:28367`gn ls out\Default` from the command line. To compile one, pass to Ninja
dpranke0ae7cad2016-11-30 07:47:58368the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
Andrew Williamsfa9b7d62023-03-20 15:48:28369use `autoninja -C out\Default chrome/test:unit_tests`).
dpranke0ae7cad2016-11-30 07:47:58370
371## Run Chromium
372
373Once it is built, you can simply run the browser:
374
dpranke1a70d0c2016-12-01 02:42:29375```shell
376$ out\Default\chrome.exe
377```
378
379(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58380
381## Running test targets
382
Andrew Williamsfa9b7d62023-03-20 15:48:28383Tests are split into multiple test targets based on their type and where they
384exist in the directory structure. To see what target a given unit test or
385browser test file corresponds to, the following command can be used:
dpranke0ae7cad2016-11-30 07:47:58386
dpranke1a70d0c2016-12-01 02:42:29387```shell
Andrew Williamsfa9b7d62023-03-20 15:48:28388$ gn refs out\Default --testonly=true --type=executable --all chrome\browser\ui\browser_list_unittest.cc
389//chrome/test:unit_tests
390```
391
392In the example above, the target is unit_tests. The unit_tests binary can be
393built by running the following command:
394
395```shell
396$ autoninja -C out\Default unit_tests
397```
398
399You can run the tests by running the unit_tests binary. You can also limit which
400tests are run using the `--gtest_filter` arg, e.g.:
401
402```shell
403$ out\Default\unit_tests.exe --gtest_filter="BrowserListUnitTest.*"
dpranke1a70d0c2016-12-01 02:42:29404```
dpranke0ae7cad2016-11-30 07:47:58405
406You can find out more about GoogleTest at its
407[GitHub page](https://github.com/google/googletest).
408
409## Update your checkout
410
411To update an existing checkout, you can run
412
dpranke1a70d0c2016-12-01 02:42:29413```shell
414$ git rebase-update
Bruce Dawsonef0b5452020-10-03 00:13:09415$ gclient sync -D
dpranke1a70d0c2016-12-01 02:42:29416```
dpranke0ae7cad2016-11-30 07:47:58417
418The first command updates the primary Chromium source repository and rebases
Andrew Williamsbbc1a1e2021-07-21 01:51:22419any of your local branches on top of tip-of-tree (aka the Git branch
420`origin/main`). If you don't want to use this script, you can also just use
421`git pull` or other common Git commands to update the repo.
dpranke0ae7cad2016-11-30 07:47:58422
Bruce Dawsonef0b5452020-10-03 00:13:09423The second command syncs the subrepositories to the appropriate versions,
424deleting those that are no longer needed, and re-runs the hooks as needed.
425
426### Editing and Debugging With the Visual Studio IDE
427
428You can use the Visual Studio IDE to edit and debug Chrome, with or without
429Intellisense support.
430
431#### Using Visual Studio Intellisense
432
433If you want to use Visual Studio Intellisense when developing Chromium, use the
434`--ide` command line argument to `gn gen` when you generate your output
435directory (as described on the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code)
Junji Watanabe0f6489c72023-02-01 04:02:11436page). This is an example when your checkout is `C:\src\chromium` and your
437output directory is `out\Default`:
Bruce Dawsonef0b5452020-10-03 00:13:09438
439```shell
Junji Watanabe0f6489c72023-02-01 04:02:11440$ gn gen --ide=vs --ninja-executable=C:\src\chromium\src\third_party\ninja\ninja.exe out\Default
Bruce Dawsonef0b5452020-10-03 00:13:09441$ devenv out\Default\all.sln
442```
443
444GN will produce a file `all.sln` in your build directory. It will internally
445use Ninja to compile while still allowing most IDE functions to work (there is
446no native Visual Studio compilation mode). If you manually run "gen" again you
447will need to resupply this argument, but normally GN will keep the build and
448IDE files up to date automatically when you build.
449
450The generated solution will contain several thousand projects and will be very
451slow to load. Use the `--filters` argument to restrict generating project files
452for only the code you're interested in. Although this will also limit what
453files appear in the project explorer, debugging will still work and you can
454set breakpoints in files that you open manually. A minimal solution that will
455let you compile and run Chrome in the IDE but will not show any source files
456is:
457
458```
Junji Watanabe0f6489c72023-02-01 04:02:11459$ gn gen --ide=vs --ninja-executable=C:\src\chromium\src\third_party\ninja\ninja.exe --filters=//chrome --no-deps out\Default
Bruce Dawsonef0b5452020-10-03 00:13:09460```
461
462You can selectively add other directories you care about to the filter like so:
463`--filters=//chrome;//third_party/WebKit/*;//gpu/*`.
464
465There are other options for controlling how the solution is generated, run `gn
466help gen` for the current documentation.
467
468#### Using Visual Studio without Intellisense
469
470It is also possible to debug and develop Chrome in Visual Studio without the
471overhead of a multi-project solution file. Simply "open" your chrome.exe binary
472with `File->Open->Project/Solution`, or from a Visual Studio command prompt like
473so: `devenv /debugexe out\Debug\chrome.exe <your arguments>`. Many of Visual
474Studio's code exploration features will not work in this configuration, but by
475installing the [VsChromium Visual Studio Extension](https://chromium.github.io/vs-chromium/)
476you can get the source code to appear in the solution explorer window along
477with other useful features such as code search. You can add multiple executables
478of interest (base_unittests.exe, browser_tests.exe) to your solution with
479`File->Add->Existing Project...` and change which one will be debugged by
480right-clicking on them in `Solution Explorer` and selecting `Set as Startup
481Project`. You can also change their properties, including command line
482arguments, by right-clicking on them in `Solution Explorer` and selecting
483`Properties`.
484
485By default when you start debugging in Visual Studio the debugger will only
486attach to the main browser process. To debug all of Chrome, install
487[Microsoft's Child Process Debugging Power Tool](https://blogs.msdn.microsoft.com/devops/2014/11/24/introducing-the-child-process-debugging-power-tool/).
488You will also need to run Visual Studio as administrator, or it will silently
489fail to attach to some of Chrome's child processes.
490
Avi Drissmanc0f6793ac2023-05-26 19:22:44491### Improving performance of `git status`
492
493#### Configure git to use an untracked cache
494
495If `git --version` reports 2.8 or higher, try running
496
497```shell
498$ git update-index --test-untracked-cache
499```
500
501If the output ends with `OK`, then the following may also improve performance of
502`git status`:
503
504```shell
505$ git config core.untrackedCache true
506```
507
508If `git --version` reports 2.6 or higher, but below 2.8, you can instead run
509
510```shell
511$ git update-index --untracked-cache
512```
513
514#### Configure git to use fsmonitor
515
516If `git --version` reports 2.37 or higher, use fsmonitor, which will
517significantly speed git:
518
519```shell
520$ git config core.fsmonitor true
521```