OLD | NEW |
---|---|
1 # Mac Build Instructions | 1 # Mac Build Instructions |
2 | 2 |
3 Google employee? See [go/building-chrome](https://goto.google.com/building-chrom e) instead. | |
4 | |
3 [TOC] | 5 [TOC] |
4 | 6 |
5 Google employee? See [go/building-chrome-mac](https://goto.google.com/building-c hrome-mac) for extra tips. | 7 ## System requirements |
6 | 8 |
7 ## Prerequisites | 9 * A 64-bit Mac running 10.9+. |
8 | |
9 * A Mac running 10.9+. | |
10 * [Xcode](https://developer.apple.com/xcode) 7.3+. | 10 * [Xcode](https://developer.apple.com/xcode) 7.3+. |
11 * [depot\_tools](http://dev.chromium.org/developers/how-tos/depottools). | |
12 * The OSX 10.10 SDK. Run | 11 * The OSX 10.10 SDK. Run |
13 ``` | 12 ``` |
14 ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs | 13 ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs |
15 ``` | 14 ``` |
16 to check whether you have it. Building with the 10.11 SDK works too, but | 15 to check whether you have it. Building with the 10.11 SDK works too, but |
17 the releases currently use the 10.10 SDK. | 16 the releases currently use the 10.10 SDK. |
17 * Git v | |
18 * Python 2.7.x. | |
18 | 19 |
19 ## Getting the code | 20 ## Install `depot_tools` |
20 | 21 |
21 [Check out the source code](https://www.chromium.org/developers/how-tos/get-the- code) | 22 Clone the depot_tools repository: |
22 using Git. | |
23 | 23 |
24 Before checking out, go to the | 24 $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
25 [waterfall](http://build.chromium.org/buildbot/waterfall/) and check that the | |
26 source tree is open (to avoid pulling a broken tree). | |
27 | 25 |
28 The path to the build directory should not contain spaces (e.g. not | 26 Add depot_tools to the end of your PATH (you will probably want to put this |
29 `~/Mac OS X/chromium`), as this will cause the build to fail. This includes your | 27 in your ~/.bashrc or ~/.zshrc). Assuming you cloned depot_tools |
30 drive name, the default "Macintosh HD2" for a second drive has a space. | 28 to /path/to/depot_tools: |
29 | |
30 $ export PATH=$PATH:/path/to/depot_tools | |
31 | |
32 ## Get the code | |
33 | |
34 Create a chromium directory for the checkout and change to it (you can call | |
35 this whatever you like and put it wherever you like, as | |
36 long as the full path has no spaces): | |
37 | |
38 $ mkdir chromium | |
39 $ cd chromium | |
40 | |
41 Run the `fetch` tool from depot_tools to check out the code and its | |
42 dependencies. | |
43 | |
44 $ fetch chromium | |
45 | |
46 If you don't want the full repo history, you can save a lot of time by | |
47 adding the `--no-history` flag to fetch. Expect the command to take | |
48 30 minutes on even a fast connection, and many hours on slower ones. | |
49 | |
50 When fetch completes, it will have created a directory called `src`. | |
51 The remaining instructions assume you are now in that directory: | |
52 | |
53 $ cd src | |
54 | |
55 *Optional*: You can also [install API keys](https://www.chromium.org/developers/ how-tos/api-keys) | |
56 if you want to talk to some of the Google services, but this is not necessary | |
57 for most development and testing purposes. | |
31 | 58 |
32 ## Building | 59 ## Building |
33 | 60 |
34 Chromium on OS X is built using the [Ninja](ninja_build.md) tool and | 61 Chromium uses [Ninja](https://ninja-build.org) as its main build tool, and |
35 the [Clang](clang.md) compiler. See both of those pages for further details on | 62 a tool called [GN](../tools/gn/docs/quick_start.md) to generate |
36 how to tune the build. | 63 the .ninja files to do the build. To create a build directory: |
37 | 64 |
38 Run | 65 $ gn gen out/Default |
39 | 66 |
40 gn gen out/gn | 67 * You only have to do run this command once, it will self-update the build |
68 files as needed after that. | |
69 * You can replace `out/Default` with another directory name, but we recommend | |
70 it should still be a subdirectory of `out`. | |
71 * To specify build parameters for GN builds, including release settings, | |
72 see [GN build configuration](https://www.chromium.org/developers/gn-build-conf iguration). | |
73 The default will be a debug component build matching the current host | |
74 operating system and CPU. | |
75 * For more info on GN, run `gn help` on the command line or read the | |
76 [quick start guide](../tools/gn/docs/quick_start.md). | |
41 | 77 |
42 to generate build files (replace "gn" in "out/gn" with whatever you like), and | |
43 then run | |
44 | 78 |
45 ninja -C out/gn chrome | 79 ### Faster builds |
46 | |
47 to build. You can edit out/gn/args.gn to configure the build. | |
48 | |
49 Before you build, you may want to | |
50 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/how-to s/api-keys) | |
51 so that Chrome-integrated Google services work. This step is optional if you | |
52 aren't testing those features. | |
53 | |
54 ## Faster builds | |
55 | 80 |
56 Full rebuilds are about the same speed in Debug and Release, but linking is a | 81 Full rebuilds are about the same speed in Debug and Release, but linking is a |
57 lot faster in Release builds. | 82 lot faster in Release builds. |
58 | 83 |
59 Put | 84 Put |
60 | 85 |
61 is_debug = false | 86 is_debug = false |
62 | 87 |
63 in your args.gn to do a release build. | 88 in your args.gn to do a release build. |
64 | 89 |
65 Put | 90 Put |
66 | 91 |
67 is_component_build = true | 92 is_component_build = true |
68 | 93 |
69 in your args.gn to build many small dylibs instead of a single large executable. | 94 in your args.gn to build many small dylibs instead of a single large executable. |
70 This makes incremental builds much faster, at the cost of producing a binary | 95 This makes incremental builds much faster, at the cost of producing a binary |
71 that opens less quickly. Component builds work in both debug and release. | 96 that opens less quickly. Component builds work in both debug and release. |
72 | 97 |
73 Put | 98 Put |
74 | 99 |
75 symbol_level = 1 | 100 symbol_level = 0 |
76 | 101 |
77 in your args.gn to disable debug symbols altogether. This makes both full | 102 in your args.gn to disable debug symbols altogether. This makes both full |
78 rebuilds and linking faster (at the cost of not getting symbolized backtraces | 103 rebuilds and linking faster (at the cost of not getting symbolized backtraces |
79 in gdb). | 104 in gdb). |
80 | 105 |
81 You might also want to [install ccache](ccache_mac.md) to speed up the build. | 106 You might also want to [install ccache](ccache_mac.md) to speed up the build. |
82 | 107 |
83 ## Running | 108 ## Run Chromium |
84 | 109 |
85 All build output is located in the `out` directory (in the example above, | 110 Once it is built, you can simply run the browser: |
86 `~/chromium/src/out`). You can find the applications at | |
87 `gn/Content Shell.app` and `gn/Chromium.app`. | |
88 | 111 |
89 ## Unit Tests | 112 $ out/Default/chrome |
90 | 113 |
91 We have several unit test targets that build, and tests that run and pass. A | 114 ## Running test targets |
92 small subset of these is: | |
93 | 115 |
94 * `unit_tests` from `chrome/chrome.gyp` | 116 You can run the tests in the same way. You can also limit which tests are |
95 * `base_unittests` from `base/base.gyp` | 117 run using the `--gtest_filter` arg, e.g.: |
96 * `net_unittests` from `net/net.gyp` | |
97 * `url_unittests` from `url/url.gyp` | |
98 | 118 |
99 When these tests are built, you will find them in the `out/gn` | 119 $ ninja -C out/Default unit_tests --gtest_filter="PushClientTest.*" |
Nico
2016/11/30 18:47:08
this should be
$ out/Default/unit_tests --gtest
| |
100 directory. You can run them from the command line: | |
101 | 120 |
102 ~/chromium/src/out/gn/unit_tests | 121 You can find out more about GoogleTest at its |
103 | 122 [GitHub page](https://github.com/google/googletest). |
104 | |
105 ## Coding | |
106 | |
107 According to the | |
108 [Chromium style guide](http://dev.chromium.org/developers/coding-style) code is | |
109 [not allowed to have whitespace on the ends of lines](https://google.github.io/s tyleguide/cppguide.html#Horizontal_Whitespace). | |
110 | |
111 Run `git cl format` after committing to your local branch and before uploading | |
112 to clang-format your code. | |
113 | 123 |
114 ## Debugging | 124 ## Debugging |
115 | 125 |
116 Good debugging tips can be found | 126 Good debugging tips can be found |
117 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you | 127 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you |
118 would like to debug in a graphical environment, rather than using `lldb` at the | 128 would like to debug in a graphical environment, rather than using `lldb` at the |
119 command line, that is possible without building in Xcode. See | 129 command line, that is possible without building in Xcode. See |
120 [Debugging in Xcode](http://www.chromium.org/developers/how-tos/debugging-on-os- x/building-with-ninja-debugging-with-xcode) | 130 [Debugging in Xcode](http://www.chromium.org/developers/how-tos/debugging-on-os- x/building-with-ninja-debugging-with-xcode) |
121 for information on how. | 131 for information on how. |
122 | 132 |
123 ## Contributing | 133 ## Update your checkout |
124 | 134 |
125 Once you’re comfortable with building Chromium, check out | 135 To update an existing checkout, you can run |
126 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for | |
127 information about writing code for Chromium and contributing it. | |
128 | 136 |
129 ## Using Xcode-Ninja Hybrid | 137 $ git rebase-update |
138 $ gclient sync | |
139 | |
140 The first command updates the primary Chromium source repository and rebases | |
141 any of your local branches on top of tip-of-tree (aka the Git branch `origin/mas ter`). | |
142 If you don't want to use this script, you can also just use `git pull` or | |
143 other common Git commands to update the repo. | |
144 | |
145 The second command syncs the subrepositories to the appropriate versions and | |
146 re-runs the hooks as needed. | |
147 | |
148 ## Tips, tricks, and troubleshooting | |
149 | |
150 ### Using Xcode-Ninja Hybrid | |
130 | 151 |
131 While using Xcode is unsupported, gn supports a hybrid approach of using ninja | 152 While using Xcode is unsupported, gn supports a hybrid approach of using ninja |
132 for building, but Xcode for editing and driving compilation. Xcode is still | 153 for building, but Xcode for editing and driving compilation. Xcode is still |
133 slow, but it runs fairly well even **with indexing enabled**. Most people | 154 slow, but it runs fairly well even **with indexing enabled**. Most people |
134 build in the Terminal and write code with a text editor though. | 155 build in the Terminal and write code with a text editor though. |
135 | 156 |
136 With hybrid builds, compilation is still handled by ninja, and can be run by the | 157 With hybrid builds, compilation is still handled by ninja, and can be run by the |
137 command line (e.g. ninja -C out/gn chrome) or by choosing the chrome target | 158 command line (e.g. ninja -C out/gn chrome) or by choosing the chrome target |
138 in the hybrid workspace and choosing build. | 159 in the hybrid workspace and choosing build. |
139 | 160 |
(...skipping 14 matching lines...) Expand all Loading... | |
154 choose the Options tab, and uncheck "Allow debugging when using document | 175 choose the Options tab, and uncheck "Allow debugging when using document |
155 Versions Browser". When this option is checked, Xcode adds | 176 Versions Browser". When this option is checked, Xcode adds |
156 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets | 177 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets |
157 interpreted as a URL to open. | 178 interpreted as a URL to open. |
158 | 179 |
159 If you have problems building, join us in `#chromium` on `irc.freenode.net` and | 180 If you have problems building, join us in `#chromium` on `irc.freenode.net` and |
160 ask there. As mentioned above, be sure that the | 181 ask there. As mentioned above, be sure that the |
161 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree | 182 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree |
162 is open before checking out. This will increase your chances of success. | 183 is open before checking out. This will increase your chances of success. |
163 | 184 |
164 ## Improving performance of `git status` | 185 ### Improving performance of `git status` |
165 | 186 |
166 `git status` is used frequently to determine the status of your checkout. Due | 187 `git status` is used frequently to determine the status of your checkout. Due |
167 to the number of files in Chromium's checkout, `git status` performance can be | 188 to the number of files in Chromium's checkout, `git status` performance can be |
168 quite variable. Increasing the system's vnode cache appears to help. By | 189 quite variable. Increasing the system's vnode cache appears to help. By |
169 default, this command: | 190 default, this command: |
170 | 191 |
171 sysctl -a | egrep kern\..*vnodes | 192 sysctl -a | egrep kern\..*vnodes |
172 | 193 |
173 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this | 194 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this |
174 setting: | 195 setting: |
175 | 196 |
176 sudo sysctl kern.maxvnodes=$((512*1024)) | 197 sudo sysctl kern.maxvnodes=$((512*1024)) |
177 | 198 |
178 Higher values may be appropriate if you routinely move between different | 199 Higher values may be appropriate if you routinely move between different |
179 Chromium checkouts. This setting will reset on reboot, the startup setting can | 200 Chromium checkouts. This setting will reset on reboot, the startup setting can |
180 be set in `/etc/sysctl.conf`: | 201 be set in `/etc/sysctl.conf`: |
181 | 202 |
182 echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf | 203 echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf |
183 | 204 |
184 Or edit the file directly. | 205 Or edit the file directly. |
185 | 206 |
186 If your `git --version` reports 2.6 or higher, the following may also improve | 207 If your `git --version` reports 2.6 or higher, the following may also improve |
187 performance of `git status`: | 208 performance of `git status`: |
188 | 209 |
189 git update-index --untracked-cache | 210 git update-index --untracked-cache |
190 | 211 |
191 ## Xcode license agreement | 212 ### Xcode license agreement |
192 | 213 |
193 If you're getting the error | 214 If you're getting the error |
194 | 215 |
195 ``` | 216 ``` |
196 Agreeing to the Xcode/iOS license requires admin privileges, please re-run as ro ot via sudo. | 217 Agreeing to the Xcode/iOS license requires admin privileges, please re-run as ro ot via sudo. |
197 ``` | 218 ``` |
198 | 219 |
199 the Xcode license hasn't been accepted yet which (contrary to the message) any | 220 the Xcode license hasn't been accepted yet which (contrary to the message) any |
200 user can do by running: | 221 user can do by running: |
201 | 222 |
202 xcodebuild -license | 223 xcodebuild -license |
203 | 224 |
204 Only accepting for all users of the machine requires root: | 225 Only accepting for all users of the machine requires root: |
205 | 226 |
206 sudo xcodebuild -license | 227 sudo xcodebuild -license |
OLD | NEW |