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