blob: 70ab13022f094ce4a160270d7b10edaff775d4cd [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.
17* At least 100GB of free disk space.
18* Visual Studio 2015 Update 3, see below (no other version is supported).
19* Windows 7 or newer.
brettwc25693b32016-05-26 01:11:5220
tfarina502f3882016-03-23 12:48:1021## Setting up Windows
22
dpranke0ae7cad2016-11-30 07:47:5823### Visual Studio
tfarina502f3882016-03-23 12:48:1024
scottmga335ca32016-12-08 18:25:4625As of December 8, 2016 Chromium requires Visual Studio 2015, with the 14393
26Windows SDK to build.
tfarina502f3882016-03-23 12:48:1027
scottmg740b32d82016-11-03 15:54:5328Install Visual Studio 2015 Update 3 or later - Community Edition
brucedawsonc2186342016-04-15 18:27:3429should work if its license is appropriate for you. Use the Custom Install option
30and select:
tfarina502f3882016-03-23 12:48:1031
brucedawsonc2186342016-04-15 18:27:3432- Visual C++, which will select three sub-categories including MFC
scottmga335ca32016-12-08 18:25:4633- Universal Windows Apps Development Tools > Tools (1.4.1) and Windows 10 SDK
34 (10.0.14393)
tfarina502f3882016-03-23 12:48:1035
scottmga335ca32016-12-08 18:25:4636You must have the 14393 SDK installed or else you will hit compile errors such
37as undefined or redefined macros.
Daniel Cheng8f817e342016-04-01 17:28:4838
dpranke1a70d0c2016-12-01 02:42:2939Install the Windows SDK 10, and choose Debugging Tools For Windows when you
40install this in order to get windbg.
pwnall43b43ba2016-08-22 19:29:2941
dpranke0ae7cad2016-11-30 07:47:5842## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1043
dpranke1a70d0c2016-12-01 02:42:2944Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5845and extract it somewhere.
tfarina502f3882016-03-23 12:48:1046
dpranke0ae7cad2016-11-30 07:47:5847*** note
48**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
49this will not extract the hidden “.git folder which is necessary for
50depot_tools to autoupdate itself. You can use Extract all…” from the
51context menu though.
52***
tfarina502f3882016-03-23 12:48:1053
dpranke0ae7cad2016-11-30 07:47:5854Add depot_tools to the start of your PATH (must be ahead of any installs of
55Python). Assuming you unzipped the bundle to C:\src\depot_tools:
tfarina502f3882016-03-23 12:48:1056
dpranke0ae7cad2016-11-30 07:47:5857With Administrator access:
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
dpranke0ae7cad2016-11-30 07:47:5861Modify the PATH system variable to include C:\src\depot_tools.
tfarina502f3882016-03-23 12:48:1062
dpranke0ae7cad2016-11-30 07:47:5863Without Administrator access:
64
65Control Panel User Accounts User Accounts Change my environment variables
66
dpranke1a70d0c2016-12-01 02:42:2967Add a PATH user variable (or modify the existing one to include):
68`C:\src\depot_tools`.
dpranke0ae7cad2016-11-30 07:47:5869
70Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set
71it to 0. This tells depot_tools to use your locally installed version of Visual
72Studio (by default, depot_tools will try to use a google-internal version).
73
74From a cmd.exe shell, run the command gclient (without arguments). On first
75run, gclient will install all the Windows-specific bits needed to work with
76the code, including msysgit and python.
77
78* If you run gclient from a non-cmd shell (e.g., cygwin, PowerShell),
79 it may appear to run properly, but msysgit, python, and other tools
80 may not get installed correctly.
81* If you see strange errors with the file system on the first run of gclient,
82 you may want to [disable Windows Indexing](http://tortoisesvn.tigris.org/faq.html#cantmove2).
83
84After running gclient open a command prompt and type `where python` and
85confirm that the depot_tools `python.bat` comes ahead of any copies of
86python.exe. Failing to ensure this can lead to overbuilding when
87using gn - see [crbug.com/611087](https://crbug.com/611087).
88
89## Get the code
90
sdy93387fa2016-12-01 01:03:4491Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:5892this whatever you like and put it wherever you like, as
93long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:5894
sdy93387fa2016-12-01 01:03:4495```shell
96$ mkdir chromium && cd chromium
97```
98
99Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:58100dependencies.
101
sdy93387fa2016-12-01 01:03:44102```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30103$ fetch chromium
sdy93387fa2016-12-01 01:03:44104```
dpranke0ae7cad2016-11-30 07:47:58105
106If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44107adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58108
sdy93387fa2016-12-01 01:03:44109Expect the command to take 30 minutes on even a fast connection, and many
110hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58111
sdy93387fa2016-12-01 01:03:44112When `fetch` completes, it will have created a hidden `.gclient` file and a
113directory called `src` in the working directory. The remaining instructions
114assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58115
sdy93387fa2016-12-01 01:03:44116```shell
117$ cd src
118```
dpranke0ae7cad2016-11-30 07:47:58119
sdy93387fa2016-12-01 01:03:44120*Optional*: You can also [install API
121keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
122build to talk to some Google services, but this is not necessary for most
123development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58124
dpranke1a70d0c2016-12-01 02:42:29125## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58126
sdy93387fa2016-12-01 01:03:44127Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
128with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
129files. You can create any number of *build directories* with different
130configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58131
sdy93387fa2016-12-01 01:03:44132```shell
133$ gn gen out/Default
134```
dpranke0ae7cad2016-11-30 07:47:58135
sdy93387fa2016-12-01 01:03:44136* You only have to run this once for each new build directory, Ninja will
137 update the build files as needed.
138* You can replace `Default` with another name, but
139 it should be a subdirectory of `out`.
140* For other build arguments, including release settings, see [GN build
141 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58142 The default will be a debug component build matching the current host
143 operating system and CPU.
144* For more info on GN, run `gn help` on the command line or read the
145 [quick start guide](../tools/gn/docs/quick_start.md).
146
147### Using the Visual Studio IDE
tfarina502f3882016-03-23 12:48:10148
brettwc25693b32016-05-26 01:11:52149If you want to use the Visual Studio IDE, use the `--ide` command line
150argument to `gn gen` when you generate your output directory (as described on
xiaoyin.l1003c0b2016-12-06 02:51:17151the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code)
brettwc25693b32016-05-26 01:11:52152page):
tfarina502f3882016-03-23 12:48:10153
dpranke1a70d0c2016-12-01 02:42:29154```shell
155$ gn gen --ide=vs out\Default
156$ devenv out\Default\all.sln
tfarina502f3882016-03-23 12:48:10157```
158
brettwc25693b32016-05-26 01:11:52159GN will produce a file `all.sln` in your build directory. It will internally
160use Ninja to compile while still allowing most IDE functions to work (there is
161no native Visual Studio compilation mode). If you manually run "gen" again you
162will need to resupply this argument, but normally GN will keep the build and
thakis3e861de2016-06-14 14:24:01163IDE files up to date automatically when you build.
tfarina502f3882016-03-23 12:48:10164
brettwc25693b32016-05-26 01:11:52165The generated solution will contain several thousand projects and will be very
166slow to load. Use the `--filters` argument to restrict generating project files
167for only the code you're interested in, although this will also limit what
168files appear in the project explorer. A minimal solution that will let you
169compile and run Chrome in the IDE but will not show any source files is:
170
dpranke1a70d0c2016-12-01 02:42:29171```
172$ gn gen --ide=vs --filters=//chrome out\Default
173```
brettwc25693b32016-05-26 01:11:52174
175There are other options for controlling how the solution is generated, run `gn
176help gen` for the current documentation.
177
dpranke0ae7cad2016-11-30 07:47:58178### Faster builds
tfarina502f3882016-03-23 12:48:10179
dpranke0ae7cad2016-11-30 07:47:58180* Reduce file system overhead by excluding build directories from
181 antivirus and indexing software.
182* Store the build tree on a fast disk (preferably SSD).
tfarina502f3882016-03-23 12:48:10183
Daniel Cheng8f817e342016-04-01 17:28:48184Still, expect build times of 30 minutes to 2 hours when everything has to
tfarina502f3882016-03-23 12:48:10185be recompiled.
dpranke0ae7cad2016-11-30 07:47:58186
187## Build Chromium
188
189Build Chromium (the "chrome" target) with Ninja using the command:
190
dpranke1a70d0c2016-12-01 02:42:29191```shell
192$ ninja -C out\Default chrome
193```
dpranke0ae7cad2016-11-30 07:47:58194
195You can get a list of all of the other build targets from GN by running
196`gn ls out/Default` from the command line. To compile one, pass to Ninja
197the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
198use ninja -C out/Default chrome/test:unit_tests`).
199
200## Run Chromium
201
202Once it is built, you can simply run the browser:
203
dpranke1a70d0c2016-12-01 02:42:29204```shell
205$ out\Default\chrome.exe
206```
207
208(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58209
210## Running test targets
211
212You can run the tests in the same way. You can also limit which tests are
213run using the `--gtest_filter` arg, e.g.:
214
dpranke1a70d0c2016-12-01 02:42:29215```shell
216$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
217```
dpranke0ae7cad2016-11-30 07:47:58218
219You can find out more about GoogleTest at its
220[GitHub page](https://github.com/google/googletest).
221
222## Update your checkout
223
224To update an existing checkout, you can run
225
dpranke1a70d0c2016-12-01 02:42:29226```shell
227$ git rebase-update
228$ gclient sync
229```
dpranke0ae7cad2016-11-30 07:47:58230
231The first command updates the primary Chromium source repository and rebases
232any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
233If you don't want to use this script, you can also just use `git pull` or
234other common Git commands to update the repo.
235
236The second command syncs the subrepositories to the appropriate versions and
237re-runs the hooks as needed.