Chromium Code Reviews| 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" with whatever you like), and then run | |
|
Robert Sesek
2016/08/09 12:16:39
"out/gn" maybe, since gn appears twice in the comm
| |
| 41 | |
| 42 ninja -C out/gn chrome | |
| 43 | |
| 44 to build. You can edit out/gn/args.gn to configure the build. | |
| 45 | |
| 41 Before you build, you may want to | 46 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) | 47 [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 | 48 so that Chrome-integrated Google services work. This step is optional if you |
| 44 aren't testing those features. | 49 aren't testing those features. |
| 45 | 50 |
| 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 | 51 ## Faster builds |
| 71 | 52 |
| 72 Full rebuilds are about the same speed in Debug and Release, but linking is a | 53 Full rebuilds are about the same speed in Debug and Release, but linking is a |
| 73 lot faster in Release builds. | 54 lot faster in Release builds. |
| 74 | 55 |
| 75 Run | 56 Put |
| 76 | 57 |
| 77 GYP_DEFINES=fastbuild=1 build/gyp_chromium | 58 is_debug = false |
| 78 | 59 |
| 79 to disable debug symbols altogether, this makes both full rebuilds and linking | 60 in your args.gn to do a release build. |
| 80 faster (at the cost of not getting symbolized backtraces in gdb). | 61 |
| 62 Put | |
| 63 | |
| 64 is_component_build = true | |
| 65 | |
| 66 in your args.gn to build many small dylibs instead of a single large executable. | |
| 67 This makes incremental builds much faster, at the cost of producing a binary | |
| 68 that opens less quickly. Component builds work in both debug and release. | |
| 69 | |
| 70 Put | |
| 71 | |
| 72 symbol_level = 1 | |
| 73 | |
| 74 in your args.gn to disable debug symbols altogether. This makes both full | |
| 75 rebuilds and linking faster (at the cost of not getting symbolized backtraces | |
| 76 in gdb). | |
| 81 | 77 |
| 82 You might also want to [install ccache](ccache_mac.md) to speed up the build. | 78 You might also want to [install ccache](ccache_mac.md) to speed up the build. |
| 83 | 79 |
| 84 ## Running | 80 ## Running |
| 85 | 81 |
| 86 All build output is located in the `out` directory (in the example above, | 82 All build output is located in the `out` directory (in the example above, |
| 87 `~/chromium/src/out`). You can find the applications at | 83 `~/chromium/src/out`). You can find the applications at |
| 88 `{Debug|Release}/ContentShell.app` and `{Debug|Release}/Chromium.app`, depending | 84 `gn/ContentShell.app` and `gn/Chromium.app`. |
|
Robert Sesek
2016/08/09 12:16:40
"Content Shell" has a space in it.
| |
| 89 on the selected configuration. | |
| 90 | 85 |
| 91 ## Unit Tests | 86 ## Unit Tests |
| 92 | 87 |
| 93 We have several unit test targets that build, and tests that run and pass. A | 88 We have several unit test targets that build, and tests that run and pass. A |
| 94 small subset of these is: | 89 small subset of these is: |
| 95 | 90 |
| 96 * `unit_tests` from `chrome/chrome.gyp` | 91 * `unit_tests` from `chrome/chrome.gyp` |
| 97 * `base_unittests` from `base/base.gyp` | 92 * `base_unittests` from `base/base.gyp` |
| 98 * `net_unittests` from `net/net.gyp` | 93 * `net_unittests` from `net/net.gyp` |
| 99 * `url_unittests` from `url/url.gyp` | 94 * `url_unittests` from `url/url.gyp` |
| 100 | 95 |
| 101 When these tests are built, you will find them in the `out/{Debug|Release}` | 96 When these tests are built, you will find them in the `out/gn` |
| 102 directory. You can run them from the command line: | 97 directory. You can run them from the command line: |
| 103 | 98 |
| 104 ~/chromium/src/out/Release/unit_tests | 99 ~/chromium/src/out/gn/unit_tests |
| 105 | 100 |
| 106 | 101 |
| 107 ## Coding | 102 ## Coding |
| 108 | 103 |
| 109 According to the | 104 According to the |
| 110 [Chromium style guide](http://dev.chromium.org/developers/coding-style) code is | 105 [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). | 106 [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 | 107 |
| 113 which can make editing in Xcode more painful than it should be. The | 108 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) | 109 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 | 110 |
| 119 ## Debugging | 111 ## Debugging |
| 120 | 112 |
| 121 Good debugging tips can be found | 113 Good debugging tips can be found |
| 122 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you | 114 [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 | 115 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 | 116 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) | 117 [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. | 118 for information on how. |
| 127 | 119 |
| 128 ## Contributing | 120 ## Contributing |
| 129 | 121 |
| 130 Once you’re comfortable with building Chromium, check out | 122 Once you’re comfortable with building Chromium, check out |
| 131 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for | 123 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for |
| 132 information about writing code for Chromium and contributing it. | 124 information about writing code for Chromium and contributing it. |
| 133 | 125 |
| 134 ## Using Xcode-Ninja Hybrid | 126 ## Using Xcode-Ninja Hybrid |
| 135 | 127 |
| 136 While using Xcode is unsupported, GYP supports a hybrid approach of using ninja | 128 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 | 129 for building, but Xcode for editing and driving compilation. Xcode is still |
| 138 slow, but it runs fairly well even **with indexing enabled**. | 130 slow, but it runs fairly well even **with indexing enabled**. Most people |
| 131 build in the Terminal and write code with a text editor though. | |
| 139 | 132 |
| 140 With hybrid builds, compilation is still handled by ninja, and can be run by the | 133 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 | 134 command line (e.g. ninja -C out/gn chrome) or by choosing the chrome target |
| 142 in the hybrid workspace and choosing build. | 135 in the hybrid workspace and choosing build. |
| 143 | 136 |
| 144 To use Xcode-Ninja Hybrid, set GYP\_GENERATORS like the following: | 137 To use Xcode-Ninja Hybrid pass --ide=xcode to `gn gen` |
| 145 | 138 |
| 146 ```shell | 139 ```shell |
| 147 export GYP_GENERATORS="ninja,xcode-ninja" | 140 gn gen out/gn --ide=xcode |
| 148 ``` | 141 ``` |
| 149 | 142 |
| 150 Due to the way Xcode parses ninja output paths, it's also necessary to change | 143 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 | 144 |
| 168 ```shell | 145 ```shell |
| 169 gclient runhooks | 146 open out/gn/ninja/all.xcworkspace |
| 170 ``` | |
| 171 | |
| 172 And finally, open it: | |
| 173 | |
| 174 ```shell | |
| 175 open build/ninja/all.ninja.xcworkspace | |
| 176 ``` | 147 ``` |
| 177 | 148 |
| 178 You may run into a problem where http://YES is opened as a new tab every time | 149 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, | 150 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 | 151 choose the Options tab, and uncheck "Allow debugging when using document |
| 181 Versions Browser". When this option is checked, Xcode adds | 152 Versions Browser". When this option is checked, Xcode adds |
| 182 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets | 153 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets |
| 183 interpreted as a URL to open. | 154 interpreted as a URL to open. |
| 184 | 155 |
| 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 | 156 If you have problems building, join us in `#chromium` on `irc.freenode.net` and |
| 193 ask there. As mentioned above, be sure that the | 157 ask there. As mentioned above, be sure that the |
| 194 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree | 158 [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. | 159 is open before checking out. This will increase your chances of success. |
| 196 | 160 |
| 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` | 161 ## Improving performance of `git status` |
| 232 | 162 |
| 233 `git status` is used frequently to determine the status of your checkout. Due | 163 `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 | 164 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 | 165 quite variable. Increasing the system's vnode cache appears to help. By |
| 236 default, this command: | 166 default, this command: |
| 237 | 167 |
| 238 sysctl -a | egrep kern\..*vnodes | 168 sysctl -a | egrep kern\..*vnodes |
| 239 | 169 |
| 240 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this | 170 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 264 ``` | 194 ``` |
| 265 | 195 |
| 266 the Xcode license hasn't been accepted yet which (contrary to the message) any | 196 the Xcode license hasn't been accepted yet which (contrary to the message) any |
| 267 user can do by running: | 197 user can do by running: |
| 268 | 198 |
| 269 xcodebuild -license | 199 xcodebuild -license |
| 270 | 200 |
| 271 Only accepting for all users of the machine requires root: | 201 Only accepting for all users of the machine requires root: |
| 272 | 202 |
| 273 sudo xcodebuild -license | 203 sudo xcodebuild -license |
| OLD | NEW |