blob: 9a3207b626d8d21a56f453023be43e4afec1092f [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.
dpranke0ae7cad2016-11-30 07:47:5819* Visual Studio 2015 Update 3, see below (no other version is supported).
20* Windows 7 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 Dawson91958392017-09-28 21:03:5826As of September, 2017 Chromium requires Visual Studio 2017 update 3.2 with the
2715063 (Creators Update) Windows SDK or later to build. Visual Studio Community
28Edition should work if its license is appropriate for you. You must install the
Bruce Dawson1c0979a62017-09-13 17:47:2129VC++ toolchain and MFC. This can be done from the command line like this:
30```shell
31vs_professional.exe --add Microsoft.VisualStudio.Workload.NativeDesktop
32 --add Microsoft.VisualStudio.Component.VC.ATLMFC --includeRecommended
33```
Bruce Dawson91958392017-09-28 21:03:5834You must have the Windows 10 SDK installed, version 10.0.15063 or later.
35The 10.0.15063 SDK initially had errors but the 10.0.15063.468 version works
36well. Most of this will be installed by Visual Studio.
pwnall43b43ba2016-08-22 19:29:2937
Bruce Dawson4d1de592017-09-08 00:24:0038If the Windows 10 SDK was installed via the Visual Studio installer, the Debugging
Robert Sesekc8ffa1b2017-08-04 19:55:2239Tools can be installed by going to: Control Panel Programs
Bruce Dawson4d1de592017-09-08 00:24:0040Programs and Features Select the "Windows Software Development Kit"
Bruce Dawson1c0979a62017-09-13 17:47:2141Change Change Check "Debugging Tools For Windows" Change. Or, you can
Bruce Dawson91958392017-09-28 21:03:5842download the standalone SDK installer and use it to install the Debugging Tools.
Robert Sesekc8ffa1b2017-08-04 19:55:2243
dpranke0ae7cad2016-11-30 07:47:5844## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1045
dpranke1a70d0c2016-12-01 02:42:2946Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5847and extract it somewhere.
tfarina502f3882016-03-23 12:48:1048
dpranke0ae7cad2016-11-30 07:47:5849*** note
50**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
51this will not extract the hidden “.git folder which is necessary for
Bruce Dawson4d1de592017-09-08 00:24:0052depot_tools to autoupdate itself. You can use Extract all…” from the
dpranke0ae7cad2016-11-30 07:47:5853context menu though.
54***
tfarina502f3882016-03-23 12:48:1055
Bruce Dawson4d1de592017-09-08 00:24:0056Add depot_tools to the start of your PATH (must be ahead of any installs of
dpranke4b470c5b2017-01-19 17:38:0457Python). Assuming you unzipped the bundle to C:\src\depot_tools, open:
tfarina502f3882016-03-23 12:48:1058
dpranke0ae7cad2016-11-30 07:47:5859Control Panel System and Security System Advanced system settings
tfarina502f3882016-03-23 12:48:1060
dpranke4b470c5b2017-01-19 17:38:0461If you have Administrator access, Modify the PATH system variable and
62put `C:\src\depot_tools` at the front (or at least in front of any directory
63that might already have a copy of Python or Git).
tfarina502f3882016-03-23 12:48:1064
dpranke4b470c5b2017-01-19 17:38:0465If you don't have Administrator access, you can add a user-level PATH
66environment variable and put `C:\src\depot_tools` at the front, but
67if your system PATH has a Python in it, you will be out of luck.
dpranke0ae7cad2016-11-30 07:47:5868
69Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set
70it to 0. This tells depot_tools to use your locally installed version of Visual
71Studio (by default, depot_tools will try to use a google-internal version).
72
73From a cmd.exe shell, run the command gclient (without arguments). On first
74run, gclient will install all the Windows-specific bits needed to work with
75the code, including msysgit and python.
76
77* If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell),
78 it may appear to run properly, but msysgit, python, and other tools
79 may not get installed correctly.
80* If you see strange errors with the file system on the first run of gclient,
81 you may want to [disable Windows Indexing](http://tortoisesvn.tigris.org/faq.html#cantmove2).
82
Bruce Dawson4d1de592017-09-08 00:24:0083After running gclient open a command prompt and type `where python` and
84confirm that the depot_tools `python.bat` comes ahead of any copies of
85python.exe. Failing to ensure this can lead to overbuilding when
dpranke0ae7cad2016-11-30 07:47:5886using gn - see [crbug.com/611087](https://crbug.com/611087).
87
88## Get the code
89
Leonard Mosescu718c9ac2017-06-20 18:06:3290First, configure Git:
91
92```shell
93$ git config --global user.name "My Name"
94$ git config --global user.email "[email protected]"
95$ git config --global core.autocrlf false
96$ git config --global core.filemode false
97$ git config --global branch.autosetuprebase always
98```
99
sdy93387fa2016-12-01 01:03:44100Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:58101this whatever you like and put it wherever you like, as
102long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:58103
sdy93387fa2016-12-01 01:03:44104```shell
105$ mkdir chromium && cd chromium
106```
107
108Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58109dependencies.
110
sdy93387fa2016-12-01 01:03:44111```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30112$ fetch chromium
sdy93387fa2016-12-01 01:03:44113```
dpranke0ae7cad2016-11-30 07:47:58114
115If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44116adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58117
sdy93387fa2016-12-01 01:03:44118Expect the command to take 30 minutes on even a fast connection, and many
119hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58120
sdy93387fa2016-12-01 01:03:44121When `fetch` completes, it will have created a hidden `.gclient` file and a
122directory called `src` in the working directory. The remaining instructions
123assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58124
sdy93387fa2016-12-01 01:03:44125```shell
126$ cd src
127```
dpranke0ae7cad2016-11-30 07:47:58128
sdy93387fa2016-12-01 01:03:44129*Optional*: You can also [install API
130keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
131build to talk to some Google services, but this is not necessary for most
132development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58133
dpranke1a70d0c2016-12-01 02:42:29134## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58135
sdy93387fa2016-12-01 01:03:44136Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
137with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
138files. You can create any number of *build directories* with different
139configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58140
sdy93387fa2016-12-01 01:03:44141```shell
142$ gn gen out/Default
143```
dpranke0ae7cad2016-11-30 07:47:58144
sdy93387fa2016-12-01 01:03:44145* You only have to run this once for each new build directory, Ninja will
146 update the build files as needed.
147* You can replace `Default` with another name, but
148 it should be a subdirectory of `out`.
149* For other build arguments, including release settings, see [GN build
150 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58151 The default will be a debug component build matching the current host
152 operating system and CPU.
153* For more info on GN, run `gn help` on the command line or read the
154 [quick start guide](../tools/gn/docs/quick_start.md).
155
156### Using the Visual Studio IDE
tfarina502f3882016-03-23 12:48:10157
brettwc25693b32016-05-26 01:11:52158If you want to use the Visual Studio IDE, use the `--ide` command line
159argument to `gn gen` when you generate your output directory (as described on
xiaoyin.l1003c0b2016-12-06 02:51:17160the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code)
brettwc25693b32016-05-26 01:11:52161page):
tfarina502f3882016-03-23 12:48:10162
dpranke1a70d0c2016-12-01 02:42:29163```shell
164$ gn gen --ide=vs out\Default
165$ devenv out\Default\all.sln
tfarina502f3882016-03-23 12:48:10166```
167
brettwc25693b32016-05-26 01:11:52168GN will produce a file `all.sln` in your build directory. It will internally
169use Ninja to compile while still allowing most IDE functions to work (there is
170no native Visual Studio compilation mode). If you manually run "gen" again you
171will need to resupply this argument, but normally GN will keep the build and
thakis3e861de2016-06-14 14:24:01172IDE files up to date automatically when you build.
tfarina502f3882016-03-23 12:48:10173
brettwc25693b32016-05-26 01:11:52174The generated solution will contain several thousand projects and will be very
175slow to load. Use the `--filters` argument to restrict generating project files
176for only the code you're interested in, although this will also limit what
177files appear in the project explorer. A minimal solution that will let you
178compile and run Chrome in the IDE but will not show any source files is:
179
dpranke1a70d0c2016-12-01 02:42:29180```
181$ gn gen --ide=vs --filters=//chrome out\Default
182```
brettwc25693b32016-05-26 01:11:52183
184There are other options for controlling how the solution is generated, run `gn
185help gen` for the current documentation.
186
dpranke0ae7cad2016-11-30 07:47:58187### Faster builds
tfarina502f3882016-03-23 12:48:10188
dpranke0ae7cad2016-11-30 07:47:58189* Reduce file system overhead by excluding build directories from
190 antivirus and indexing software.
191* Store the build tree on a fast disk (preferably SSD).
brucedawsoncfc7fd52017-07-06 18:41:01192* The more cores the better (20+ is not excessive) and lots of RAM is needed
193(64 GB is not excessive).
tfarina502f3882016-03-23 12:48:10194
brucedawsoncfc7fd52017-07-06 18:41:01195There are some gn flags that can improve build speeds. You can specify these
196in the editor that appears when you create your output directory
197(`gn args out/Default`) or on the gn gen command line
198(`gn gen out/Default --args="is_component_build = true is_debug = true"`).
199Some helpful settings to consider using include:
Bruce Dawsonfcd3deb12017-07-28 17:12:20200* `use_jumbo_build = true` - *Experimental* [Jumbo/unity](jumbo.md) builds.
brucedawsoncfc7fd52017-07-06 18:41:01201* `is_component_build = true` - this uses more, smaller DLLs, and incremental
202linking.
Bruce Dawsonfcd3deb12017-07-28 17:12:20203* `enable_nacl = false` - this disables Native Client which is usually not
204needed for local builds.
brucedawsoncfc7fd52017-07-06 18:41:01205* `target_cpu = "x86"` - x86 builds are slightly faster than x64 builds and
206support incremental linking for more targets. Note that if you set this but
Bruce Dawsonfcd3deb12017-07-28 17:12:20207don't' set enable_nacl = false then build times may get worse.
brucedawsoncfc7fd52017-07-06 18:41:01208* `remove_webcore_debug_symbols = true` - turn off source-level debugging for
209blink to reduce build times, appropriate if you don't plan to debug blink.
brucedawsoncfc7fd52017-07-06 18:41:01210* `win_linker_timing = true` - this should not generally be set but can be
211helpful when trying to understand build times or incremental linking failures.
212
213In addition, Google employees should consider using goma, a distributed
214compilation system. Detailed information is available internally but the
215relevant gn args are:
216* `use_goma = true`
217* `symbol_level = 2` - by default goma builds change symbol_level from 2 to 1
218which disables source-level debugging. This turns it back on. This actually
219makes builds slower, but it makes goma more usable.
220* `is_win_fastlink = true` - this is required if you have goma enabled and
221symbol_level set to 2.
222
223Note that debugging of is_win_fastlink built binaries is unreliable prior to
224VS 2017 Update 3 and may crash Visual Studio.
225
226To get any benefit from goma it is important to pass a large -j value to ninja.
227A good default is 10\*numCores to 20\*numCores. If you run autoninja.bat then it
228will pass an appropriate -j value to ninja for goma or not, automatically.
229
230When invoking ninja specify 'chrome' as the target to avoid building all test
231binaries as well.
232
233Still, builds will take many hours on many machines.
dpranke0ae7cad2016-11-30 07:47:58234
235## Build Chromium
236
237Build Chromium (the "chrome" target) with Ninja using the command:
238
dpranke1a70d0c2016-12-01 02:42:29239```shell
240$ ninja -C out\Default chrome
241```
dpranke0ae7cad2016-11-30 07:47:58242
243You can get a list of all of the other build targets from GN by running
244`gn ls out/Default` from the command line. To compile one, pass to Ninja
245the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
246use ninja -C out/Default chrome/test:unit_tests`).
247
248## Run Chromium
249
250Once it is built, you can simply run the browser:
251
dpranke1a70d0c2016-12-01 02:42:29252```shell
253$ out\Default\chrome.exe
254```
255
256(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58257
258## Running test targets
259
260You can run the tests in the same way. You can also limit which tests are
261run using the `--gtest_filter` arg, e.g.:
262
dpranke1a70d0c2016-12-01 02:42:29263```shell
264$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
265```
dpranke0ae7cad2016-11-30 07:47:58266
267You can find out more about GoogleTest at its
268[GitHub page](https://github.com/google/googletest).
269
270## Update your checkout
271
272To update an existing checkout, you can run
273
dpranke1a70d0c2016-12-01 02:42:29274```shell
275$ git rebase-update
276$ gclient sync
277```
dpranke0ae7cad2016-11-30 07:47:58278
279The first command updates the primary Chromium source repository and rebases
280any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
Bruce Dawson4d1de592017-09-08 00:24:00281If you don't want to use this script, you can also just use `git pull` or
dpranke0ae7cad2016-11-30 07:47:58282other common Git commands to update the repo.
283
284The second command syncs the subrepositories to the appropriate versions and
285re-runs the hooks as needed.