blob: 4b9f530a2251dcd4ecaafb4081914f7dc9cc9659 [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
Frédéric Wangee66b892021-11-24 09:22:2826Chromium requires [Visual Studio 2017](https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes) (>=15.7.2)
27to build, but [Visual Studio 2019](https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes) (>=16.0.0)
28is preferred. Visual Studio can also be used to debug Chromium, and version 2019 is
Bruce Dawsonfa551102019-06-11 23:50:0429preferred for this as it handles Chromium's large debug information much better.
Raul Tambre1bb5c1a2018-12-29 00:57:1230The clang-cl compiler is used but Visual Studio's header files, libraries, and
31some tools are required. Visual Studio Community Edition should work if its
32license is appropriate for you. You must install the "Desktop development with
33C++" component and the "MFC/ATL support" sub-components. This can be done from
34the command line by passing these arguments to the Visual Studio installer (see
35below for ARM64 instructions):
Bruce Dawson1c0979a62017-09-13 17:47:2136```shell
Bruce Dawsone42d7642018-12-10 23:50:0037$ PATH_TO_INSTALLER.EXE ^
38--add Microsoft.VisualStudio.Workload.NativeDesktop ^
39--add Microsoft.VisualStudio.Component.VC.ATLMFC ^
40--includeRecommended
Bruce Dawson1c0979a62017-09-13 17:47:2141```
pwnall43b43ba2016-08-22 19:29:2942
Bruce Dawsone42d7642018-12-10 23:50:0043If you want to build for ARM64 Win32 then some extra arguments are needed. The
44full set for that case is:
45```shell
46$ PATH_TO_INSTALLER.EXE ^
47--add Microsoft.VisualStudio.Workload.NativeDesktop ^
48--add Microsoft.VisualStudio.Component.VC.ATLMFC ^
49--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^
50--add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ^
51--includeRecommended
52```
53
Frédéric Wangee66b892021-11-24 09:22:2854-You must have the version 10.0.19041 or higher [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive/)
55installed. This
Bruce Dawsone42d7642018-12-10 23:50:0056can be installed separately or by checking the appropriate box in the Visual
57Studio Installer.
Bruce Dawsone9f20fff2018-03-03 01:58:3858
59The SDK Debugging Tools must also be installed. If the Windows 10 SDK was
60installed via the Visual Studio installer, then they can be installed by going
61to: Control Panel → Programs → Programs and Features → Select the "Windows
62Software Development Kit" → Change → Change → Check "Debugging Tools For
63Windows" → Change. Or, you can download the standalone SDK installer and use it
64to install the Debugging Tools.
Robert Sesekc8ffa1b2017-08-04 19:55:2265
dpranke0ae7cad2016-11-30 07:47:5866## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1067
dpranke1a70d0c2016-12-01 02:42:2968Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5869and extract it somewhere.
tfarina502f3882016-03-23 12:48:1070
dpranke0ae7cad2016-11-30 07:47:5871*** note
72**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
73this will not extract the hidden “.git” folder which is necessary for
Bruce Dawson4d1de592017-09-08 00:24:0074depot_tools to autoupdate itself. You can use “Extract all…” from the
dpranke0ae7cad2016-11-30 07:47:5875context menu though.
76***
tfarina502f3882016-03-23 12:48:1077
Bruce Dawson4d1de592017-09-08 00:24:0078Add depot_tools to the start of your PATH (must be ahead of any installs of
dpranke4b470c5b2017-01-19 17:38:0479Python). Assuming you unzipped the bundle to C:\src\depot_tools, open:
tfarina502f3882016-03-23 12:48:1080
dpranke0ae7cad2016-11-30 07:47:5881Control Panel → System and Security → System → Advanced system settings
tfarina502f3882016-03-23 12:48:1082
dpranke4b470c5b2017-01-19 17:38:0483If you have Administrator access, Modify the PATH system variable and
84put `C:\src\depot_tools` at the front (or at least in front of any directory
85that might already have a copy of Python or Git).
tfarina502f3882016-03-23 12:48:1086
dpranke4b470c5b2017-01-19 17:38:0487If you don't have Administrator access, you can add a user-level PATH
88environment variable and put `C:\src\depot_tools` at the front, but
89if your system PATH has a Python in it, you will be out of luck.
dpranke0ae7cad2016-11-30 07:47:5890
91Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set
92it to 0. This tells depot_tools to use your locally installed version of Visual
Aaron Gabledad9e0f2020-01-09 19:38:5293Studio (by default, depot_tools will try to use a google-internal version).
dpranke0ae7cad2016-11-30 07:47:5894
Andreas Papacharalampous1d22c9612020-06-13 23:11:1795You may also have to set variable `vs2017_install` or `vs2019_install` to your
96installation path of Visual Studio 2017 or 19, like
97`set vs2019_install=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional`
98for Visual Studio 2019.
99
Reilly Grant07ff22e2021-10-19 19:21:20100From a cmd.exe shell, run:
101
102```shell
103$ gclient
104```
105
106On first run, gclient will install all the Windows-specific bits needed to work
107with the code, including msysgit and python.
dpranke0ae7cad2016-11-30 07:47:58108
109* If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell),
110 it may appear to run properly, but msysgit, python, and other tools
111 may not get installed correctly.
112* If you see strange errors with the file system on the first run of gclient,
113 you may want to [disable Windows Indexing](http://tortoisesvn.tigris.org/faq.html#cantmove2).
114
Will Harris1c8f89c2021-03-08 22:53:43115## Check python install
116
Bruce Dawson4d1de592017-09-08 00:24:00117After running gclient open a command prompt and type `where python` and
118confirm that the depot_tools `python.bat` comes ahead of any copies of
119python.exe. Failing to ensure this can lead to overbuilding when
dpranke0ae7cad2016-11-30 07:47:58120using gn - see [crbug.com/611087](https://crbug.com/611087).
121
Will Harris1c8f89c2021-03-08 22:53:43122[App Execution Aliases](https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/desktop-to-uwp-extensions#alias)
123can conflict with other installations of python on the system so disable
124these for 'python.exe' and 'python3.exe' by opening 'App execution aliases'
125section of Control Panel and unticking the boxes next to both of these
126that point to 'App Installer'.
127
dpranke0ae7cad2016-11-30 07:47:58128## Get the code
129
Leonard Mosescu718c9ac2017-06-20 18:06:32130First, configure Git:
131
132```shell
133$ git config --global user.name "My Name"
134$ git config --global user.email "[email protected]"
135$ git config --global core.autocrlf false
136$ git config --global core.filemode false
137$ git config --global branch.autosetuprebase always
138```
139
sdy93387fa2016-12-01 01:03:44140Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:58141this whatever you like and put it wherever you like, as
142long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:58143
sdy93387fa2016-12-01 01:03:44144```shell
145$ mkdir chromium && cd chromium
146```
147
148Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58149dependencies.
150
sdy93387fa2016-12-01 01:03:44151```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30152$ fetch chromium
sdy93387fa2016-12-01 01:03:44153```
dpranke0ae7cad2016-11-30 07:47:58154
155If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44156adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58157
sdy93387fa2016-12-01 01:03:44158Expect the command to take 30 minutes on even a fast connection, and many
159hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58160
sdy93387fa2016-12-01 01:03:44161When `fetch` completes, it will have created a hidden `.gclient` file and a
162directory called `src` in the working directory. The remaining instructions
163assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58164
sdy93387fa2016-12-01 01:03:44165```shell
166$ cd src
167```
dpranke0ae7cad2016-11-30 07:47:58168
sdy93387fa2016-12-01 01:03:44169*Optional*: You can also [install API
170keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
171build to talk to some Google services, but this is not necessary for most
172development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58173
dpranke1a70d0c2016-12-01 02:42:29174## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58175
Tom Bridgwatereef401542018-08-17 00:54:43176Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Andrew Williamsbbc1a1e2021-07-21 01:51:22177a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md)
Tom Bridgwatereef401542018-08-17 00:54:43178to generate `.ninja` files. You can create any number of *build directories*
179with different configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58180
sdy93387fa2016-12-01 01:03:44181```shell
182$ gn gen out/Default
183```
dpranke0ae7cad2016-11-30 07:47:58184
sdy93387fa2016-12-01 01:03:44185* You only have to run this once for each new build directory, Ninja will
186 update the build files as needed.
187* You can replace `Default` with another name, but
188 it should be a subdirectory of `out`.
Aaron Gabledad9e0f2020-01-09 19:38:52189* For other build arguments, including release settings or using an alternate
190 version of Visual Studio, see [GN build
sdy93387fa2016-12-01 01:03:44191 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58192 The default will be a debug component build matching the current host
193 operating system and CPU.
Tom Bridgwatereef401542018-08-17 00:54:43194* For more info on GN, run `gn help` on the command line or read the [quick
Andrew Williamsbbc1a1e2021-07-21 01:51:22195 start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md).
Juan Cruz Viotti9c7622d2021-06-30 00:27:23196
dpranke0ae7cad2016-11-30 07:47:58197### Faster builds
tfarina502f3882016-03-23 12:48:10198
dpranke0ae7cad2016-11-30 07:47:58199* Reduce file system overhead by excluding build directories from
200 antivirus and indexing software.
201* Store the build tree on a fast disk (preferably SSD).
brucedawsoncfc7fd52017-07-06 18:41:01202* The more cores the better (20+ is not excessive) and lots of RAM is needed
203(64 GB is not excessive).
tfarina502f3882016-03-23 12:48:10204
brucedawsoncfc7fd52017-07-06 18:41:01205There are some gn flags that can improve build speeds. You can specify these
206in the editor that appears when you create your output directory
207(`gn args out/Default`) or on the gn gen command line
208(`gn gen out/Default --args="is_component_build = true is_debug = true"`).
209Some helpful settings to consider using include:
210* `is_component_build = true` - this uses more, smaller DLLs, and incremental
211linking.
Bruce Dawsonfcd3deb12017-07-28 17:12:20212* `enable_nacl = false` - this disables Native Client which is usually not
213needed for local builds.
brucedawsoncfc7fd52017-07-06 18:41:01214* `target_cpu = "x86"` - x86 builds are slightly faster than x64 builds and
215support incremental linking for more targets. Note that if you set this but
Bruce Dawsonfcd3deb12017-07-28 17:12:20216don't' set enable_nacl = false then build times may get worse.
James Cook26699a92019-03-12 22:23:10217* `blink_symbol_level = 0` - turn off source-level debugging for
brucedawsoncfc7fd52017-07-06 18:41:01218blink to reduce build times, appropriate if you don't plan to debug blink.
brucedawsoncfc7fd52017-07-06 18:41:01219
Bruce Dawson817f47fb2020-05-01 22:29:08220In order to speed up linking you can set `symbol_level = 1` or
221`symbol_level = 0` - these options reduce the work the compiler and linker have
222to do. With `symbol_level = 1` the compiler emits file name and line number
223information so you can still do source-level debugging but there will be no
224local variable or type information. With `symbol_level = 0` there is no
225source-level debugging but call stacks still have function names. Changing
226`symbol_level` requires recompiling everything.
brucedawsoncfc7fd52017-07-06 18:41:01227
Bruce Dawsone9f20fff2018-03-03 01:58:38228In addition, Google employees should use goma, a distributed compilation system.
229Detailed information is available internally but the relevant gn arg is:
230* `use_goma = true`
brucedawsoncfc7fd52017-07-06 18:41:01231
232To get any benefit from goma it is important to pass a large -j value to ninja.
Bruce Dawsone9f20fff2018-03-03 01:58:38233A good default is 10\*numCores to 20\*numCores. If you run autoninja then it
234will automatically pass an appropriate -j value to ninja for goma or not.
235
236```shell
237$ autoninja -C out\Default chrome
238```
brucedawsoncfc7fd52017-07-06 18:41:01239
240When invoking ninja specify 'chrome' as the target to avoid building all test
241binaries as well.
242
243Still, builds will take many hours on many machines.
dpranke0ae7cad2016-11-30 07:47:58244
Juan Cruz Viotti9c7622d2021-06-30 00:27:23245#### Use SCCACHE
246
247You might be able to use [sccache](https://github.com/mozilla/sccache) for the
248build process by enabling the following arguments:
249
250* `cc_wrapper = "sccache"` - assuming the `sccache` binary is in your `%PATH%`
251* `chrome_pgo_phase = 0`
252
Bruce Dawsone9f20fff2018-03-03 01:58:38253### Why is my build slow?
254
255Many things can make builds slow, with Windows Defender slowing process startups
256being a frequent culprit. Have you ensured that the entire Chromium src
Bruce Dawson0bbe2d42018-03-06 19:45:55257directory is excluded from antivirus scanning (on Google machines this means
Bruce Dawsone9f20fff2018-03-03 01:58:38258putting it in a ``src`` directory in the root of a drive)? Have you tried the
259different settings listed above, including different link settings and -j
260values? Have you asked on the chromium-dev mailing list to see if your build is
261slower than expected for your machine's specifications?
262
Bruce Dawson89390172019-05-08 09:51:18263The next step is to gather some data. If you set the ``NINJA_SUMMARIZE_BUILD``
Bruce Dawsonb9988e92019-09-16 17:01:10264environment variable to 1 then ``autoninja`` will do three things. First, it
265will set the [NINJA_STATUS](https://ninja-build.org/manual.html#_environment_variables)
Bruce Dawson89390172019-05-08 09:51:18266environment variable so that ninja will print additional information while
267building Chrome. It will show how many build processes are running at any given
268time, how many build steps have completed, how many build steps have completed
269per second, and how long the build has been running, as shown here:
Bruce Dawsone9f20fff2018-03-03 01:58:38270
271```shell
Bruce Dawson89390172019-05-08 09:51:18272$ set NINJA_SUMMARIZE_BUILD=1
Bruce Dawsone9f20fff2018-03-03 01:58:38273$ autoninja -C out\Default base
274ninja: Entering directory `out\Default'
275[1 processes, 86/86 @ 2.7/s : 31.785s ] LINK(DLL) base.dll base.dll.lib base.dll.pdb
276```
277
Bruce Dawson89390172019-05-08 09:51:18278This makes slow process creation immediately obvious and lets you tell quickly
279if a build is running more slowly than normal.
280
281In addition, setting ``NINJA_SUMMARIZE_BUILD=1`` tells ``autoninja`` to print a
282build performance summary when the build completes, showing the slowest build
283steps and slowest build-step types, as shown here:
Bruce Dawsone9f20fff2018-03-03 01:58:38284
285```shell
286$ set NINJA_SUMMARIZE_BUILD=1
287$ autoninja -C out\Default base
Bruce Dawson2721f0b2019-11-08 18:41:27288Longest build steps:
289 0.1 weighted s to build obj/base/base/trace_log.obj (6.7 s elapsed time)
290 0.2 weighted s to build nasm.exe, nasm.exe.pdb (0.2 s elapsed time)
291 0.3 weighted s to build obj/base/base/win_util.obj (12.4 s elapsed time)
292 1.2 weighted s to build base.dll, base.dll.lib (1.2 s elapsed time)
293Time by build-step type:
294 0.0 s weighted time to generate 6 .lib files (0.3 s elapsed time sum)
295 0.1 s weighted time to generate 25 .stamp files (1.2 s elapsed time sum)
296 0.2 s weighted time to generate 20 .o files (2.8 s elapsed time sum)
297 1.7 s weighted time to generate 4 PEFile (linking) files (2.0 s elapsed
298time sum)
299 23.9 s weighted time to generate 770 .obj files (974.8 s elapsed time sum)
30026.1 s weighted time (982.9 s elapsed time sum, 37.7x parallelism)
301839 build steps completed, average of 32.17/s
Bruce Dawsone9f20fff2018-03-03 01:58:38302```
303
Bruce Dawson2721f0b2019-11-08 18:41:27304The "weighted" time is the elapsed time of each build step divided by the number
305of tasks that were running in parallel. This makes it an excellent approximation
306of how "important" a slow step was. A link that is entirely or mostly serialized
307will have a weighted time that is the same or similar to its elapsed time. A
308compile that runs in parallel with 999 other compiles will have a weighted time
309that is tiny.
310
Bruce Dawson0bbe2d42018-03-06 19:45:55311You can also generate these reports by manually running the script after a build:
312
313```shell
314$ python depot_tools\post_build_ninja_summary.py -C out\Default
315```
316
Bruce Dawsonb9988e92019-09-16 17:01:10317Finally, setting ``NINJA_SUMMARIZE_BUILD=1`` tells autoninja to tell Ninja to
318report on its own overhead by passing "-d stats". This can be helpful if, for
319instance, process creation (which shows up in the StartEdge metric) is making
320builds slow, perhaps due to antivirus interference due to clang-cl not being in
321an excluded directory:
Bruce Dawsone9f20fff2018-03-03 01:58:38322
323```shell
Bruce Dawsonb9988e92019-09-16 17:01:10324$ set NINJA_SUMMARIZE_BUILD=1
325$ autoninja -C out\Default base
326"c:\src\depot_tools\ninja.exe" -C out\Default base -j 10 -d stats
Bruce Dawsone9f20fff2018-03-03 01:58:38327metric count avg (us) total (ms)
328.ninja parse 3555 1539.4 5472.6
329canonicalize str 1383032 0.0 12.7
330canonicalize path 1402349 0.0 11.2
331lookup node 1398245 0.0 8.1
332.ninja_log load 2 118.0 0.2
333.ninja_deps load 2 67.5 0.1
334node stat 2516 29.6 74.4
335depfile load 2 1132.0 2.3
336StartEdge 88 3508.1 308.7
337FinishCommand 87 1670.9 145.4
338CLParser::Parse 45 1889.1 85.0
339```
340
Bruce Dawsonb9988e92019-09-16 17:01:10341You can also get a visual report of the build performance with
342[ninjatracing](https://github.com/nico/ninjatracing). This converts the
343.ninja_log file into a .json file which can be loaded into chrome://tracing:
344
345```shell
346$ python ninjatracing out\Default\.ninja_log >build.json
347```
348
dpranke0ae7cad2016-11-30 07:47:58349## Build Chromium
350
Max Morozf5b31fcd2018-08-10 21:55:48351Build Chromium (the "chrome" target) with Ninja using the command:
dpranke0ae7cad2016-11-30 07:47:58352
dpranke1a70d0c2016-12-01 02:42:29353```shell
Max Morozf5b31fcd2018-08-10 21:55:48354$ autoninja -C out\Default chrome
dpranke1a70d0c2016-12-01 02:42:29355```
dpranke0ae7cad2016-11-30 07:47:58356
Max Morozf5b31fcd2018-08-10 21:55:48357`autoninja` is a wrapper that automatically provides optimal values for the
358arguments passed to `ninja`.
359
dpranke0ae7cad2016-11-30 07:47:58360You can get a list of all of the other build targets from GN by running
361`gn ls out/Default` from the command line. To compile one, pass to Ninja
362the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
363use ninja -C out/Default chrome/test:unit_tests`).
364
365## Run Chromium
366
367Once it is built, you can simply run the browser:
368
dpranke1a70d0c2016-12-01 02:42:29369```shell
370$ out\Default\chrome.exe
371```
372
373(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58374
375## Running test targets
376
377You can run the tests in the same way. You can also limit which tests are
378run using the `--gtest_filter` arg, e.g.:
379
dpranke1a70d0c2016-12-01 02:42:29380```shell
381$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
382```
dpranke0ae7cad2016-11-30 07:47:58383
384You can find out more about GoogleTest at its
385[GitHub page](https://github.com/google/googletest).
386
387## Update your checkout
388
389To update an existing checkout, you can run
390
dpranke1a70d0c2016-12-01 02:42:29391```shell
392$ git rebase-update
Bruce Dawsonef0b5452020-10-03 00:13:09393$ gclient sync -D
dpranke1a70d0c2016-12-01 02:42:29394```
dpranke0ae7cad2016-11-30 07:47:58395
396The first command updates the primary Chromium source repository and rebases
Andrew Williamsbbc1a1e2021-07-21 01:51:22397any of your local branches on top of tip-of-tree (aka the Git branch
398`origin/main`). If you don't want to use this script, you can also just use
399`git pull` or other common Git commands to update the repo.
dpranke0ae7cad2016-11-30 07:47:58400
Bruce Dawsonef0b5452020-10-03 00:13:09401The second command syncs the subrepositories to the appropriate versions,
402deleting those that are no longer needed, and re-runs the hooks as needed.
403
404### Editing and Debugging With the Visual Studio IDE
405
406You can use the Visual Studio IDE to edit and debug Chrome, with or without
407Intellisense support.
408
409#### Using Visual Studio Intellisense
410
411If you want to use Visual Studio Intellisense when developing Chromium, use the
412`--ide` command line argument to `gn gen` when you generate your output
413directory (as described on the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code)
414page):
415
416```shell
417$ gn gen --ide=vs out\Default
418$ devenv out\Default\all.sln
419```
420
421GN will produce a file `all.sln` in your build directory. It will internally
422use Ninja to compile while still allowing most IDE functions to work (there is
423no native Visual Studio compilation mode). If you manually run "gen" again you
424will need to resupply this argument, but normally GN will keep the build and
425IDE files up to date automatically when you build.
426
427The generated solution will contain several thousand projects and will be very
428slow to load. Use the `--filters` argument to restrict generating project files
429for only the code you're interested in. Although this will also limit what
430files appear in the project explorer, debugging will still work and you can
431set breakpoints in files that you open manually. A minimal solution that will
432let you compile and run Chrome in the IDE but will not show any source files
433is:
434
435```
436$ gn gen --ide=vs --filters=//chrome --no-deps out\Default
437```
438
439You can selectively add other directories you care about to the filter like so:
440`--filters=//chrome;//third_party/WebKit/*;//gpu/*`.
441
442There are other options for controlling how the solution is generated, run `gn
443help gen` for the current documentation.
444
445#### Using Visual Studio without Intellisense
446
447It is also possible to debug and develop Chrome in Visual Studio without the
448overhead of a multi-project solution file. Simply "open" your chrome.exe binary
449with `File->Open->Project/Solution`, or from a Visual Studio command prompt like
450so: `devenv /debugexe out\Debug\chrome.exe <your arguments>`. Many of Visual
451Studio's code exploration features will not work in this configuration, but by
452installing the [VsChromium Visual Studio Extension](https://chromium.github.io/vs-chromium/)
453you can get the source code to appear in the solution explorer window along
454with other useful features such as code search. You can add multiple executables
455of interest (base_unittests.exe, browser_tests.exe) to your solution with
456`File->Add->Existing Project...` and change which one will be debugged by
457right-clicking on them in `Solution Explorer` and selecting `Set as Startup
458Project`. You can also change their properties, including command line
459arguments, by right-clicking on them in `Solution Explorer` and selecting
460`Properties`.
461
462By default when you start debugging in Visual Studio the debugger will only
463attach to the main browser process. To debug all of Chrome, install
464[Microsoft's Child Process Debugging Power Tool](https://blogs.msdn.microsoft.com/devops/2014/11/24/introducing-the-child-process-debugging-power-tool/).
465You will also need to run Visual Studio as administrator, or it will silently
466fail to attach to some of Chrome's child processes.
467