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