OLD | NEW |
1 # Mac Build Instructions | 1 # Mac Build Instructions |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 ## Prerequisites | 5 ## Prerequisites |
6 | 6 |
7 * A Mac running 10.9+. | 7 * A Mac running 10.9+. |
8 * [Xcode](https://developer.apple.com/xcode) 5+. | 8 * [Xcode](https://developer.apple.com/xcode) 7.3+. |
9 * [depot\_tools](http://dev.chromium.org/developers/how-tos/depottools). | 9 * [depot\_tools](http://dev.chromium.org/developers/how-tos/depottools). |
10 * Xcode Command Line Tools. Run | |
11 ``` | |
12 xcode-select --install | |
13 ``` | |
14 to install them. | |
15 * The OSX 10.10 SDK. Run | 10 * The OSX 10.10 SDK. Run |
16 ``` | 11 ``` |
17 ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs | 12 ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs |
18 ``` | 13 ``` |
19 to check whether you have it. If you don't have it, you need to get one from | 14 to check whether you have it. Building with the 10.11 SDK works too, but |
20 an install of Xcode 6, and place it in the above directory. | 15 the releases currently use the 10.10 SDK. |
21 | 16 |
22 ## Getting the code | 17 ## Getting the code |
23 | 18 |
24 [Check out the source code](https://www.chromium.org/developers/how-tos/get-the-
code) | 19 [Check out the source code](https://www.chromium.org/developers/how-tos/get-the-
code) |
25 using Git. | 20 using Git. |
26 | 21 |
27 Before checking out, go to the | 22 Before checking out, go to the |
28 [waterfall](http://build.chromium.org/buildbot/waterfall/) and check that the | 23 [waterfall](http://build.chromium.org/buildbot/waterfall/) and check that the |
29 source tree is open (to avoid pulling a broken tree). | 24 source tree is open (to avoid pulling a broken tree). |
30 | 25 |
31 The path to the build directory should not contain spaces (e.g. not | 26 The path to the build directory should not contain spaces (e.g. not |
32 `~/Mac OS X/chromium`), as this will cause the build to fail. This includes your | 27 `~/Mac OS X/chromium`), as this will cause the build to fail. This includes your |
33 drive name, the default "Macintosh HD2" for a second drive has a space. | 28 drive name, the default "Macintosh HD2" for a second drive has a space. |
34 | 29 |
35 ## Building | 30 ## Building |
36 | 31 |
37 Chromium on OS X can only be built using the [Ninja](ninja_build.md) tool and | 32 Chromium on OS X is built using the [Ninja](ninja_build.md) tool and |
38 the [Clang](clang.md) compiler. See both of those pages for further details on | 33 the [Clang](clang.md) compiler. See both of those pages for further details on |
39 how to tune the build. | 34 how to tune the build. |
40 | 35 |
| 36 Run |
| 37 |
| 38 gn gen out/gn |
| 39 |
| 40 to generate build files (replace "gn" in "out/gn" with whatever you like), and |
| 41 then run |
| 42 |
| 43 ninja -C out/gn chrome |
| 44 |
| 45 to build. You can edit out/gn/args.gn to configure the build. |
| 46 |
41 Before you build, you may want to | 47 Before you build, you may want to |
42 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/how-to
s/api-keys) | 48 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/how-to
s/api-keys) |
43 so that Chrome-integrated Google services work. This step is optional if you | 49 so that Chrome-integrated Google services work. This step is optional if you |
44 aren't testing those features. | 50 aren't testing those features. |
45 | 51 |
46 ### Raising system-wide and per-user process limits | |
47 | |
48 If you see errors like the following: | |
49 | |
50 ``` | |
51 clang: error: unable to execute command: posix_spawn failed: Resource temporaril
y unavailable | |
52 clang: error: clang frontend command failed due to signal (use -v to see invocat
ion) | |
53 ``` | |
54 | |
55 you may be running into too-low limits on the number of concurrent processes | |
56 allowed on the machine. Check: | |
57 | |
58 sysctl kern.maxproc | |
59 sysctl kern.maxprocperuid | |
60 | |
61 You can increase them with e.g.: | |
62 | |
63 sudo sysctl -w kern.maxproc=2500 | |
64 sudo sysctl -w kern.maxprocperuid=2500 | |
65 | |
66 But normally this shouldn't be necessary if you're building on 10.7 or higher. | |
67 If you see this, check if some rogue program spawned hundreds of processes and | |
68 kill them first. | |
69 | |
70 ## Faster builds | 52 ## Faster builds |
71 | 53 |
72 Full rebuilds are about the same speed in Debug and Release, but linking is a | 54 Full rebuilds are about the same speed in Debug and Release, but linking is a |
73 lot faster in Release builds. | 55 lot faster in Release builds. |
74 | 56 |
75 Run | 57 Put |
76 | 58 |
77 GYP_DEFINES=fastbuild=1 build/gyp_chromium | 59 is_debug = false |
78 | 60 |
79 to disable debug symbols altogether, this makes both full rebuilds and linking | 61 in your args.gn to do a release build. |
80 faster (at the cost of not getting symbolized backtraces in gdb). | 62 |
| 63 Put |
| 64 |
| 65 is_component_build = true |
| 66 |
| 67 in your args.gn to build many small dylibs instead of a single large executable. |
| 68 This makes incremental builds much faster, at the cost of producing a binary |
| 69 that opens less quickly. Component builds work in both debug and release. |
| 70 |
| 71 Put |
| 72 |
| 73 symbol_level = 1 |
| 74 |
| 75 in your args.gn to disable debug symbols altogether. This makes both full |
| 76 rebuilds and linking faster (at the cost of not getting symbolized backtraces |
| 77 in gdb). |
81 | 78 |
82 You might also want to [install ccache](ccache_mac.md) to speed up the build. | 79 You might also want to [install ccache](ccache_mac.md) to speed up the build. |
83 | 80 |
84 ## Running | 81 ## Running |
85 | 82 |
86 All build output is located in the `out` directory (in the example above, | 83 All build output is located in the `out` directory (in the example above, |
87 `~/chromium/src/out`). You can find the applications at | 84 `~/chromium/src/out`). You can find the applications at |
88 `{Debug|Release}/ContentShell.app` and `{Debug|Release}/Chromium.app`, depending | 85 `gn/Content Shell.app` and `gn/Chromium.app`. |
89 on the selected configuration. | |
90 | 86 |
91 ## Unit Tests | 87 ## Unit Tests |
92 | 88 |
93 We have several unit test targets that build, and tests that run and pass. A | 89 We have several unit test targets that build, and tests that run and pass. A |
94 small subset of these is: | 90 small subset of these is: |
95 | 91 |
96 * `unit_tests` from `chrome/chrome.gyp` | 92 * `unit_tests` from `chrome/chrome.gyp` |
97 * `base_unittests` from `base/base.gyp` | 93 * `base_unittests` from `base/base.gyp` |
98 * `net_unittests` from `net/net.gyp` | 94 * `net_unittests` from `net/net.gyp` |
99 * `url_unittests` from `url/url.gyp` | 95 * `url_unittests` from `url/url.gyp` |
100 | 96 |
101 When these tests are built, you will find them in the `out/{Debug|Release}` | 97 When these tests are built, you will find them in the `out/gn` |
102 directory. You can run them from the command line: | 98 directory. You can run them from the command line: |
103 | 99 |
104 ~/chromium/src/out/Release/unit_tests | 100 ~/chromium/src/out/gn/unit_tests |
105 | 101 |
106 | 102 |
107 ## Coding | 103 ## Coding |
108 | 104 |
109 According to the | 105 According to the |
110 [Chromium style guide](http://dev.chromium.org/developers/coding-style) code is | 106 [Chromium style guide](http://dev.chromium.org/developers/coding-style) code is |
111 [not allowed to have whitespace on the ends of lines](https://google.github.io/s
tyleguide/cppguide.html#Horizontal_Whitespace). | 107 [not allowed to have whitespace on the ends of lines](https://google.github.io/s
tyleguide/cppguide.html#Horizontal_Whitespace). |
112 If you edit in Xcode, know that it loves adding whitespace to the ends of lines | 108 |
113 which can make editing in Xcode more painful than it should be. The | 109 Run `git cl format` after committing to your local branch and before uploading |
114 [GTM Xcode Plugin](http://code.google.com/p/google-toolbox-for-mac/downloads/lis
t) | 110 to clang-format your code. |
115 adds a preference panel to Xcode that allows you to strip whitespace off of the | |
116 ends of lines on save. Documentation on how to install it is | |
117 [here](http://code.google.com/p/google-toolbox-for-mac/wiki/GTMXcodePlugin). | |
118 | 111 |
119 ## Debugging | 112 ## Debugging |
120 | 113 |
121 Good debugging tips can be found | 114 Good debugging tips can be found |
122 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you | 115 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you |
123 would like to debug in a graphical environment, rather than using `lldb` at the | 116 would like to debug in a graphical environment, rather than using `lldb` at the |
124 command line, that is possible without building in Xcode. See | 117 command line, that is possible without building in Xcode. See |
125 [Debugging in Xcode](http://www.chromium.org/developers/debugging-on-os-x/buildi
ng-with-ninja-debugging-with-xcode) | 118 [Debugging in Xcode](http://www.chromium.org/developers/how-tos/debugging-on-os-
x/building-with-ninja-debugging-with-xcode) |
126 for information on how. | 119 for information on how. |
127 | 120 |
128 ## Contributing | 121 ## Contributing |
129 | 122 |
130 Once you’re comfortable with building Chromium, check out | 123 Once you’re comfortable with building Chromium, check out |
131 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for | 124 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for |
132 information about writing code for Chromium and contributing it. | 125 information about writing code for Chromium and contributing it. |
133 | 126 |
134 ## Using Xcode-Ninja Hybrid | 127 ## Using Xcode-Ninja Hybrid |
135 | 128 |
136 While using Xcode is unsupported, GYP supports a hybrid approach of using ninja | 129 While using Xcode is unsupported, gn supports a hybrid approach of using ninja |
137 for building, but Xcode for editing and driving compilation. Xcode can still be | 130 for building, but Xcode for editing and driving compilation. Xcode is still |
138 slow, but it runs fairly well even **with indexing enabled**. | 131 slow, but it runs fairly well even **with indexing enabled**. Most people |
| 132 build in the Terminal and write code with a text editor though. |
139 | 133 |
140 With hybrid builds, compilation is still handled by ninja, and can be run by the | 134 With hybrid builds, compilation is still handled by ninja, and can be run by the |
141 command line (e.g. ninja -C out/Debug chrome) or by choosing the chrome target | 135 command line (e.g. ninja -C out/gn chrome) or by choosing the chrome target |
142 in the hybrid workspace and choosing build. | 136 in the hybrid workspace and choosing build. |
143 | 137 |
144 To use Xcode-Ninja Hybrid, set GYP\_GENERATORS like the following: | 138 To use Xcode-Ninja Hybrid pass --ide=xcode to `gn gen` |
145 | 139 |
146 ```shell | 140 ```shell |
147 export GYP_GENERATORS="ninja,xcode-ninja" | 141 gn gen out/gn --ide=xcode |
148 ``` | 142 ``` |
149 | 143 |
150 Due to the way Xcode parses ninja output paths, it's also necessary to change | 144 Open it: |
151 the main gyp location to anything two directories deep. Otherwise Xcode build | |
152 output will not be clickable. | |
153 To make this change permanent, you can edit `chromium.gyp_env` (or create it if | |
154 it does not exists) and define GYP\_GENERATOR\_FLAGS. In general, to use hybrid | |
155 mode, your `chromium.gyp_env` could contain the following: | |
156 | |
157 ```json | |
158 { | |
159 "GYP_GENERATORS" : "ninja,xcode-ninja", | |
160 "GYP_GENERATOR_FLAGS": | |
161 "xcode_project_version=3.2 " + | |
162 "xcode_ninja_main_gyp=src/build/ninja/all.ninja.gyp", | |
163 } | |
164 ``` | |
165 | |
166 After, generate the project files with: | |
167 | 145 |
168 ```shell | 146 ```shell |
169 gclient runhooks | 147 open out/gn/ninja/all.xcworkspace |
170 ``` | |
171 | |
172 And finally, open it: | |
173 | |
174 ```shell | |
175 open build/ninja/all.ninja.xcworkspace | |
176 ``` | 148 ``` |
177 | 149 |
178 You may run into a problem where http://YES is opened as a new tab every time | 150 You may run into a problem where http://YES is opened as a new tab every time |
179 you launch Chrome. To fix this, open the scheme editor for the Run scheme, | 151 you launch Chrome. To fix this, open the scheme editor for the Run scheme, |
180 choose the Options tab, and uncheck "Allow debugging when using document | 152 choose the Options tab, and uncheck "Allow debugging when using document |
181 Versions Browser". When this option is checked, Xcode adds | 153 Versions Browser". When this option is checked, Xcode adds |
182 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets | 154 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets |
183 interpreted as a URL to open. | 155 interpreted as a URL to open. |
184 | 156 |
185 If you want to limit the number of targets visible, which is known to improve | |
186 Xcode performance, add `xcode_ninja_executable_target_pattern=%target%` where | |
187 `%target%` is a regular expression matching executable targets you'd like to | |
188 include. | |
189 | |
190 To include non-executable targets, use `xcode_ninja_target_pattern=All_iOS`. | |
191 | |
192 If you have problems building, join us in `#chromium` on `irc.freenode.net` and | 157 If you have problems building, join us in `#chromium` on `irc.freenode.net` and |
193 ask there. As mentioned above, be sure that the | 158 ask there. As mentioned above, be sure that the |
194 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree | 159 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree |
195 is open before checking out. This will increase your chances of success. | 160 is open before checking out. This will increase your chances of success. |
196 | 161 |
197 ## Using Emacs as `EDITOR` for `git commit` | |
198 | |
199 Using the [Cocoa version of Emacs](http://emacsformacosx.com/) as the `EDITOR` | |
200 environment variable on Mac OS will cause `git commit` to open the message in a | |
201 window underneath all the others. To fix this, create a shell script somewhere | |
202 (call it `$HOME/bin/EmacsEditor` in this example) containing the following: | |
203 | |
204 ``` | |
205 #!/bin/sh | |
206 | |
207 # All of these hacks are needed to get "git commit" to launch a new | |
208 # instance of Emacs on top of everything else, properly pointing to | |
209 # the COMMIT_EDITMSG. | |
210 | |
211 realpath() { | |
212 [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}" | |
213 } | |
214 | |
215 i=0 | |
216 full_paths=() | |
217 for arg in "$@" | |
218 do | |
219 full_paths[$i]=$(realpath $arg) | |
220 ((++i)) | |
221 done | |
222 | |
223 open -nWa /Applications/Emacs.app/Contents/MacOS/Emacs --args --no-desktop \ | |
224 "${full_paths[@]}" | |
225 ``` | |
226 | |
227 and in your `.bashrc` or similar, | |
228 | |
229 export EDITOR=$HOME/bin/EmacsEditor | |
230 | |
231 ## Improving performance of `git status` | 162 ## Improving performance of `git status` |
232 | 163 |
233 `git status` is used frequently to determine the status of your checkout. Due | 164 `git status` is used frequently to determine the status of your checkout. Due |
234 to the number of files in Chromium's checkout, `git status` performance can be | 165 to the number of files in Chromium's checkout, `git status` performance can be |
235 quite variable. Increasing the system's vnode cache appears to help. By | 166 quite variable. Increasing the system's vnode cache appears to help. By |
236 default, this command: | 167 default, this command: |
237 | 168 |
238 sysctl -a | egrep kern\..*vnodes | 169 sysctl -a | egrep kern\..*vnodes |
239 | 170 |
240 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this | 171 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this |
(...skipping 23 matching lines...) Expand all Loading... |
264 ``` | 195 ``` |
265 | 196 |
266 the Xcode license hasn't been accepted yet which (contrary to the message) any | 197 the Xcode license hasn't been accepted yet which (contrary to the message) any |
267 user can do by running: | 198 user can do by running: |
268 | 199 |
269 xcodebuild -license | 200 xcodebuild -license |
270 | 201 |
271 Only accepting for all users of the machine requires root: | 202 Only accepting for all users of the machine requires root: |
272 | 203 |
273 sudo xcodebuild -license | 204 sudo xcodebuild -license |
OLD | NEW |