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 | |
Avi Drissman | 1a520bf | 2020-12-08 19:00:47 | [diff] [blame^] | 15 | * A 64-bit Intel Mac running 10.15.4+. (Building on Arm Macs is |
| 16 | [not yet supported](https://chromium.googlesource.com/chromium/src.git/+/master/docs/mac_arm64.md).) |
| 17 | * [Xcode](https://developer.apple.com/xcode/) 12.2+. This version of Xcode |
| 18 | comes with ... |
| 19 | * The macOS 11.0 SDK. Run |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 20 | |
erikchen | 7d7509a | 2017-10-02 23:40:36 | [diff] [blame] | 21 | ```shell |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 22 | $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs |
dominicc | a4e4c99 | 2016-05-23 22:08:03 | [diff] [blame] | 23 | ``` |
erikchen | 7d7509a | 2017-10-02 23:40:36 | [diff] [blame] | 24 | |
Avi Drissman | 1a520bf | 2020-12-08 19:00:47 | [diff] [blame^] | 25 | to check whether you have it. Building with a newer SDK usually works too |
| 26 | (please fix it if it doesn't), but the releases |
| 27 | [currently use Xcode 12.2](https://source.chromium.org/search?q=MAC_BINARIES_LABEL&ss=chromium) |
| 28 | and the macOS 11.0 SDK. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 29 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 30 | ## Install `depot_tools` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 31 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 32 | Clone the `depot_tools` repository: |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 33 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 34 | ```shell |
| 35 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 36 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 37 | |
Gabriel Charette | b6780c1 | 2019-04-24 16:23:52 | [diff] [blame] | 38 | Add `depot_tools` to the end of your PATH (you will probably want to put this in |
| 39 | your `~/.bash_profile` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
| 40 | `/path/to/depot_tools` (note: you **must** use the absolute path or Python will |
| 41 | not be able to find infra tools): |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 42 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 43 | ```shell |
| 44 | $ export PATH="$PATH:/path/to/depot_tools" |
| 45 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 46 | |
| 47 | ## Get the code |
| 48 | |
Aaron Gable | 94b7e2a3 | 2018-01-03 19:14:41 | [diff] [blame] | 49 | Ensure that unicode filenames aren't mangled by HFS: |
| 50 | |
| 51 | ```shell |
| 52 | $ git config --global core.precomposeUnicode true |
| 53 | ``` |
| 54 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 55 | Create a `chromium` directory for the checkout and change to it (you can call |
| 56 | this whatever you like and put it wherever you like, as long as the full path |
| 57 | has no spaces): |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 58 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 59 | ```shell |
| 60 | $ mkdir chromium && cd chromium |
| 61 | ``` |
| 62 | |
| 63 | Run the `fetch` tool from `depot_tools` to check out the code and its |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 64 | dependencies. |
| 65 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 66 | ```shell |
| 67 | $ fetch chromium |
| 68 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 69 | |
[email protected] | 1436b95 | 2018-10-26 16:35:13 | [diff] [blame] | 70 | 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] | 71 | `fetch --no-history chromium`. You can call `git fetch --unshallow` to retrieve |
| 72 | the full history later. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 73 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 74 | Expect the command to take 30 minutes on even a fast connection, and many |
| 75 | hours on slower ones. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 76 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 77 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 78 | directory called `src` in the working directory. The remaining instructions |
| 79 | assume you have switched to the `src` directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 80 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 81 | ```shell |
| 82 | $ cd src |
| 83 | ``` |
| 84 | |
| 85 | *Optional*: You can also [install API |
| 86 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 87 | build to talk to some Google services, but this is not necessary for most |
| 88 | development and testing purposes. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 89 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 90 | ## Setting up the build |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 91 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 92 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
| 93 | a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md) |
| 94 | to generate `.ninja` files. You can create any number of *build directories* |
| 95 | with different configurations. To create a build directory: |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 96 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 97 | ```shell |
| 98 | $ gn gen out/Default |
| 99 | ``` |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 100 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 101 | * You only have to run this once for each new build directory, Ninja will |
| 102 | update the build files as needed. |
| 103 | * You can replace `Default` with another name, but |
| 104 | it should be a subdirectory of `out`. |
| 105 | * For other build arguments, including release settings, see [GN build |
| 106 | configuration](https://www.chromium.org/developers/gn-build-configuration). |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 107 | The default will be a debug component build matching the current host |
| 108 | operating system and CPU. |
| 109 | * For more info on GN, run `gn help` on the command line or read the |
Eric Roman | 0144675 | 2019-09-03 23:45:08 | [diff] [blame] | 110 | [quick start guide](https://gn.googlesource.com/gn/+/master/docs/quick_start.md). |
Reilly Grant | f057adf | 2020-11-03 17:42:37 | [diff] [blame] | 111 | * Building Chromium for arm Macs requires [additional setup](mac_arm64.md). |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 112 | |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 113 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 114 | ### Faster builds |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 115 | |
andybons | ad92aa3 | 2015-08-31 02:27:44 | [diff] [blame] | 116 | Full rebuilds are about the same speed in Debug and Release, but linking is a |
| 117 | lot faster in Release builds. |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 118 | |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 119 | Put |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 120 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 121 | ``` |
| 122 | is_debug = false |
| 123 | ``` |
andybons | 3322f76 | 2015-08-24 21:37:09 | [diff] [blame] | 124 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 125 | in your `args.gn` to do a release build. |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 126 | |
| 127 | Put |
| 128 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 129 | ``` |
| 130 | is_component_build = true |
| 131 | ``` |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 132 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 133 | in your `args.gn` to build many small dylibs instead of a single large |
| 134 | executable. This makes incremental builds much faster, at the cost of producing |
| 135 | a binary that opens less quickly. Component builds work in both debug and |
| 136 | release. |
thakis | f28551b | 2016-08-09 14:42:55 | [diff] [blame] | 137 | |
| 138 | Put |
|
|