OLD | NEW |
1 # Windows Build Instructions | 1 # Checking out and building Chromium on Windows |
2 | 2 |
3 ## Common checkout instructions | 3 **See also [the old version of this page](old_linux_build_instructions.md).** |
4 | 4 |
5 This page covers Windows-specific setup and configuration. The | 5 Google employee? See [go/building-chrome](https://goto.google.com/building-chrom
e) instead. |
6 [general checkout | 6 |
7 instructions](http://dev.chromium.org/developers/how-tos/get-the-code) cover | 7 [TOC] |
8 installing depot tools and checking out the code via git. | 8 |
| 9 ## System requirements |
| 10 |
| 11 * A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly |
| 12 recommended. |
| 13 * At least 100GB of free disk space. |
| 14 * Visual Studio 2015 Update 3, see below (no other version is supported). |
| 15 * Windows 7 or newer. |
9 | 16 |
10 ## Setting up Windows | 17 ## Setting up Windows |
11 | 18 |
| 19 ### System locale |
| 20 |
12 You must set your Windows system locale to English, or else you may get | 21 You must set your Windows system locale to English, or else you may get |
13 build errors about "The file contains a character that cannot be | 22 build errors about "The file contains a character that cannot be |
14 represented in the current code page." | 23 represented in the current code page." |
15 | 24 |
16 ### Setting up the environment for Visual Studio | 25 ### Visual Studio |
17 | |
18 You must build with Visual Studio 2015 Update 3; no other version is | |
19 supported. | |
20 | |
21 You must have Windows 7 x64 or later. x86 OSs are unsupported. | |
22 | |
23 ## Getting the compiler toolchain | |
24 | |
25 Follow the appropriate path below: | |
26 | |
27 ### Open source contributors | |
28 | 26 |
29 As of March 11, 2016 Chromium requires Visual Studio 2015 to build. | 27 As of March 11, 2016 Chromium requires Visual Studio 2015 to build. |
30 | 28 |
31 Install Visual Studio 2015 Update 3 or later - Community Edition | 29 Install Visual Studio 2015 Update 3 or later - Community Edition |
32 should work if its license is appropriate for you. Use the Custom Install option | 30 should work if its license is appropriate for you. Use the Custom Install option |
33 and select: | 31 and select: |
34 | 32 |
35 - Visual C++, which will select three sub-categories including MFC | 33 - Visual C++, which will select three sub-categories including MFC |
36 - Universal Windows Apps Development Tools > Tools | 34 - Universal Windows Apps Development Tools > Tools |
37 - Universal Windows Apps Development Tools > Windows 10 SDK (10.0.10586) | 35 - Universal Windows Apps Development Tools > Windows 10 SDK (10.0.10586) |
38 | 36 |
39 You must have the 10586 SDK installed or else you will hit compile errors such | 37 You must have the 10586 SDK installed or else you will hit compile errors such |
40 as redefined macros. | 38 as redefined macros. |
41 | 39 |
42 Install Windows Driver Kit (WDK) 10, or use some other method to get the | 40 Install Windows Driver Kit (WDK) 10, or use some other method to get the |
43 Debugging Tools for Windows. | 41 Debugging Tools for Windows. |
44 | 42 |
45 Run `set DEPOT_TOOLS_WIN_TOOLCHAIN=0`, or set that variable in your | 43 ## Install `depot_tools` |
46 global environment. | |
47 | 44 |
48 Compilation is done through ninja, **not** Visual Studio. | 45 Download the (depot_tools bundle)[https://storage.googleapis.com/chrome-infra/de
pot_tools.zip] |
| 46 and extract it somewhere. |
49 | 47 |
50 ### Google employees | 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 *** |
51 | 54 |
52 Run: `download_from_google_storage --config` and follow the | 55 Add depot_tools to the start of your PATH (must be ahead of any installs of |
53 authentication instructions. **Note that you must authenticate with your | 56 Python). Assuming you unzipped the bundle to C:\src\depot_tools: |
54 @google.com credentials**, not @chromium.org. Enter "0" if asked for a | |
55 project-id. | |
56 | 57 |
57 Run: `gclient sync` again to download and install the toolchain automatically. | 58 With Administrator access: |
58 | 59 |
59 The toolchain will be in `depot_tools\win_toolchain\vs_files\<hash>`, and windbg | 60 Control Panel → System and Security → System → Advanced system settings |
60 can be found in `depot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers`. | |
61 | 61 |
62 If you want the IDE for debugging and editing, you will need to install | 62 Modify the PATH system variable to include C:\src\depot_tools. |
63 it separately, but this is optional and not needed to build Chromium. | |
64 | 63 |
65 ## Using the Visual Studio IDE | 64 Without Administrator access: |
| 65 |
| 66 Control Panel → User Accounts → User Accounts → Change my environment variables |
| 67 |
| 68 Add a PATH user variable: C:\src\depot_tools;%PATH%. |
| 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.h
tml#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 |
| 91 Create a chromium directory for the checkout and change to it (you can call |
| 92 this whatever you like and put it wherever you like, as |
| 93 long as the full path has no spaces): |
| 94 |
| 95 $ mkdir chromium |
| 96 $ cd chromium |
| 97 |
| 98 Run the `fetch` tool from depot_tools to check out the code and its |
| 99 dependencies. |
| 100 |
| 101 $ fetch chromium |
| 102 |
| 103 If you don't want the full repo history, you can save a lot of time by |
| 104 adding the `--no-history` flag to fetch. Expect the command to take |
| 105 30 minutes on even a fast connection, and many hours on slower ones. |
| 106 |
| 107 When fetch completes, it will have created a directory called `src`. |
| 108 The remaining instructions assume you are now in that directory: |
| 109 |
| 110 $ cd src |
| 111 |
| 112 ### (optional) Install API keys |
| 113 |
| 114 You can also [instaldl API keys](https://www.chromium.org/developers/how-tos/api
-keys) |
| 115 if you want to talk to some of the Google services, but this is not necessary |
| 116 for most development and testing purposes. |
| 117 |
| 118 ## Seting up the Build |
| 119 |
| 120 Chromium uses [Ninja](https://ninja-build.org) as its main build tool, and |
| 121 a tool called [GN](../tools/gn/docs/quick_start.md) to generate |
| 122 the .ninja files to do the build. To create a build directory: |
| 123 |
| 124 $ gn gen out/Default |
| 125 |
| 126 * You only have to do run this command once, it will self-update the build |
| 127 files as needed after that. |
| 128 * You can replace `out/Default` with another directory name, but we recommend |
| 129 it should still be a subdirectory of `out`. |
| 130 * To specify build parameters for GN builds, including release settings, |
| 131 see [GN build configuration](https://www.chromium.org/developers/gn-build-conf
iguration). |
| 132 The default will be a debug component build matching the current host |
| 133 operating system and CPU. |
| 134 * For more info on GN, run `gn help` on the command line or read the |
| 135 [quick start guide](../tools/gn/docs/quick_start.md). |
| 136 |
| 137 ### Using the Visual Studio IDE |
66 | 138 |
67 If you want to use the Visual Studio IDE, use the `--ide` command line | 139 If you want to use the Visual Studio IDE, use the `--ide` command line |
68 argument to `gn gen` when you generate your output directory (as described on | 140 argument to `gn gen` when you generate your output directory (as described on |
69 the [get the code](http://dev.chromium.org/developers/how-tos/get-the-code) | 141 the [get the code](http://dev.chromium.org/developers/how-tos/get-the-code) |
70 page): | 142 page): |
71 | 143 |
72 ```gn gen --ide=vs out\Default | 144 ```gn gen --ide=vs out\Default |
73 devenv out\Default\all.sln | 145 devenv out\Default\all.sln |
74 ``` | 146 ``` |
75 | 147 |
76 GN will produce a file `all.sln` in your build directory. It will internally | 148 GN will produce a file `all.sln` in your build directory. It will internally |
77 use Ninja to compile while still allowing most IDE functions to work (there is | 149 use Ninja to compile while still allowing most IDE functions to work (there is |
78 no native Visual Studio compilation mode). If you manually run "gen" again you | 150 no native Visual Studio compilation mode). If you manually run "gen" again you |
79 will need to resupply this argument, but normally GN will keep the build and | 151 will need to resupply this argument, but normally GN will keep the build and |
80 IDE files up to date automatically when you build. | 152 IDE files up to date automatically when you build. |
81 | 153 |
82 The generated solution will contain several thousand projects and will be very | 154 The generated solution will contain several thousand projects and will be very |
83 slow to load. Use the `--filters` argument to restrict generating project files | 155 slow to load. Use the `--filters` argument to restrict generating project files |
84 for only the code you're interested in, although this will also limit what | 156 for only the code you're interested in, although this will also limit what |
85 files appear in the project explorer. A minimal solution that will let you | 157 files appear in the project explorer. A minimal solution that will let you |
86 compile and run Chrome in the IDE but will not show any source files is: | 158 compile and run Chrome in the IDE but will not show any source files is: |
87 | 159 |
88 ```gn gen --ide=vs --filters=//chrome out\Default``` | 160 ```gn gen --ide=vs --filters=//chrome out\Default``` |
89 | 161 |
90 There are other options for controlling how the solution is generated, run `gn | 162 There are other options for controlling how the solution is generated, run `gn |
91 help gen` for the current documentation. | 163 help gen` for the current documentation. |
92 | 164 |
93 ## Performance tips | 165 ### Faster builds |
94 | 166 |
95 1. Have a lot of fast CPU cores and enough RAM to keep them all busy. | 167 * Reduce file system overhead by excluding build directories from |
96 (Minimum recommended is 4-8 fast cores and 16-32 GB of RAM) | 168 antivirus and indexing software. |
97 2. Reduce file system overhead by excluding build directories from | 169 * Store the build tree on a fast disk (preferably SSD). |
98 antivirus and indexing software. | |
99 3. Store the build tree on a fast disk (preferably SSD). | |
100 4. If you are primarily going to be doing debug development builds, you | |
101 should use the component build. Set the [build | |
102 arg](https://www.chromium.org/developers/gn-build-configuration) | |
103 `is_component_build = true`. | |
104 This will generate many DLLs and enable incremental linking, which makes | |
105 linking **much** faster in Debug. | |
106 | 170 |
107 Still, expect build times of 30 minutes to 2 hours when everything has to | 171 Still, expect build times of 30 minutes to 2 hours when everything has to |
108 be recompiled. | 172 be recompiled. |
| 173 |
| 174 ## Build Chromium |
| 175 |
| 176 Build Chromium (the "chrome" target) with Ninja using the command: |
| 177 |
| 178 $ ninja -C out\Default chrome |
| 179 |
| 180 You can get a list of all of the other build targets from GN by running |
| 181 `gn ls out/Default` from the command line. To compile one, pass to Ninja |
| 182 the GN label with no preceding "//" (so for `//chrome/test:unit_tests` |
| 183 use ninja -C out/Default chrome/test:unit_tests`). |
| 184 |
| 185 ## Run Chromium |
| 186 |
| 187 Once it is built, you can simply run the browser: |
| 188 |
| 189 $ out\Default\chrome.exe |
| 190 |
| 191 ## Running test targets |
| 192 |
| 193 You can run the tests in the same way. You can also limit which tests are |
| 194 run using the `--gtest_filter` arg, e.g.: |
| 195 |
| 196 $ ninja -C out\Default unit_tests --gtest_filter="PushClientTest.*" |
| 197 |
| 198 You can find out more about GoogleTest at its |
| 199 [GitHub page](https://github.com/google/googletest). |
| 200 |
| 201 ## Update your checkout |
| 202 |
| 203 To update an existing checkout, you can run |
| 204 |
| 205 $ git rebase-update |
| 206 $ gclient sync |
| 207 |
| 208 The first command updates the primary Chromium source repository and rebases |
| 209 any of your local branches on top of tip-of-tree (aka the Git branch `origin/mas
ter`). |
| 210 If you don't want to use this script, you can also just use `git pull` or |
| 211 other common Git commands to update the repo. |
| 212 |
| 213 The second command syncs the subrepositories to the appropriate versions and |
| 214 re-runs the hooks as needed. |
OLD | NEW |