| OLD | NEW |
| (Empty) |
| 1 # Mac Build Instructions | |
| 2 | |
| 3 **Generally, this page is obsolete and you should look at | |
| 4 [the new page instead](mac_build_instructions.md).** | |
| 5 | |
| 6 [TOC] | |
| 7 | |
| 8 Google employee? See [go/building-chrome-mac](https://goto.google.com/building-c
hrome-mac) for extra tips. | |
| 9 | |
| 10 ## Prerequisites | |
| 11 | |
| 12 * A Mac running 10.9+. | |
| 13 * [Xcode](https://developer.apple.com/xcode) 7.3+. | |
| 14 * [depot\_tools](http://dev.chromium.org/developers/how-tos/depottools). | |
| 15 * The OSX 10.10 SDK. Run | |
| 16 ``` | |
| 17 ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs | |
| 18 ``` | |
| 19 to check whether you have it. Building with the 10.11 SDK works too, but | |
| 20 the releases currently use the 10.10 SDK. | |
| 21 | |
| 22 ## Getting the code | |
| 23 | |
| 24 [Check out the source code](https://www.chromium.org/developers/how-tos/get-the-
code) | |
| 25 using Git. | |
| 26 | |
| 27 Before checking out, go to the | |
| 28 [waterfall](http://build.chromium.org/buildbot/waterfall/) and check that the | |
| 29 source tree is open (to avoid pulling a broken tree). | |
| 30 | |
| 31 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 | |
| 33 drive name, the default "Macintosh HD2" for a second drive has a space. | |
| 34 | |
| 35 ## Building | |
| 36 | |
| 37 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 | |
| 39 how to tune the build. | |
| 40 | |
| 41 Run | |
| 42 | |
| 43 gn gen out/gn | |
| 44 | |
| 45 to generate build files (replace "gn" in "out/gn" with whatever you like), and | |
| 46 then run | |
| 47 | |
| 48 ninja -C out/gn chrome | |
| 49 | |
| 50 to build. You can edit out/gn/args.gn to configure the build. | |
| 51 | |
| 52 Before you build, you may want to | |
| 53 [install API keys](https://sites.google.com/a/chromium.org/dev/developers/how-to
s/api-keys) | |
| 54 so that Chrome-integrated Google services work. This step is optional if you | |
| 55 aren't testing those features. | |
| 56 | |
| 57 ## Faster builds | |
| 58 | |
| 59 Full rebuilds are about the same speed in Debug and Release, but linking is a | |
| 60 lot faster in Release builds. | |
| 61 | |
| 62 Put | |
| 63 | |
| 64 is_debug = false | |
| 65 | |
| 66 in your args.gn to do a release build. | |
| 67 | |
| 68 Put | |
| 69 | |
| 70 is_component_build = true | |
| 71 | |
| 72 in your args.gn to build many small dylibs instead of a single large executable. | |
| 73 This makes incremental builds much faster, at the cost of producing a binary | |
| 74 that opens less quickly. Component builds work in both debug and release. | |
| 75 | |
| 76 Put | |
| 77 | |
| 78 symbol_level = 1 | |
| 79 | |
| 80 in your args.gn to disable debug symbols altogether. This makes both full | |
| 81 rebuilds and linking faster (at the cost of not getting symbolized backtraces | |
| 82 in gdb). | |
| 83 | |
| 84 You might also want to [install ccache](ccache_mac.md) to speed up the build. | |
| 85 | |
| 86 ## Running | |
| 87 | |
| 88 All build output is located in the `out` directory (in the example above, | |
| 89 `~/chromium/src/out`). You can find the applications at | |
| 90 `gn/Content Shell.app` and `gn/Chromium.app`. | |
| 91 | |
| 92 ## Unit Tests | |
| 93 | |
| 94 We have several unit test targets that build, and tests that run and pass. A | |
| 95 small subset of these is: | |
| 96 | |
| 97 * `unit_tests` from `chrome/chrome.gyp` | |
| 98 * `base_unittests` from `base/base.gyp` | |
| 99 * `net_unittests` from `net/net.gyp` | |
| 100 * `url_unittests` from `url/url.gyp` | |
| 101 | |
| 102 When these tests are built, you will find them in the `out/gn` | |
| 103 directory. You can run them from the command line: | |
| 104 | |
| 105 ~/chromium/src/out/gn/unit_tests | |
| 106 | |
| 107 | |
| 108 ## Coding | |
| 109 | |
| 110 According to the | |
| 111 [Chromium style guide](http://dev.chromium.org/developers/coding-style) code is | |
| 112 [not allowed to have whitespace on the ends of lines](https://google.github.io/s
tyleguide/cppguide.html#Horizontal_Whitespace). | |
| 113 | |
| 114 Run `git cl format` after committing to your local branch and before uploading | |
| 115 to clang-format your code. | |
| 116 | |
| 117 ## Debugging | |
| 118 | |
| 119 Good debugging tips can be found | |
| 120 [here](http://dev.chromium.org/developers/how-tos/debugging-on-os-x). If you | |
| 121 would like to debug in a graphical environment, rather than using `lldb` at the | |
| 122 command line, that is possible without building in Xcode. See | |
| 123 [Debugging in Xcode](http://www.chromium.org/developers/how-tos/debugging-on-os-
x/building-with-ninja-debugging-with-xcode) | |
| 124 for information on how. | |
| 125 | |
| 126 ## Contributing | |
| 127 | |
| 128 Once you’re comfortable with building Chromium, check out | |
| 129 [Contributing Code](http://dev.chromium.org/developers/contributing-code) for | |
| 130 information about writing code for Chromium and contributing it. | |
| 131 | |
| 132 ## Using Xcode-Ninja Hybrid | |
| 133 | |
| 134 While using Xcode is unsupported, gn supports a hybrid approach of using ninja | |
| 135 for building, but Xcode for editing and driving compilation. Xcode is still | |
| 136 slow, but it runs fairly well even **with indexing enabled**. Most people | |
| 137 build in the Terminal and write code with a text editor though. | |
| 138 | |
| 139 With hybrid builds, compilation is still handled by ninja, and can be run by the | |
| 140 command line (e.g. ninja -C out/gn chrome) or by choosing the chrome target | |
| 141 in the hybrid workspace and choosing build. | |
| 142 | |
| 143 To use Xcode-Ninja Hybrid pass --ide=xcode to `gn gen` | |
| 144 | |
| 145 ```shell | |
| 146 gn gen out/gn --ide=xcode | |
| 147 ``` | |
| 148 | |
| 149 Open it: | |
| 150 | |
| 151 ```shell | |
| 152 open out/gn/ninja/all.xcworkspace | |
| 153 ``` | |
| 154 | |
| 155 You may run into a problem where http://YES is opened as a new tab every time | |
| 156 you launch Chrome. To fix this, open the scheme editor for the Run scheme, | |
| 157 choose the Options tab, and uncheck "Allow debugging when using document | |
| 158 Versions Browser". When this option is checked, Xcode adds | |
| 159 `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` gets | |
| 160 interpreted as a URL to open. | |
| 161 | |
| 162 If you have problems building, join us in `#chromium` on `irc.freenode.net` and | |
| 163 ask there. As mentioned above, be sure that the | |
| 164 [waterfall](http://build.chromium.org/buildbot/waterfall/) is green and the tree | |
| 165 is open before checking out. This will increase your chances of success. | |
| 166 | |
| 167 ## Improving performance of `git status` | |
| 168 | |
| 169 `git status` is used frequently to determine the status of your checkout. Due | |
| 170 to the number of files in Chromium's checkout, `git status` performance can be | |
| 171 quite variable. Increasing the system's vnode cache appears to help. By | |
| 172 default, this command: | |
| 173 | |
| 174 sysctl -a | egrep kern\..*vnodes | |
| 175 | |
| 176 Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this | |
| 177 setting: | |
| 178 | |
| 179 sudo sysctl kern.maxvnodes=$((512*1024)) | |
| 180 | |
| 181 Higher values may be appropriate if you routinely move between different | |
| 182 Chromium checkouts. This setting will reset on reboot, the startup setting can | |
| 183 be set in `/etc/sysctl.conf`: | |
| 184 | |
| 185 echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf | |
| 186 | |
| 187 Or edit the file directly. | |
| 188 | |
| 189 If your `git --version` reports 2.6 or higher, the following may also improve | |
| 190 performance of `git status`: | |
| 191 | |
| 192 git update-index --untracked-cache | |
| 193 | |
| 194 ## Xcode license agreement | |
| 195 | |
| 196 If you're getting the error | |
| 197 | |
| 198 ``` | |
| 199 Agreeing to the Xcode/iOS license requires admin privileges, please re-run as ro
ot via sudo. | |
| 200 ``` | |
| 201 | |
| 202 the Xcode license hasn't been accepted yet which (contrary to the message) any | |
| 203 user can do by running: | |
| 204 | |
| 205 xcodebuild -license | |
| 206 | |
| 207 Only accepting for all users of the machine requires root: | |
| 208 | |
| 209 sudo xcodebuild -license | |
| OLD | NEW |