blob: 45cb30602160aacc0ba3aa1c1fe7a08572038c8f [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
dpranke0ae7cad2016-11-30 07:47:586**See also [the old version of this page](old_linux_build_instructions.md).**
brettwc25693b32016-05-26 01:11:527
dpranke1a70d0c2016-12-01 02:42:298## Instructions for Google Employees
9
10Are you a Google employee? See
11[go/building-chrome](https://goto.google.com/building-chrome) instead.
dpranke0ae7cad2016-11-30 07:47:5812
13[TOC]
14
15## System requirements
16
17* A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly
18 recommended.
19* At least 100GB of free disk space.
20* Visual Studio 2015 Update 3, see below (no other version is supported).
21* Windows 7 or newer.
brettwc25693b32016-05-26 01:11:5222
tfarina502f3882016-03-23 12:48:1023## Setting up Windows
24
dpranke0ae7cad2016-11-30 07:47:5825### Visual Studio
tfarina502f3882016-03-23 12:48:1026
brucedawsonc2186342016-04-15 18:27:3427As of March 11, 2016 Chromium requires Visual Studio 2015 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
34- Universal Windows Apps Development Tools > Tools
35- Universal Windows Apps Development Tools > Windows 10 SDK (10.0.10586)
tfarina502f3882016-03-23 12:48:1036
brucedawsonc2186342016-04-15 18:27:3437You must have the 10586 SDK installed or else you will hit compile errors such
38as redefined macros.
Daniel Cheng8f817e342016-04-01 17:28:4839
dpranke1a70d0c2016-12-01 02:42:2940Install the Windows SDK 10, and choose Debugging Tools For Windows when you
41install this in order to get windbg.
pwnall43b43ba2016-08-22 19:29:2942
dpranke0ae7cad2016-11-30 07:47:5843## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1044
dpranke1a70d0c2016-12-01 02:42:2945Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5846and extract it somewhere.
tfarina502f3882016-03-23 12:48:1047
dpranke0ae7cad2016-11-30 07:47:5848*** note
49**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
50this will not extract the hidden “.git folder which is necessary for
51depot_tools to autoupdate itself. You can use Extract all…” from the
52context menu though.
53***
tfarina502f3882016-03-23 12:48:1054
dpranke0ae7cad2016-11-30 07:47:5855Add depot_tools to the start of your PATH (must be ahead of any installs of
56Python). Assuming you unzipped the bundle to C:\src\depot_tools:
tfarina502f3882016-03-23 12:48:1057
dpranke0ae7cad2016-11-30 07:47:5858With Administrator access:
tfarina502f3882016-03-23 12:48:1059
dpranke0ae7cad2016-11-30 07:47:5860Control Panel System and Security System Advanced system settings
tfarina502f3882016-03-23 12:48:1061
dpranke0ae7cad2016-11-30 07:47:5862Modify the PATH system variable to include C:\src\depot_tools.
tfarina502f3882016-03-23 12:48:1063
dpranke0ae7cad2016-11-30 07:47:5864Without Administrator access:
65
66Control Panel User Accounts User Accounts Change my environment variables
67
dpranke1a70d0c2016-12-01 02:42:2968Add a PATH user variable (or modify the existing one to include):
69`C:\src\depot_tools`.
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
sdy93387fa2016-12-01 01:03:4492Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:5893this whatever you like and put it wherever you like, as
94long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:5895
sdy93387fa2016-12-01 01:03:4496```shell
97$ mkdir chromium && cd chromium
98```
99
100Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58101dependencies.
102
sdy93387fa2016-12-01 01:03:44103```shell
104$ fetch ios
105```
dpranke0ae7cad2016-11-30 07:47:58106
107If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44108adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58109
sdy93387fa2016-12-01 01:03:44110Expect the command to take 30 minutes on even a fast connection, and many
111hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58112
sdy93387fa2016-12-01 01:03:44113When `fetch` completes, it will have created a hidden `.gclient` file and a
114directory called `src` in the working directory. The remaining instructions
115assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58116
sdy93387fa2016-12-01 01:03:44117```shell
118$ cd src
119```
dpranke0ae7cad2016-11-30 07:47:58120
sdy93387fa2016-12-01 01:03:44121*Optional*: You can also [install API
122keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
123build to talk to some Google services, but this is not necessary for most
124development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58125
dpranke1a70d0c2016-12-01 02:42:29126## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58127
sdy93387fa2016-12-01 01:03:44128Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
129with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
130files. You can create any number of *build directories* with different
131configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58132
sdy93387fa2016-12-01 01:03:44133```shell
134$ gn gen out/Default
135```
dpranke0ae7cad2016-11-30 07:47:58136
sdy93387fa2016-12-01 01:03:44137* You only have to run this once for each new build directory, Ninja will
138 update the build files as needed.
139* You can replace `Default` with another name, but
140 it should be a subdirectory of `out`.
141* For other build arguments, including release settings, see [GN build
142 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58143 The default will be a debug component build matching the current host
144 operating system and CPU.
145* For more info on GN, run `gn help` on the command line or read the
146 [quick start guide](../tools/gn/docs/quick_start.md).
147
148### Using the Visual Studio IDE
tfarina502f3882016-03-23 12:48:10149
brettwc25693b32016-05-26 01:11:52150If you want to use the Visual Studio IDE, use the `--ide` command line
151argument to `gn gen` when you generate your output directory (as described on
152the [get the code](http://dev.chromium.org/developers/how-tos/get-the-code)
153page):
tfarina502f3882016-03-23 12:48:10154
dpranke1a70d0c2016-12-01 02:42:29155```shell
156$ gn gen --ide=vs out\Default
157$ devenv out\Default\all.sln
tfarina502f3882016-03-23 12:48:10158```
159
brettwc25693b32016-05-26 01:11:52160GN will produce a file `all.sln` in your build directory. It will internally
161use Ninja to compile while still allowing most IDE functions to work (there is
162no native Visual Studio compilation mode). If you manually run "gen" again you
163will need to resupply this argument, but normally GN will keep the build and
thakis3e861de2016-06-14 14:24:01164IDE files up to date automatically when you build.
tfarina502f3882016-03-23 12:48:10165
brettwc25693b32016-05-26 01:11:52166The generated solution will contain several thousand projects and will be very
167slow to load. Use the `--filters` argument to restrict generating project files
168for only the code you're interested in, although this will also limit what
169files appear in the project explorer. A minimal solution that will let you
170compile and run Chrome in the IDE but will not show any source files is:
171
dpranke1a70d0c2016-12-01 02:42:29172```
173$ gn gen --ide=vs --filters=//chrome out\Default
174```
brettwc25693b32016-05-26 01:11:52175
176There are other options for controlling how the solution is generated, run `gn
177help gen` for the current documentation.
178
dpranke0ae7cad2016-11-30 07:47:58179### Faster builds
tfarina502f3882016-03-23 12:48:10180
dpranke0ae7cad2016-11-30 07:47:58181* Reduce file system overhead by excluding build directories from
182 antivirus and indexing software.
183* Store the build tree on a fast disk (preferably SSD).
tfarina502f3882016-03-23 12:48:10184
Daniel Cheng8f817e342016-04-01 17:28:48185Still, expect build times of 30 minutes to 2 hours when everything has to
tfarina502f3882016-03-23 12:48:10186be recompiled.
dpranke0ae7cad2016-11-30 07:47:58187
188## Build Chromium
189
190Build Chromium (the "chrome" target) with Ninja using the command:
191
dpranke1a70d0c2016-12-01 02:42:29192```shell
193$ ninja -C out\Default chrome
194```
dpranke0ae7cad2016-11-30 07:47:58195
196You can get a list of all of the other build targets from GN by running
197`gn ls out/Default` from the command line. To compile one, pass to Ninja
198the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
199use ninja -C out/Default chrome/test:unit_tests`).
200
201## Run Chromium
202
203Once it is built, you can simply run the browser:
204
dpranke1a70d0c2016-12-01 02:42:29205```shell
206$ out\Default\chrome.exe
207```
208
209(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58210
211## Running test targets
212
213You can run the tests in the same way. You can also limit which tests are
214run using the `--gtest_filter` arg, e.g.:
215
dpranke1a70d0c2016-12-01 02:42:29216```shell
217$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
218```
dpranke0ae7cad2016-11-30 07:47:58219
220You can find out more about GoogleTest at its
221[GitHub page](https://github.com/google/googletest).
222
223## Update your checkout
224
225To update an existing checkout, you can run
226
dpranke1a70d0c2016-12-01 02:42:29227```shell
228$ git rebase-update
229$ gclient sync
230```
dpranke0ae7cad2016-11-30 07:47:58231
232The first command updates the primary Chromium source repository and rebases
233any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
234If you don't want to use this script, you can also just use `git pull` or
235other common Git commands to update the repo.
236
237The second command syncs the subrepositories to the appropriate versions and
238re-runs the hooks as needed.