blob: c4c282c6d89c2a6c62c6ef90fa8210c208b2decc [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
dpranke0ae7cad2016-11-30 07:47:5846## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1047
dpranke1a70d0c2016-12-01 02:42:2948Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5849and extract it somewhere.
tfarina502f3882016-03-23 12:48:1050
dpranke0ae7cad2016-11-30 07:47:5851*** note
52**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
53this will not extract the hidden “.git folder which is necessary for
54depot_tools to autoupdate itself. You can use Extract all…” from the
55context menu though.
56***
tfarina502f3882016-03-23 12:48:1057
dpranke0ae7cad2016-11-30 07:47:5858Add depot_tools to the start of your PATH (must be ahead of any installs of
dpranke4b470c5b2017-01-19 17:38:0459Python). Assuming you unzipped the bundle to C:\src\depot_tools, open:
tfarina502f3882016-03-23 12:48:1060
dpranke0ae7cad2016-11-30 07:47:5861Control Panel System and Security System Advanced system settings
tfarina502f3882016-03-23 12:48:1062
dpranke4b470c5b2017-01-19 17:38:0463If you have Administrator access, Modify the PATH system variable and
64put `C:\src\depot_tools` at the front (or at least in front of any directory
65that might already have a copy of Python or Git).
tfarina502f3882016-03-23 12:48:1066
dpranke4b470c5b2017-01-19 17:38:0467If you don't have Administrator access, you can add a user-level PATH
68environment variable and put `C:\src\depot_tools` at the front, but
69if your system PATH has a Python in it, you will be out of luck.
dpranke0ae7cad2016-11-30 07:47:5870
71Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set
72it to 0. This tells depot_tools to use your locally installed version of Visual
73Studio (by default, depot_tools will try to use a google-internal version).
74
75From a cmd.exe shell, run the command gclient (without arguments). On first
76run, gclient will install all the Windows-specific bits needed to work with
77the code, including msysgit and python.
78
79* If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell),
80 it may appear to run properly, but msysgit, python, and other tools
81 may not get installed correctly.
82* If you see strange errors with the file system on the first run of gclient,
83 you may want to [disable Windows Indexing](http://tortoisesvn.tigris.org/faq.html#cantmove2).
84
85After running gclient open a command prompt and type `where python` and
86confirm that the depot_tools `python.bat` comes ahead of any copies of
87python.exe. Failing to ensure this can lead to overbuilding when
88using gn - see [crbug.com/611087](https://crbug.com/611087).
89
90## Get the code
91
Leonard Mosescu718c9ac2017-06-20 18:06:3292First, configure Git:
93
94```shell
95$ git config --global user.name "My Name"
96$ git config --global user.email "[email protected]"
97$ git config --global core.autocrlf false
98$ git config --global core.filemode false
99$ git config --global branch.autosetuprebase always
100```
101
sdy93387fa2016-12-01 01:03:44102Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:58103this whatever you like and put it wherever you like, as
104long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:58105
sdy93387fa2016-12-01 01:03:44106```shell
107$ mkdir chromium && cd chromium
108```
109
110Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58111dependencies.
112
sdy93387fa2016-12-01 01:03:44113```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30114$ fetch chromium
sdy93387fa2016-12-01 01:03:44115```
dpranke0ae7cad2016-11-30 07:47:58116
117If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44118adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58119
sdy93387fa2016-12-01 01:03:44120Expect the command to take 30 minutes on even a fast connection, and many
121hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58122
sdy93387fa2016-12-01 01:03:44123When `fetch` completes, it will have created a hidden `.gclient` file and a
124directory called `src` in the working directory. The remaining instructions
125assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58126
sdy93387fa2016-12-01 01:03:44127```shell
128$ cd src
129```
dpranke0ae7cad2016-11-30 07:47:58130
sdy93387fa2016-12-01 01:03:44131*Optional*: You can also [install API
132keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
133build to talk to some Google services, but this is not necessary for most
134development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58135
dpranke1a70d0c2016-12-01 02:42:29136## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58137
sdy93387fa2016-12-01 01:03:44138Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
139with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
140files. You can create any number of *build directories* with different
141configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58142
sdy93387fa2016-12-01 01:03:44143```shell
144$ gn gen out/Default
145```
dpranke0ae7cad2016-11-30 07:47:58146
sdy93387fa2016-12-01 01:03:44147* You only have to run this once for each new build directory, Ninja will
148 update the build files as needed.
149* You can replace `Default` with another name, but
150 it should be a subdirectory of `out`.
151* For other build arguments, including release settings, see [GN build
152 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58153 The default will be a debug component build matching the current host
154 operating system and CPU.
155* For more info on GN, run `gn help` on the command line or read the
156 [quick start guide](../tools/gn/docs/quick_start.md).
157
158### Using the Visual Studio IDE
tfarina502f3882016-03-23 12:48:10159
brettwc25693b32016-05-26 01:11:52160If you want to use the Visual Studio IDE, use the `--ide` command line
161argument to `gn gen` when you generate your output directory (as described on
xiaoyin.l1003c0b2016-12-06 02:51:17162the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code)
brettwc25693b32016-05-26 01:11:52163page):
tfarina502f3882016-03-23 12:48:10164
dpranke1a70d0c2016-12-01 02:42:29165```shell
166$ gn gen --ide=vs out\Default
167$ devenv out\Default\all.sln
tfarina502f3882016-03-23 12:48:10168```
169
brettwc25693b32016-05-26 01:11:52170GN will produce a file `all.sln` in your build directory. It will internally
171use Ninja to compile while still allowing most IDE functions to work (there is
172no native Visual Studio compilation mode). If you manually run "gen" again you
173will need to resupply this argument, but normally GN will keep the build and
thakis3e861de2016-06-14 14:24:01174IDE files up to date automatically when you build.
tfarina502f3882016-03-23 12:48:10175
brettwc25693b32016-05-26 01:11:52176The generated solution will contain several thousand projects and will be very
177slow to load. Use the `--filters` argument to restrict generating project files
178for only the code you're interested in, although this will also limit what
179files appear in the project explorer. A minimal solution that will let you
180compile and run Chrome in the IDE but will not show any source files is:
181
dpranke1a70d0c2016-12-01 02:42:29182```
183$ gn gen --ide=vs --filters=//chrome out\Default
184```
brettwc25693b32016-05-26 01:11:52185
186There are other options for controlling how the solution is generated, run `gn
187help gen` for the current documentation.
188
dpranke0ae7cad2016-11-30 07:47:58189### Faster builds
tfarina502f3882016-03-23 12:48:10190
dpranke0ae7cad2016-11-30 07:47:58191* Reduce file system overhead by excluding build directories from
192 antivirus and indexing software.
193* Store the build tree on a fast disk (preferably SSD).
brucedawsoncfc7fd52017-07-06 18:41:01194* The more cores the better (20+ is not excessive) and lots of RAM is needed
195(64 GB is not excessive).
tfarina502f3882016-03-23 12:48:10196
brucedawsoncfc7fd52017-07-06 18:41:01197There are some gn flags that can improve build speeds. You can specify these
198in the editor that appears when you create your output directory
199(`gn args out/Default`) or on the gn gen command line
200(`gn gen out/Default --args="is_component_build = true is_debug = true"`).
201Some helpful settings to consider using include:
202* `is_component_build = true` - this uses more, smaller DLLs, and incremental
203linking.
204* `use_nacl = false` - this disables Native Client which is usually not needed for
205local builds.
206* `target_cpu = "x86"` - x86 builds are slightly faster than x64 builds and
207support incremental linking for more targets. Note that if you set this but
208don't' set use_nacl = false then build times may get worse.
209* `remove_webcore_debug_symbols = true` - turn off source-level debugging for
210blink to reduce build times, appropriate if you don't plan to debug blink.
211* `use_jumbo_build = true` - compile multiple translation units as one, for
212faster builds (applies only to some components).
213* `win_linker_timing = true` - this should not generally be set but can be
214helpful when trying to understand build times or incremental linking failures.
215
216In addition, Google employees should consider using goma, a distributed
217compilation system. Detailed information is available internally but the
218relevant gn args are:
219* `use_goma = true`
220* `symbol_level = 2` - by default goma builds change symbol_level from 2 to 1
221which disables source-level debugging. This turns it back on. This actually
222makes builds slower, but it makes goma more usable.
223* `is_win_fastlink = true` - this is required if you have goma enabled and
224symbol_level set to 2.
225
226Note that debugging of is_win_fastlink built binaries is unreliable prior to
227VS 2017 Update 3 and may crash Visual Studio.
228
229To get any benefit from goma it is important to pass a large -j value to ninja.
230A good default is 10\*numCores to 20\*numCores. If you run autoninja.bat then it
231will pass an appropriate -j value to ninja for goma or not, automatically.
232
233When invoking ninja specify 'chrome' as the target to avoid building all test
234binaries as well.
235
236Still, builds will take many hours on many machines.
dpranke0ae7cad2016-11-30 07:47:58237
238## Build Chromium
239
240Build Chromium (the "chrome" target) with Ninja using the command:
241
dpranke1a70d0c2016-12-01 02:42:29242```shell
243$ ninja -C out\Default chrome
244```
dpranke0ae7cad2016-11-30 07:47:58245
246You can get a list of all of the other build targets from GN by running
247`gn ls out/Default` from the command line. To compile one, pass to Ninja
248the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
249use ninja -C out/Default chrome/test:unit_tests`).
250
251## Run Chromium
252
253Once it is built, you can simply run the browser:
254
dpranke1a70d0c2016-12-01 02:42:29255```shell
256$ out\Default\chrome.exe
257```
258
259(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58260
261## Running test targets
262
263You can run the tests in the same way. You can also limit which tests are
264run using the `--gtest_filter` arg, e.g.:
265
dpranke1a70d0c2016-12-01 02:42:29266```shell
267$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
268```
dpranke0ae7cad2016-11-30 07:47:58269
270You can find out more about GoogleTest at its
271[GitHub page](https://github.com/google/googletest).
272
273## Update your checkout
274
275To update an existing checkout, you can run
276
dpranke1a70d0c2016-12-01 02:42:29277```shell
278$ git rebase-update
279$ gclient sync
280```
dpranke0ae7cad2016-11-30 07:47:58281
282The first command updates the primary Chromium source repository and rebases
283any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
284If you don't want to use this script, you can also just use `git pull` or
285other common Git commands to update the repo.
286
287The second command syncs the subrepositories to the appropriate versions and
288re-runs the hooks as needed.