blob: 3d41e82925c969adb49353ed0fce50c7212b0ef2 [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
9[go/building-chrome](https://goto.google.com/building-chrome) 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
brucedawsonc2186342016-04-15 18:27:3425As of March 11, 2016 Chromium requires Visual Studio 2015 to build.
tfarina502f3882016-03-23 12:48:1026
scottmg740b32d82016-11-03 15:54:5327Install Visual Studio 2015 Update 3 or later - Community Edition
brucedawsonc2186342016-04-15 18:27:3428should work if its license is appropriate for you. Use the Custom Install option
29and select:
tfarina502f3882016-03-23 12:48:1030
brucedawsonc2186342016-04-15 18:27:3431- Visual C++, which will select three sub-categories including MFC
32- Universal Windows Apps Development Tools > Tools
33- Universal Windows Apps Development Tools > Windows 10 SDK (10.0.10586)
tfarina502f3882016-03-23 12:48:1034
brucedawsonc2186342016-04-15 18:27:3435You must have the 10586 SDK installed or else you will hit compile errors such
36as redefined macros.
Daniel Cheng8f817e342016-04-01 17:28:4837
dpranke1a70d0c2016-12-01 02:42:2938Install the Windows SDK 10, and choose Debugging Tools For Windows when you
39install this in order to get windbg.
pwnall43b43ba2016-08-22 19:29:2940
dpranke0ae7cad2016-11-30 07:47:5841## Install `depot_tools`
tfarina502f3882016-03-23 12:48:1042
dpranke1a70d0c2016-12-01 02:42:2943Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip)
dpranke0ae7cad2016-11-30 07:47:5844and extract it somewhere.
tfarina502f3882016-03-23 12:48:1045
dpranke0ae7cad2016-11-30 07:47:5846*** note
47**Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer,
48this will not extract the hidden “.git folder which is necessary for
49depot_tools to autoupdate itself. You can use Extract all…” from the
50context menu though.
51***
tfarina502f3882016-03-23 12:48:1052
dpranke0ae7cad2016-11-30 07:47:5853Add depot_tools to the start of your PATH (must be ahead of any installs of
54Python). Assuming you unzipped the bundle to C:\src\depot_tools:
tfarina502f3882016-03-23 12:48:1055
dpranke0ae7cad2016-11-30 07:47:5856With Administrator access:
tfarina502f3882016-03-23 12:48:1057
dpranke0ae7cad2016-11-30 07:47:5858Control Panel System and Security System Advanced system settings
tfarina502f3882016-03-23 12:48:1059
dpranke0ae7cad2016-11-30 07:47:5860Modify the PATH system variable to include C:\src\depot_tools.
tfarina502f3882016-03-23 12:48:1061
dpranke0ae7cad2016-11-30 07:47:5862Without Administrator access:
63
64Control Panel User Accounts User Accounts Change my environment variables
65
dpranke1a70d0c2016-12-01 02:42:2966Add a PATH user variable (or modify the existing one to include):
67`C:\src\depot_tools`.
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
83After 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
86using gn - see [crbug.com/611087](https://crbug.com/611087).
87
88## Get the code
89
sdy93387fa2016-12-01 01:03:4490Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:5891this whatever you like and put it wherever you like, as
92long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:5893
sdy93387fa2016-12-01 01:03:4494```shell
95$ mkdir chromium && cd chromium
96```
97
98Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:5899dependencies.
100
sdy93387fa2016-12-01 01:03:44101```shell
xiaoyin.l802e4b3e2016-12-04 22:17:30102$ fetch chromium
sdy93387fa2016-12-01 01:03:44103```
dpranke0ae7cad2016-11-30 07:47:58104
105If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:44106adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:58107
sdy93387fa2016-12-01 01:03:44108Expect the command to take 30 minutes on even a fast connection, and many
109hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:58110
sdy93387fa2016-12-01 01:03:44111When `fetch` completes, it will have created a hidden `.gclient` file and a
112directory called `src` in the working directory. The remaining instructions
113assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:58114
sdy93387fa2016-12-01 01:03:44115```shell
116$ cd src
117```
dpranke0ae7cad2016-11-30 07:47:58118
sdy93387fa2016-12-01 01:03:44119*Optional*: You can also [install API
120keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
121build to talk to some Google services, but this is not necessary for most
122development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:58123
dpranke1a70d0c2016-12-01 02:42:29124## Setting up the build
dpranke0ae7cad2016-11-30 07:47:58125
sdy93387fa2016-12-01 01:03:44126Chromium uses [Ninja](https://ninja-build.org) as its main build tool along
127with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja`
128files. You can create any number of *build directories* with different
129configurations. To create a build directory:
dpranke0ae7cad2016-11-30 07:47:58130
sdy93387fa2016-12-01 01:03:44131```shell
132$ gn gen out/Default
133```
dpranke0ae7cad2016-11-30 07:47:58134
sdy93387fa2016-12-01 01:03:44135* You only have to run this once for each new build directory, Ninja will
136 update the build files as needed.
137* You can replace `Default` with another name, but
138 it should be a subdirectory of `out`.
139* For other build arguments, including release settings, see [GN build
140 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58141 The default will be a debug component build matching the current host
142 operating system and CPU.
143* For more info on GN, run `gn help` on the command line or read the
144 [quick start guide](../tools/gn/docs/quick_start.md).
145
146### Using the Visual Studio IDE
tfarina502f3882016-03-23 12:48:10147
brettwc25693b32016-05-26 01:11:52148If you want to use the Visual Studio IDE, use the `--ide` command line
149argument to `gn gen` when you generate your output directory (as described on
150the [get the code](http://dev.chromium.org/developers/how-tos/get-the-code)
151page):
tfarina502f3882016-03-23 12:48:10152
dpranke1a70d0c2016-12-01 02:42:29153```shell
154$ gn gen --ide=vs out\Default
155$ devenv out\Default\all.sln
tfarina502f3882016-03-23 12:48:10156```
157
brettwc25693b32016-05-26 01:11:52158GN will produce a file `all.sln` in your build directory. It will internally
159use Ninja to compile while still allowing most IDE functions to work (there is
160no native Visual Studio compilation mode). If you manually run "gen" again you
161will need to resupply this argument, but normally GN will keep the build and
thakis3e861de2016-06-14 14:24:01162IDE files up to date automatically when you build.
tfarina502f3882016-03-23 12:48:10163
brettwc25693b32016-05-26 01:11:52164The generated solution will contain several thousand projects and will be very
165slow to load. Use the `--filters` argument to restrict generating project files
166for only the code you're interested in, although this will also limit what
167files appear in the project explorer. A minimal solution that will let you
168compile and run Chrome in the IDE but will not show any source files is:
169
dpranke1a70d0c2016-12-01 02:42:29170```
171$ gn gen --ide=vs --filters=//chrome out\Default
172```
brettwc25693b32016-05-26 01:11:52173
174There are other options for controlling how the solution is generated, run `gn
175help gen` for the current documentation.
176
dpranke0ae7cad2016-11-30 07:47:58177### Faster builds
tfarina502f3882016-03-23 12:48:10178
dpranke0ae7cad2016-11-30 07:47:58179* Reduce file system overhead by excluding build directories from
180 antivirus and indexing software.
181* Store the build tree on a fast disk (preferably SSD).
tfarina502f3882016-03-23 12:48:10182
Daniel Cheng8f817e342016-04-01 17:28:48183Still, expect build times of 30 minutes to 2 hours when everything has to
tfarina502f3882016-03-23 12:48:10184be recompiled.
dpranke0ae7cad2016-11-30 07:47:58185
186## Build Chromium
187
188Build Chromium (the "chrome" target) with Ninja using the command:
189
dpranke1a70d0c2016-12-01 02:42:29190```shell
191$ ninja -C out\Default chrome
192```
dpranke0ae7cad2016-11-30 07:47:58193
194You can get a list of all of the other build targets from GN by running
195`gn ls out/Default` from the command line. To compile one, pass to Ninja
196the GN label with no preceding "//" (so for `//chrome/test:unit_tests`
197use ninja -C out/Default chrome/test:unit_tests`).
198
199## Run Chromium
200
201Once it is built, you can simply run the browser:
202
dpranke1a70d0c2016-12-01 02:42:29203```shell
204$ out\Default\chrome.exe
205```
206
207(The ".exe" suffix in the command is actually optional).
dpranke0ae7cad2016-11-30 07:47:58208
209## Running test targets
210
211You can run the tests in the same way. You can also limit which tests are
212run using the `--gtest_filter` arg, e.g.:
213
dpranke1a70d0c2016-12-01 02:42:29214```shell
215$ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*"
216```
dpranke0ae7cad2016-11-30 07:47:58217
218You can find out more about GoogleTest at its
219[GitHub page](https://github.com/google/googletest).
220
221## Update your checkout
222
223To update an existing checkout, you can run
224
dpranke1a70d0c2016-12-01 02:42:29225```shell
226$ git rebase-update
227$ gclient sync
228```
dpranke0ae7cad2016-11-30 07:47:58229
230The first command updates the primary Chromium source repository and rebases
231any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`).
232If you don't want to use this script, you can also just use `git pull` or
233other common Git commands to update the repo.
234
235The second command syncs the subrepositories to the appropriate versions and
236re-runs the hooks as needed.