blob: 7508e26e36943bd0599803b486df848059d35207 [file] [log] [blame] [view]
dpranke1a70d0c2016-12-01 02:42:291# Checking out and Building Chromium for Windows
2
3There are instructions for other platforms linked from the
4[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
scottmga335ca32016-12-08 18:25:4626As of December 8, 2016 Chromium requires Visual Studio 2015, with the 14393
27Windows SDK to build.
tfarina502f3882016-03-23 12:48:1028
scottmg740b32d82016-11-03 15:54:5329Install Visual Studio 2015 Update 3 or later - Community Edition
brucedawsonc2186342016-04-15 18:27:3430should work if its license is appropriate for you. Use the Custom Install option
31and select:
tfarina502f3882016-03-23 12:48:1032
brucedawsonc2186342016-04-15 18:27:3433- Visual C++, which will select three sub-categories including MFC
scottmga335ca32016-12-08 18:25:4634- Universal Windows Apps Development Tools > Tools (1.4.1) and Windows 10 SDK
35 (10.0.14393)
tfarina502f3882016-03-23 12:48:1036
brucedawson806105702017-04-26 23:39:3937You must have the 14393 Windows SDK installed - the 15063 SDK has errors and
38cannot be used to compile Chrome. It is okay to have multiple SDK versions
39installed as long as 14393 is one of them. The installer can be found in the
40[Windows SDK archive](https://developer.microsoft.com/en-us/windows/downloads/sdk-archive).
Daniel Cheng8f817e342016-04-01 17:28:4841
brucedawson806105702017-04-26 23:39:3942When installing the 14393 Windows SDK choose Debugging Tools For Windows in
43order to get windbg and cdb. The latter is required for the build to succeed as
44some tests use it for symbolizing crash dumps.
pwnall43b43ba2016-08-22 19:29:2945
Robert Sesekc8ffa1b2017-08-04 19:55:2246If the Windows SDK was installed via the Visual Studio installer, the Debugging
47Tools can be installed by going to: Control Panel Programs
48Programs and Features Select the "Windows Software Development Kit" v14393
49Change Change Check "Debugging Tools For Windows" Change.
50
dpranke0ae7cad2016-11-30 07:47:5851## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1052
dpranke1a70d0c2016-12-01 02:42:2953Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5854and extract it somewhere.
tfarina502f3882016-03-23 12:48:1055
dpranke0ae7cad2016-11-30 07:47:5856*** note
57**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
58this will not extract the hidden “.git folder which is necessary for
59depot_tools to autoupdate itself. You can use Extract all…” from the
60context menu though.
61***
tfarina502f3882016-03-23 12:48:1062
dpranke0ae7cad2016-11-30 07:47:5863Add depot_tools to the start of your PATH (must be ahead of any installs of
dpranke4b470c5b2017-01-19 17:38:0464Python). Assuming you unzipped the bundle to C:\src\depot_tools, open:
tfarina502f3882016-03-23 12:48:1065
dpranke0ae7cad2016-11-30 07:47:5866Control Panel System and Security System Advanced system settings
tfarina502f3882016-03-23 12:48:1067
dpranke4b470c5b2017-01-19 17:38:0468If you have Administrator access, Modify the PATH system variable and
69put `C:\src\depot_tools` at the front (or at least in front of any directory
70that might already have a copy of Python or Git).
tfarina502f3882016-03-23 12:48:1071
dpranke4b470c5b2017-01-19 17:38:0472If you don't have Administrator access, you can add a user-level PATH
73environment variable and put `C:\src\depot_tools` at the front, but
74if your system PATH has a Python in it, you will be out of luck.
dpranke0ae7cad2016-11-30 07:47:5875
76Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set
77it to 0. This tells depot_tools to use your locally installed version of Visual
78Studio (by default, depot_tools will try to use a google-internal version).
79
80From a cmd.exe shell, run the command gclient (without arguments). On first
81run, gclient will install all the Windows-specific bits needed to work with
82the code, including msysgit and python.
83
84* If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell),
85 it may appear to run properly, but msysgit, python, and other tools
86 may not get installed correctly.
87* If you see strange errors with the file system on the first run of gclient,
88 you may want to [disable Windows Indexing](http://tortoisesvn.tigris.org/faq.html#cantmove2).
89
90After running gclient open a command prompt and type `where python` and
91confirm that the depot_tools `python.bat` comes ahead of any copies of
92python.exe. Failing to ensure this can lead to overbuilding when
93using gn - see [crbug.com/611087](https://crbug.com/611087).
94
95## Get the code
96
Leonard Mosescu718c9ac2017-06-20 18:06:3297First, configure Git:
98
99```shell
100$ git config --global user.name "My Name"
101$ git config --global user.email "[email protected]"
102$ git config --global core.autocrlf false
103$ git config --global core.filemode false
104$ git config --global branch.autosetuprebase always
105```
106
sdy93387fa2016-12-01 01:03:44107Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:58108this whatever you like and put it wherever you like, as
109long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:58110
sdy93387fa2016-12-01 01:03:44111```shell
112$ mkdir chromium && cd chromium
113```
114
115Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58116dependencies.
117
sdy93387fa2016-12-01 01:03:44118```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30119$ fetch chromium
sdy93387fa2016-12-01 01:03:44120```
dpranke0ae7cad2016-11-30 07:47:58121
122If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44123adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58124
sdy93387fa2016-12-01 01:03:44125Expect the command to take 30 minutes on even a fast connection, and many
126hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58127
sdy93387fa2016-12-01 01:03:44128When `fetch` completes, it will have created a hidden `.gclient` file and a
129directory called `src` in the working directory. The remaining instructions
130assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58131
sdy93387fa2016-12-01 01:03:44132```shell
133$ cd src
134```
dpranke0ae7cad2016-11-30 07:47:58135
sdy93387fa2016-12-01 01:03:44136*Optional*: You can also [install API
137keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
138build to talk to some Google services, but this is not necessary for most
139development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58140
dpranke1a70d0c2016-12-01 02:42:29141## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58142
sdy93387fa2016-12-01 01:03:44143Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
144with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
145files. You can create any number of *build directories* with different
146configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58147
sdy93387fa2016-12-01 01:03:44148```shell
149$ gn gen out/Default
150```
dpranke0ae7cad2016-11-30 07:47:58151
sdy93387fa2016-12-01 01:03:44152* You only have to run this once for each new build directory, Ninja will
153 update the build files as needed.
154* You can replace `Default` with another name, but
155 it should be a subdirectory of `out`.
156* For other build arguments, including release settings, see [GN build
157 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58158 The default will be a debug component build matching the current host
159 operating system and CPU.
160* For more info on GN, run `gn help` on the command line or read the
161 [quick start guide](../tools/gn/docs/quick_start.md).
162
163### Using the Visual Studio IDE
tfarina502f3882016-03-23 12:48:10164
brettwc25693b32016-05-26 01:11:52165If you want to use the Visual Studio IDE, use the `--ide` command line
166argument to `gn gen` when you generate your output directory (as described on
xiaoyin.l1003c0b2016-12-06 02:51:17167the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code)
brettwc25693b32016-05-26 01:11:52168page):
tfarina502f3882016-03-23 12:48:10169
dpranke1a70d0c2016-12-01 02:42:29170```shell
171$ gn gen --ide=vs out\Default
172$ devenv out\Default\all.sln
tfarina502f3882016-03-23 12:48:10173```
174
brettwc25693b32016-05-26 01:11:52175GN will produce a file `all.sln` in your build directory. It will internally
176use Ninja to compile while still allowing most IDE functions to work (there is
177no native Visual Studio compilation mode). If you manually run "gen" again you
178will need to resupply this argument, but normally GN will keep the build and
thakis3e861de2016-06-14 14:24:01179IDE files up to date automatically when you build.
tfarina502f3882016-03-23 12:48:10180
brettwc25693b32016-05-26 01:11:52181The generated solution will contain several thousand projects and will be very
182slow to load. Use the `--filters` argument to restrict generating project files
183for only the code you're interested in, although this will also limit what
184files appear in the project explorer. A minimal solution that will let you
185compile and run Chrome in the IDE but will not show any source files is:
186
dpranke1a70d0c2016-12-01 02:42:29187```
188$ gn gen --ide=vs --filters=//chrome out\Default
189```
brettwc25693b32016-05-26 01:11:52190
191There are other options for controlling how the solution is generated, run `gn
192help gen` for the current documentation.
193
dpranke0ae7cad2016-11-30 07:47:58194### Faster builds
tfarina502f3882016-03-23 12:48:10195
dpranke0ae7cad2016-11-30 07:47:58196* Reduce file system overhead by excluding build directories from
197 antivirus and indexing software.
198* Store the build tree on a fast disk (preferably SSD).
brucedawsoncfc7fd52017-07-06 18:41:01199* The more cores the better (20+ is not excessive) and lots of RAM is needed
200(64 GB is not excessive).
tfarina502f3882016-03-23 12:48:10201
brucedawsoncfc7fd52017-07-06 18:41:01202There are some gn flags that can improve build speeds. You can specify these
203in the editor that appears when you create your output directory
204(`gn args out/Default`) or on the gn gen command line
205(`gn gen out/Default --args="is_component_build = true is_debug = true"`).
206Some helpful settings to consider using include:
Bruce Dawsonfcd3deb12017-07-28 17:12:20207* `use_jumbo_build = true` - *Experimental* [Jumbo/unity](jumbo.md) builds.
brucedawsoncfc7fd52017-07-06 18:41:01208* `is_component_build = true` - this uses more, smaller DLLs, and incremental
209linking.
Bruce Dawsonfcd3deb12017-07-28 17:12:20210* `enable_nacl = false` - this disables Native Client which is usually not
211needed for local builds.
brucedawsoncfc7fd52017-07-06 18:41:01212* `target_cpu = "x86"` - x86 builds are slightly faster than x64 builds and
213support incremental linking for more targets. Note that if you set this but
Bruce Dawsonfcd3deb12017-07-28 17:12:20214don't' set enable_nacl = false then build times may get worse.
brucedawsoncfc7fd52017-07-06 18:41:01215* `remove_webcore_debug_symbols = true` - turn off source-level debugging for
216blink to reduce build times, appropriate if you don't plan to debug blink.
brucedawsoncfc7fd52017-07-06 18:41:01217* `win_linker_timing = true` - this should not generally be set but can be
218helpful when trying to understand build times or incremental linking failures.
219
220In addition, Google employees should consider using goma, a distributed
221compilation system. Detailed information is available internally but the
222relevant gn args are:
223* `use_goma = true`
224* `symbol_level = 2` - by default goma builds change symbol_level from 2 to 1
225which disables source-level debugging. This turns it back on. This actually
226makes builds slower, but it makes goma more usable.
227* `is_win_fastlink = true` - this is required if you have goma enabled and
228symbol_level set to 2.
229
230Note that debugging of is_win_fastlink built binaries is unreliable prior to
231VS 2017 Update 3 and may crash Visual Studio.
232
233To get any benefit from goma it is important to pass a large -j value to ninja.
234A good default is 10\*numCores to 20\*numCores. If you run autoninja.bat then it
235will pass an appropriate -j value to ninja for goma or not, automatically.
236
237When invoking ninja specify 'chrome' as the target to avoid building all test
238binaries as well.
239
240Still, builds will take many hours on many machines.
dpranke0ae7cad2016-11-30 07:47:58241
242## Build Chromium
243
244Build Chromium (the "chrome" target) with Ninja using the command:
245
dpranke1a70d0c2016-12-01 02:42:29246```shell
247$ ninja -C out\Default chrome
248```
dpranke0ae7cad2016-11-30 07:47:58249
250You can get a list of all of the other build targets from GN by running
251`gn ls out/Default` from the command line. To compile one, pass to Ninja
252the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
253use ninja -C out/Default chrome/test:unit_tests`).
254
255## Run Chromium
256
257Once it is built, you can simply run the browser:
258
dpranke1a70d0c2016-12-01 02:42:29259```shell
260$ out\Default\chrome.exe
261```
262
263(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58264
265## Running test targets
266
267You can run the tests in the same way. You can also limit which tests are
268run using the `--gtest_filter` arg, e.g.:
269
dpranke1a70d0c2016-12-01 02:42:29270```shell
271$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
272```
dpranke0ae7cad2016-11-30 07:47:58273
274You can find out more about GoogleTest at its
275[GitHub page](https://github.com/google/googletest).
276
277## Update your checkout
278
279To update an existing checkout, you can run
280
dpranke1a70d0c2016-12-01 02:42:29281```shell
282$ git rebase-update
283$ gclient sync
284```
dpranke0ae7cad2016-11-30 07:47:58285
286The first command updates the primary Chromium source repository and rebases
287any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
288If you don't want to use this script, you can also just use `git pull` or
289other common Git commands to update the repo.
290
291The second command syncs the subrepositories to the appropriate versions and
292re-runs the hooks as needed.