dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 1 | # Checking out and Building Chromium for Windows |
| 2 | |
| 3 | There are instructions for other platforms linked from the |
| 4 | [get the code](get_the_code.md) page. |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 5 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 6 | ## Instructions for Google Employees |
| 7 | |
| 8 | Are you a Google employee? See |
scottmg | 292538ae | 2017-01-12 00:10:55 | [diff] [blame^] | 9 | [go/building-chrome-win](https://goto.google.com/building-chrome-win) instead. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 10 | |
| 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. |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 20 | |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 21 | ## Setting up Windows |
| 22 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 23 | ### Visual Studio |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 24 | |
scottmg | a335ca3 | 2016-12-08 18:25:46 | [diff] [blame] | 25 | As of December 8, 2016 Chromium requires Visual Studio 2015, with the 14393 |
| 26 | Windows SDK to build. |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 27 | |
scottmg | 740b32d8 | 2016-11-03 15:54:53 | [diff] [blame] | 28 | Install Visual Studio 2015 Update 3 or later - Community Edition |
brucedawson | c218634 | 2016-04-15 18:27:34 | [diff] [blame] | 29 | should work if its license is appropriate for you. Use the Custom Install option |
| 30 | and select: |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 31 | |
brucedawson | c218634 | 2016-04-15 18:27:34 | [diff] [blame] | 32 | - Visual C++, which will select three sub-categories including MFC |
scottmg | a335ca3 | 2016-12-08 18:25:46 | [diff] [blame] | 33 | - Universal Windows Apps Development Tools > Tools (1.4.1) and Windows 10 SDK |
| 34 | (10.0.14393) |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 35 | |
scottmg | a335ca3 | 2016-12-08 18:25:46 | [diff] [blame] | 36 | You must have the 14393 SDK installed or else you will hit compile errors such |
| 37 | as undefined or redefined macros. |
Daniel Cheng | 8f817e34 | 2016-04-01 17:28:48 | [diff] [blame] | 38 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 39 | Install the Windows SDK 10, and choose Debugging Tools For Windows when you |
| 40 | install this in order to get windbg. |
pwnall | 43b43ba | 2016-08-22 19:29:29 | [diff] [blame] | 41 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 42 | ## Install `depot_tools` |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 43 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 44 | Download the [depot_tools bundle](https://storage.googleapis.com/chrome-infra/depot_tools.zip) |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 45 | and extract it somewhere. |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 46 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 47 | *** note |
| 48 | **Warning:** **DO NOT** use drag-n-drop or copy-n-paste extract from Explorer, |
| 49 | this will not extract the hidden “.git” folder which is necessary for |
| 50 | depot_tools to autoupdate itself. You can use “Extract all…” from the |
| 51 | context menu though. |
| 52 | *** |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 53 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 54 | Add depot_tools to the start of your PATH (must be ahead of any installs of |
| 55 | Python). Assuming you unzipped the bundle to C:\src\depot_tools: |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 56 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 57 | With Administrator access: |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 58 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 59 | Control Panel → System and Security → System → Advanced system settings |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 60 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 61 | Modify the PATH system variable to include C:\src\depot_tools. |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 62 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 63 | Without Administrator access: |
| 64 | |
| 65 | Control Panel → User Accounts → User Accounts → Change my environment variables |
| 66 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 67 | Add a PATH user variable (or modify the existing one to include): |
| 68 | `C:\src\depot_tools`. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 69 | |
| 70 | Also, add a DEPOT_TOOLS_WIN_TOOLCHAIN system variable in the same way, and set |
| 71 | it to 0. This tells depot_tools to use your locally installed version of Visual |
| 72 | Studio (by default, depot_tools will try to use a google-internal version). |
| 73 | |
| 74 | From a cmd.exe shell, run the command gclient (without arguments). On first |
| 75 | run, gclient will install all the Windows-specific bits needed to work with |
| 76 | the 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 | |
| 84 | After running gclient open a command prompt and type `where python` and |
| 85 | confirm that the depot_tools `python.bat` comes ahead of any copies of |
| 86 | python.exe. Failing to ensure this can lead to overbuilding when |
| 87 | using gn - see [crbug.com/611087](https://crbug.com/611087). |
| 88 | |
| 89 | ## Get the code |
| 90 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 91 | Create a `chromium` directory for the checkout and change to it (you can call |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 92 | this whatever you like and put it wherever you like, as |
| 93 | long as the full path has no spaces): |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 94 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 95 | ```shell |
| 96 | $ mkdir chromium && cd chromium |
| 97 | ``` |
| 98 | |
| 99 | Run the `fetch` tool from `depot_tools` to check out the code and its |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 100 | dependencies. |
| 101 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 102 | ```shell |
xiaoyin.l | 802e4b3e | 2016-12-04 22:17:30 | [diff] [blame] | 103 | $ fetch chromium |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 104 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 105 | |
| 106 | If you don't want the full repo history, you can save a lot of time by |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 107 | adding the `--no-history` flag to `fetch`. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 108 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 109 | Expect the command to take 30 minutes on even a fast connection, and many |
| 110 | hours on slower ones. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 111 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 112 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 113 | directory called `src` in the working directory. The remaining instructions |
| 114 | assume you have switched to the `src` directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 115 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 116 | ```shell |
| 117 | $ cd src |
| 118 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 119 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 120 | *Optional*: You can also [install API |
| 121 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 122 | build to talk to some Google services, but this is not necessary for most |
| 123 | development and testing purposes. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 124 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 125 | ## Setting up the build |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 126 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 127 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along |
| 128 | with a tool called [GN](../tools/gn/docs/quick_start.md) to generate `.ninja` |
| 129 | files. You can create any number of *build directories* with different |
| 130 | configurations. To create a build directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 131 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 132 | ```shell |
| 133 | $ gn gen out/Default |
| 134 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 135 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 136 | * 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). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 142 | 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 |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 148 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 149 | If you want to use the Visual Studio IDE, use the `--ide` command line |
| 150 | argument to `gn gen` when you generate your output directory (as described on |
xiaoyin.l | 1003c0b | 2016-12-06 02:51:17 | [diff] [blame] | 151 | the [get the code](https://dev.chromium.org/developers/how-tos/get-the-code) |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 152 | page): |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 153 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 154 | ```shell |
| 155 | $ gn gen --ide=vs out\Default |
| 156 | $ devenv out\Default\all.sln |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 157 | ``` |
| 158 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 159 | GN will produce a file `all.sln` in your build directory. It will internally |
| 160 | use Ninja to compile while still allowing most IDE functions to work (there is |
| 161 | no native Visual Studio compilation mode). If you manually run "gen" again you |
| 162 | will need to resupply this argument, but normally GN will keep the build and |
thakis | 3e861de | 2016-06-14 14:24:01 | [diff] [blame] | 163 | IDE files up to date automatically when you build. |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 164 | |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 165 | The generated solution will contain several thousand projects and will be very |
| 166 | slow to load. Use the `--filters` argument to restrict generating project files |
| 167 | for only the code you're interested in, although this will also limit what |
| 168 | files appear in the project explorer. A minimal solution that will let you |
| 169 | compile and run Chrome in the IDE but will not show any source files is: |
| 170 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 171 | ``` |
| 172 | $ gn gen --ide=vs --filters=//chrome out\Default |
| 173 | ``` |
brettw | c25693b3 | 2016-05-26 01:11:52 | [diff] [blame] | 174 | |
| 175 | There are other options for controlling how the solution is generated, run `gn |
| 176 | help gen` for the current documentation. |
| 177 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 178 | ### Faster builds |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 179 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 180 | * 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). |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 183 | |
Daniel Cheng | 8f817e34 | 2016-04-01 17:28:48 | [diff] [blame] | 184 | Still, expect build times of 30 minutes to 2 hours when everything has to |
tfarina | 502f388 | 2016-03-23 12:48:10 | [diff] [blame] | 185 | be recompiled. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 186 | |
| 187 | ## Build Chromium |
| 188 | |
| 189 | Build Chromium (the "chrome" target) with Ninja using the command: |
| 190 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 191 | ```shell |
| 192 | $ ninja -C out\Default chrome |
| 193 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 194 | |
| 195 | You 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 |
| 197 | the GN label with no preceding "//" (so for `//chrome/test:unit_tests` |
| 198 | use ninja -C out/Default chrome/test:unit_tests`). |
| 199 | |
| 200 | ## Run Chromium |
| 201 | |
| 202 | Once it is built, you can simply run the browser: |
| 203 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 204 | ```shell |
| 205 | $ out\Default\chrome.exe |
| 206 | ``` |
| 207 | |
| 208 | (The ".exe" suffix in the command is actually optional). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 209 | |
| 210 | ## Running test targets |
| 211 | |
| 212 | You can run the tests in the same way. You can also limit which tests are |
| 213 | run using the `--gtest_filter` arg, e.g.: |
| 214 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 215 | ```shell |
| 216 | $ out\Default\unit_tests.exe --gtest_filter="PushClientTest.*" |
| 217 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 218 | |
| 219 | You can find out more about GoogleTest at its |
| 220 | [GitHub page](https://github.com/google/googletest). |
| 221 | |
| 222 | ## Update your checkout |
| 223 | |
| 224 | To update an existing checkout, you can run |
| 225 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 226 | ```shell |
| 227 | $ git rebase-update |
| 228 | $ gclient sync |
| 229 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 230 | |
| 231 | The first command updates the primary Chromium source repository and rebases |
| 232 | any of your local branches on top of tip-of-tree (aka the Git branch `origin/master`). |
| 233 | If you don't want to use this script, you can also just use `git pull` or |
| 234 | other common Git commands to update the repo. |
| 235 | |
| 236 | The second command syncs the subrepositories to the appropriate versions and |
| 237 | re-runs the hooks as needed. |