dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 1 | # Checking out and building Chromium for Mac |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 2 | |
erikchen | 7d7509a | 2017-10-02 23:40:36 | [diff] [blame] | 3 | There are instructions for other platforms linked from the |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 4 | [get the code](get_the_code.md) page. |
| 5 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 6 | ## Instructions for Google Employees |
| 7 | |
| 8 | Are you a Google employee? See |
| 9 | [go/building-chrome](https://goto.google.com/building-chrome) instead. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 10 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 11 | [TOC] |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 12 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 13 | ## System requirements |
sdy | a8197bd2 | 2016-09-14 19:06:42 | [diff] [blame] | 14 | |
Nico Weber | 3c9befa | 2021-11-03 17:07:11 | [diff] [blame] | 15 | * A Mac, Intel or Arm. |
Avi Drissman | ab7729b | 2021-06-10 19:17:15 | [diff] [blame] | 16 | ([More details about Arm Macs](https://chromium.googlesource.com/chromium/src.git/+/main/docs/mac_arm64.md).) |
Nico Weber | 3c9befa | 2021-11-03 17:07:11 | [diff] [blame] | 17 | * [Xcode](https://developer.apple.com/xcode/). Xcode comes with... |
| 18 | * The macOS SDK. Run |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 19 | |
erikchen | 7d7509a | 2017-10-02 23:40:36 | [diff] [blame] | 20 | ```shell |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 21 | $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs |
dominicc | a4e4c99 | 2016-05-23 22:08:03 | [diff] [blame] | 22 | ``` |
erikchen | 7d7509a | 2017-10-02 23:40:36 | [diff] [blame] | 23 | |
Nico Weber | 3c9befa | 2021-11-03 17:07:11 | [diff] [blame] | 24 | to check whether you have it, and what version you have. |
| 25 | `mac_sdk_official_version` in [mac_sdk.gni](../build/config/mac/mac_sdk.gni) |
| 26 | is the SDK version used on all the bots and for |
| 27 | [official builds](https://source.chromium.org/search?q=MAC_BINARIES_LABEL&ss=chromium), |
| 28 | so that version is guaranteed to work. Building with a newer SDK usually |
| 29 | works too (please fix or file a bug if it doesn't). |
wafuwafu13 | b6854ba5 | 2021-12-24 06:02:43 | [diff] [blame] | 30 | |
Nico Weber | 3c9befa | 2021-11-03 17:07:11 | [diff] [blame] | 31 | Building with an older SDK might also work, but if it doesn't then we won't |
| 32 | accept changes for making it work. |
wafuwafu13 | b6854ba5 | 2021-12-24 06:02:43 | [diff] [blame] | 33 | |
Nico Weber | 3c9befa | 2021-11-03 17:07:11 | [diff] [blame] | 34 | The easiest way to get the newest SDK is to use the newest version of Xcode, |
| 35 | which often requires using the newest version of macOS. We don't use Xcode |
| 36 | itself much, so if you're know what you're doing, you can likely get the |
| 37 | build working with an older version of macOS as long as you get a new |
| 38 | version of the macOS SDK on it. |
Nico Weber | 36cd0a55 | 2022-01-18 16:31:49 | [diff] [blame] | 39 | * An APFS-formatted volume (this is the default format for macOS volumes). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 40 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 41 | ## Install `depot_tools` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 42 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 43 | Clone the `depot_tools` repository: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 44 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 45 | ```shell |
| 46 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 47 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 48 | |
Gabriel Charette | b6780c1 | 2019-04-24 16:23:52 | [diff] [blame] | 49 | Add `depot_tools` to the end of your PATH (you will probably want to put this in |
| 50 | your `~/.bash_profile` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
| 51 | `/path/to/depot_tools` (note: you **must** use the absolute path or Python will |
| 52 | not be able to find infra tools): |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 53 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 54 | ```shell |
| 55 | $ export PATH="$PATH:/path/to/depot_tools" |
| 56 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 57 | |
| 58 | ## Get the code |
| 59 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 60 | Create a `chromium` directory for the checkout and change to it (you can call |
| 61 | this whatever you like and put it wherever you like, as long as the full path |
| 62 | has no spaces): |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 63 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 64 | ```shell |
| 65 | $ mkdir chromium && cd chromium |
| 66 | ``` |
| 67 | |
| 68 | Run the `fetch` tool from `depot_tools` to check out the code and its |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 69 | dependencies. |
| 70 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 71 | ```shell |
David Sanders | e382717 | 2022-02-08 15:48:56 | [diff] [blame] | 72 | $ caffeinate fetch chromium |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 73 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 74 | |
David Sanders | e382717 | 2022-02-08 15:48:56 | [diff] [blame] | 75 | Running the `fetch` with `caffeinate` is optional, but it will prevent the |
| 76 | system from sleeping for the duration of the `fetch` command, which may run for |
| 77 | a considerable amount of time. |
| 78 | |
[email protected] | 1436b95 | 2018-10-26 16:35:13 | [diff] [blame] | 79 | If you don't need the full repo history, you can save time by using |
Yannic Bonenberger | a6855700 | 2019-04-29 14:13:19 | [diff] [blame] | 80 | `fetch --no-history chromium`. You can call `git fetch --unshallow` to retrieve |
| 81 | the full history later. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 82 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 83 | Expect the command to take 30 minutes on even a fast connection, and many |
| 84 | hours on slower ones. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 85 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 86 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 87 | directory called `src` in the working directory. The remaining instructions |
| 88 | assume you have switched to the `src` directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 89 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 90 | ```shell |
| 91 | $ cd src |
| 92 | ``` |
| 93 | |
| 94 | *Optional*: You can also [install API |
| 95 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 96 | build to talk to some Google services, but this is not necessary for most |
| 97 | development and testing purposes. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 98 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 99 | ## Setting up the build |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 100 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 101 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 102 | a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 103 | to generate `.ninja` files. You can create any number of *build directories* |
| 104 | with different configurations. To create a build directory: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 105 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 106 | ```shell |
| 107 | $ gn gen out/Default |
| 108 | ``` |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 109 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 110 | * You only have to run this once for each new build directory, Ninja will |
| 111 | update the build files as needed. |
| 112 | * You can replace `Default` with another name, but |
| 113 | it should be a subdirectory of `out`. |
| 114 | * For other build arguments, including release settings, see [GN build |
| 115 | configuration](https://www.chromium.org/developers/gn-build-configuration). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 116 | The default will be a debug component build matching the current host |
| 117 | operating system and CPU. |
| 118 | * For more info on GN, run `gn help` on the command line or read the |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 119 | [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md). |
Reilly Grant | f057adf | 2020-11-03 17:42:37 | [diff] [blame] | 120 | * Building Chromium for arm Macs requires [additional setup](mac_arm64.md). |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 121 | |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 122 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 123 | ### Faster builds |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 124 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 125 | Full rebuilds are about the same speed in Debug and Release, but linking is a |
| 126 | lot faster in Release builds. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 127 | |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 128 | Put |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 129 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 130 | ``` |
| 131 | is_debug = false |
| 132 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 133 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 134 | in your `args.gn` to do a release build. |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 135 | |
| 136 | Put |
| 137 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 138 | ``` |
| 139 | is_component_build = true |
| 140 | ``` |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 141 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 142 | in your `args.gn` to build many small dylibs instead of a single large |
| 143 | executable. This makes incremental builds much faster, at the cost of producing |
| 144 | a binary that opens less quickly. Component builds work in both debug and |
| 145 | release. |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 146 | |
| 147 | Put |
| 148 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 149 | ``` |
| 150 | symbol_level = 0 |
| 151 | ``` |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 152 | |
| 153 | in your args.gn to disable debug symbols altogether. This makes both full |
| 154 | rebuilds and linking faster (at the cost of not getting symbolized backtraces |
| 155 | in gdb). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 156 | |
Andrew Williams | 54da9cc | 2024-01-09 17:32:23 | [diff] [blame] | 157 | #### Use Reclient |
| 158 | |
| 159 | In addition, Google employees should use Reclient, a distributed compilation system. |
| 160 | Detailed information is available internally but the relevant gn arg is: |
| 161 | * `use_remoteexec = true` |
| 162 | |
| 163 | Google employees can visit |
| 164 | [go/building-chrome-mac#using-remote-execution](https://goto.google.com/building-chrome-mac#using-remote-execution) |
| 165 | for more information. For external contributors, Reclient does not support Mac |
| 166 | builds. |
| 167 | |
Philip Rogers | eb84168 | 2017-10-09 16:08:50 | [diff] [blame] | 168 | #### CCache |
| 169 | |
philipj | 5a0fcb9 | 2016-01-23 23:23:40 | [diff] [blame] | 170 | You might also want to [install ccache](ccache_mac.md) to speed up the build. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 171 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 172 | ## Build Chromium |
| 173 | |
| 174 | Build Chromium (the "chrome" target) with Ninja using the command: |
| 175 | |
| 176 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 177 | $ autoninja -C out/Default chrome |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 178 | ``` |
| 179 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 180 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 181 | arguments passed to `ninja`.) |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 182 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 183 | You can get a list of all of the other build targets from GN by running `gn ls |
| 184 | out/Default` from the command line. To compile one, pass the GN label to Ninja |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 185 | with no preceding "//" (so, for `//chrome/test:unit_tests` use `autoninja -C |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 186 | out/Default chrome/test:unit_tests`). |
| 187 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 188 | ## Run Chromium |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 189 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 190 | Once it is built, you can simply run the browser: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 191 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 192 | ```shell |
Owen Min | 83eda110 | 2017-06-28 18:47:21 | [diff] [blame] | 193 | $ out/Default/Chromium.app/Contents/MacOS/Chromium |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 194 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 195 | |
Kai Ninomiya | c52b6bc | 2022-05-10 23:27:43 | [diff] [blame] | 196 | ## Avoiding system permissions dialogs after each build |
Dominic Mazzoni | a7494a5 | 2020-08-06 19:19:11 | [diff] [blame] | 197 | |
Kai Ninomiya | c52b6bc | 2022-05-10 23:27:43 | [diff] [blame] | 198 | Every time you start a new developer build, you may get two system dialogs: |
| 199 | `Chromium wants to use your confidential information stored in "Chromium Safe |
| 200 | Storage" in your keychain.`, and `Do you want the application "Chromium.app" to |
| 201 | accept incoming network connections?`. |
Dominic Mazzoni | a7494a5 | 2020-08-06 19:19:11 | [diff] [blame] | 202 | |
Kai Ninomiya | c52b6bc | 2022-05-10 23:27:43 | [diff] [blame] | 203 | To avoid them, you can run Chromium with these command-line flags (but of |
| 204 | course beware that they will change the behavior of certain subsystems): |
| 205 | |
| 206 | ```shell |
| 207 | --use-mock-keychain --disable-features=DialMediaRouteProvider |
| 208 | ``` |
Dominic Mazzoni | a7494a5 | 2020-08-06 19:19:11 | [diff] [blame] | 209 | |
wafuwafu13 | b6854ba5 | 2021-12-24 06:02:43 | [diff] [blame] | 210 | ## Build and run test targets |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 211 | |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 212 | Tests are split into multiple test targets based on their type and where they |
| 213 | exist in the directory structure. To see what target a given unit test or |
| 214 | browser test file corresponds to, the following command can be used: |
| 215 | |
| 216 | ```shell |
| 217 | $ gn refs out/Default --testonly=true --type=executable --all chrome/browser/ui/browser_list_unittest.cc |
| 218 | //chrome/test:unit_tests |
| 219 | ``` |
| 220 | |
| 221 | In the example above, the target is unit_tests. The unit_tests binary can be |
| 222 | built by running the following command: |
wafuwafu13 | b6854ba5 | 2021-12-24 06:02:43 | [diff] [blame] | 223 | |
| 224 | ```shell |
| 225 | $ autoninja -C out/Default unit_tests |
| 226 | ``` |
| 227 | |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 228 | You can run the tests by running the unit_tests binary. You can also limit which |
| 229 | tests are run using the `--gtest_filter` arg, e.g.: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 230 | |
Andrew Williams | fa9b7d6 | 2023-03-20 15:48:28 | [diff] [blame] | 231 | ```shell |
| 232 | $ out/Default/unit_tests --gtest_filter="BrowserListUnitTest.*" |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 233 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 234 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 235 | You can find out more about GoogleTest at its |
| 236 | [GitHub page](https://github.com/google/googletest). |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 237 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 238 | ## Debugging |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 239 | |
Robert Sesek | 3b731b1 | 2021-04-14 21:54:03 | [diff] [blame] | 240 | Good debugging tips can be found [here](mac/debugging.md). |
Vaclav Brozek | 539499e | 2018-07-18 11:19:51 | [diff] [blame] | 241 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 242 | ## Update your checkout |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 243 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 244 | To update an existing checkout, you can run |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 245 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 246 | ```shell |
| 247 | $ git rebase-update |
| 248 | $ gclient sync |
| 249 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 250 | |
| 251 | The first command updates the primary Chromium source repository and rebases |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 252 | any of your local branches on top of tip-of-tree (aka the Git branch |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 253 | `origin/main`). If you don't want to use this script, you can also just use |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 254 | `git pull` or other common Git commands to update the repo. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 255 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 256 | The second command syncs dependencies to the appropriate versions and re-runs |
| 257 | hooks as needed. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 258 | |
| 259 | ## Tips, tricks, and troubleshooting |
| 260 | |
| 261 | ### Using Xcode-Ninja Hybrid |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 262 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 263 | While using Xcode is unsupported, GN supports a hybrid approach of using Ninja |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 264 | for building, but Xcode for editing and driving compilation. Xcode is still |
| 265 | slow, but it runs fairly well even **with indexing enabled**. Most people |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 266 | build in the Terminal and write code with a text editor, though. |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 267 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 268 | With hybrid builds, compilation is still handled by Ninja, and can be run from |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 269 | the command line (e.g. `autoninja -C out/gn chrome`) or by choosing the `chrome` |
Sylvain Defresne | fc11bcd | 2020-06-26 13:42:00 | [diff] [blame] | 270 | target in the hybrid project and choosing Build. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 271 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 272 | To use Xcode-Ninja Hybrid pass `--ide=xcode` to `gn gen`: |
tfarina | 59fb57ac | 2016-03-02 18:17:24 | [diff] [blame] | 273 | |
| 274 | ```shell |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 275 | $ gn gen out/gn --ide=xcode |
tfarina | 59fb57ac | 2016-03-02 18:17:24 | [diff] [blame] | 276 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 277 | |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 278 | Open it: |
tfarina | 59fb57ac | 2016-03-02 18:17:24 | [diff] [blame] | 279 | |
| 280 | ```shell |
Sylvain Defresne | fc11bcd | 2020-06-26 13:42:00 | [diff] [blame] | 281 | $ open out/gn/all.xcodeproj |
tfarina | 59fb57ac | 2016-03-02 18:17:24 | [diff] [blame] | 282 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 283 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 284 | You may run into a problem where http://YES is opened as a new tab every time |
| 285 | you launch Chrome. To fix this, open the scheme editor for the Run scheme, |
| 286 | choose the Options tab, and uncheck "Allow debugging when using document |
| 287 | Versions Browser". When this option is checked, Xcode adds |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 288 | `--NSDocumentRevisionsDebugMode YES` to the launch arguments, and the `YES` |
| 289 | gets interpreted as a URL to open. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 290 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 291 | If you have problems building, join us in `#chromium` on `irc.freenode.net` and |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 292 | ask there. Be sure that the |
xiaoyin.l | 1003c0b | 2016-12-06 02:51:17 | [diff] [blame] | 293 | [waterfall](https://build.chromium.org/buildbot/waterfall/) is green and the |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 294 | tree is open before checking out. This will increase your chances of success. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 295 | |
Bruce Dawson | 425d4ab | 2023-06-25 01:36:15 | [diff] [blame] | 296 | ### Improving performance of git commands |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 297 | |
isherman | ce1d9d8 | 2017-05-12 23:10:04 | [diff] [blame] | 298 | #### Increase the vnode cache size |
| 299 | |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 300 | `git status` is used frequently to determine the status of your checkout. Due |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 301 | to the large number of files in Chromium's checkout, `git status` performance |
| 302 | can be quite variable. Increasing the system's vnode cache appears to help. By |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 303 | default, this command: |
| 304 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 305 | ```shell |
Steve Kobes | 11a670a | 2022-03-25 21:49:09 | [diff] [blame] | 306 | $ sysctl -a | egrep 'kern\..*vnodes' |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 307 | ``` |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 308 | |
| 309 | Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this |
| 310 | setting: |
| 311 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 312 | ```shell |
| 313 | $ sudo sysctl kern.maxvnodes=$((512*1024)) |
| 314 | ``` |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 315 | |
| 316 | Higher values may be appropriate if you routinely move between different |
Steve Kobes | 11a670a | 2022-03-25 21:49:09 | [diff] [blame] | 317 | Chromium checkouts. This setting will reset on reboot. To apply it at startup: |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 318 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 319 | ```shell |
Steve Kobes | 11a670a | 2022-03-25 21:49:09 | [diff] [blame] | 320 | $ sudo tee /Library/LaunchDaemons/kern.maxvnodes.plist > /dev/null <<EOF |
| 321 | <?xml version="1.0" encoding="UTF-8"?> |
| 322 | <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> |
| 323 | <plist version="1.0"> |
| 324 | <dict> |
| 325 | <key>Label</key> |
| 326 | <string>kern.maxvnodes</string> |
| 327 | <key>ProgramArguments</key> |
| 328 | <array> |
| 329 | <string>sysctl</string> |
| 330 | <string>kern.maxvnodes=524288</string> |
| 331 | </array> |
| 332 | <key>RunAtLoad</key> |
| 333 | <true/> |
| 334 | </dict> |
| 335 | </plist> |
| 336 | EOF |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 337 | ``` |
shess | 1f4c3d9 | 2015-11-05 18:15:37 | [diff] [blame] | 338 | |
| 339 | Or edit the file directly. |
| 340 | |
isherman | ce1d9d8 | 2017-05-12 23:10:04 | [diff] [blame] | 341 | #### Configure git to use an untracked cache |
| 342 | |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 343 | Try running |
isherman | ce1d9d8 | 2017-05-12 23:10:04 | [diff] [blame] | 344 | |
| 345 | ```shell |
| 346 | $ git update-index --test-untracked-cache |
| 347 | ``` |
| 348 | |
| 349 | If the output ends with `OK`, then the following may also improve performance of |
| 350 | `git status`: |
| 351 | |
| 352 | ```shell |
| 353 | $ git config core.untrackedCache true |
| 354 | ``` |
| 355 | |
Avi Drissman | c0f6793ac | 2023-05-26 19:22:44 | [diff] [blame] | 356 | #### Configure git to use fsmonitor |
| 357 | |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 358 | You can significantly speed up git by using [fsmonitor.](https://github.blog/2022-06-29-improve-git-monorepo-performance-with-a-file-system-monitor/) |
| 359 | You should enable fsmonitor in large repos, such as Chromium and v8. Enabling |
Avi Drissman | 9908ae44 | 2023-09-29 16:31:11 | [diff] [blame] | 360 | it globally will launch many processes and probably isn't worthwhile. Be sure |
| 361 | you have at least version 2.43 (fsmonitor on the Mac is broken before then). The |
Bruce Dawson | 2154274a | 2023-06-17 22:24:29 | [diff] [blame] | 362 | command to enable fsmonitor in the current repo is: |
Avi Drissman | c0f6793ac | 2023-05-26 19:22:44 | [diff] [blame] | 363 | |
| 364 | ```shell |
| 365 | $ git config core.fsmonitor true |
| 366 | ``` |
| 367 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 368 | ### Xcode license agreement |
tnagel | cad63169 | 2016-04-15 11:02:36 | [diff] [blame] | 369 | |
| 370 | If you're getting the error |
| 371 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 372 | > Agreeing to the Xcode/iOS license requires admin privileges, please re-run as |
| 373 | > root via sudo. |
tnagel | cad63169 | 2016-04-15 11:02:36 | [diff] [blame] | 374 | |
| 375 | the Xcode license hasn't been accepted yet which (contrary to the message) any |
| 376 | user can do by running: |
| 377 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 378 | ```shell |
| 379 | $ xcodebuild -license |
| 380 | ``` |
tnagel | cad63169 | 2016-04-15 11:02:36 | [diff] [blame] | 381 | |
| 382 | Only accepting for all users of the machine requires root: |
| 383 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 384 | ```shell |
| 385 | $ sudo xcodebuild -license |
| 386 | ``` |
David Sanders | aa3fdeb70 | 2022-05-26 14:42:18 | [diff] [blame] | 387 | |
| 388 | ### Exclude checkout from Spotlight indexing |
| 389 | |
| 390 | Chromium's checkout contains a lot of files, and building generates many more. |
| 391 | Spotlight will try to index all of those files, and uses a lot of CPU time |
| 392 | doing so, especially during a build, which can slow things down. |
| 393 | |
| 394 | To prevent the Chromium checkout from being indexed by Spotlight, open System |
| 395 | Preferences, go to "Spotlight" -> "Privacy" and add your Chromium checkout |
| 396 | directory to the list of excluded locations. |