blob: 0396294fa7e99d651ac8b455d34593533994ffa6 [file] [log] [blame] [view]
dpranke1a70d0c2016-12-01 02:42:291# Checking out and building Chromium for Mac
andybons3322f762015-08-24 21:37:092
erikchen7d7509a2017-10-02 23:40:363There are instructions for other platforms linked from the
dpranke1a70d0c2016-12-01 02:42:294[get the code](get_the_code.md) page.
5
dpranke1a70d0c2016-12-01 02:42:296## Instructions for Google Employees
7
8Are you a Google employee? See
9[go/building-chrome](https://goto.google.com/building-chrome) instead.
dpranke0ae7cad2016-11-30 07:47:5810
andybonsad92aa32015-08-31 02:27:4411[TOC]
andybons3322f762015-08-24 21:37:0912
dpranke0ae7cad2016-11-30 07:47:5813## System requirements
sdya8197bd22016-09-14 19:06:4214
Avi Drissman1a520bf2020-12-08 19:00:4715* 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
sdy93387fa2016-12-01 01:03:4420
erikchen7d7509a2017-10-02 23:40:3621 ```shell
sdy93387fa2016-12-01 01:03:4422 $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
dominicca4e4c992016-05-23 22:08:0323 ```
erikchen7d7509a2017-10-02 23:40:3624
Avi Drissman1a520bf2020-12-08 19:00:4725 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.
andybons3322f762015-08-24 21:37:0929
dpranke0ae7cad2016-11-30 07:47:5830## Install `depot_tools`
andybons3322f762015-08-24 21:37:0931
sdy93387fa2016-12-01 01:03:4432Clone the `depot_tools` repository:
andybons3322f762015-08-24 21:37:0933
sdy93387fa2016-12-01 01:03:4434```shell
35$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
36```
andybons3322f762015-08-24 21:37:0937
Gabriel Charetteb6780c12019-04-24 16:23:5238Add `depot_tools` to the end of your PATH (you will probably want to put this in
39your `~/.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
41not be able to find infra tools):
dpranke0ae7cad2016-11-30 07:47:5842
sdy93387fa2016-12-01 01:03:4443```shell
44$ export PATH="$PATH:/path/to/depot_tools"
45```
dpranke0ae7cad2016-11-30 07:47:5846
47## Get the code
48
Aaron Gable94b7e2a32018-01-03 19:14:4149Ensure that unicode filenames aren't mangled by HFS:
50
51```shell
52$ git config --global core.precomposeUnicode true
53```
54
sdy93387fa2016-12-01 01:03:4455Create a `chromium` directory for the checkout and change to it (you can call
56this whatever you like and put it wherever you like, as long as the full path
57has no spaces):
dpranke0ae7cad2016-11-30 07:47:5858
sdy93387fa2016-12-01 01:03:4459```shell
60$ mkdir chromium && cd chromium
61```
62
63Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:5864dependencies.
65
sdy93387fa2016-12-01 01:03:4466```shell
67$ fetch chromium
68```
dpranke0ae7cad2016-11-30 07:47:5869
[email protected]1436b952018-10-26 16:35:1370If you don't need the full repo history, you can save time by using
Yannic Bonenbergera68557002019-04-29 14:13:1971`fetch --no-history chromium`. You can call `git fetch --unshallow` to retrieve
72the full history later.
dpranke0ae7cad2016-11-30 07:47:5873
sdy93387fa2016-12-01 01:03:4474Expect the command to take 30 minutes on even a fast connection, and many
75hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:5876
sdy93387fa2016-12-01 01:03:4477When `fetch` completes, it will have created a hidden `.gclient` file and a
78directory called `src` in the working directory. The remaining instructions
79assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:5880
sdy93387fa2016-12-01 01:03:4481```shell
82$ cd src
83```
84
85*Optional*: You can also [install API
86keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
87build to talk to some Google services, but this is not necessary for most
88development and testing purposes.
andybons3322f762015-08-24 21:37:0989
dpranke1a70d0c2016-12-01 02:42:2990## Setting up the build
andybons3322f762015-08-24 21:37:0991
Tom Bridgwatereef401542018-08-17 00:54:4392Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
93a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
94to generate `.ninja` files. You can create any number of *build directories*
95with different configurations. To create a build directory:
andybonsad92aa32015-08-31 02:27:4496
sdy93387fa2016-12-01 01:03:4497```shell
98$ gn gen out/Default
99```
thakisf28551b2016-08-09 14:42:55100
sdy93387fa2016-12-01 01:03:44101* 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).
dpranke0ae7cad2016-11-30 07:47:58107 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 Roman01446752019-09-03 23:45:08110 [quick start guide](https://gn.googlesource.com/gn/+/master/docs/quick_start.md).
Reilly Grantf057adf2020-11-03 17:42:37111* Building Chromium for arm Macs requires [additional setup](mac_arm64.md).
thakisf28551b2016-08-09 14:42:55112
thakisf28551b2016-08-09 14:42:55113
dpranke0ae7cad2016-11-30 07:47:58114### Faster builds
andybons3322f762015-08-24 21:37:09115
andybonsad92aa32015-08-31 02:27:44116Full rebuilds are about the same speed in Debug and Release, but linking is a
117lot faster in Release builds.
andybons3322f762015-08-24 21:37:09118
thakisf28551b2016-08-09 14:42:55119Put
andybons3322f762015-08-24 21:37:09120
sdy93387fa2016-12-01 01:03:44121```
122is_debug = false
123```
andybons3322f762015-08-24 21:37:09124
sdy93387fa2016-12-01 01:03:44125in your `args.gn` to do a release build.
thakisf28551b2016-08-09 14:42:55126
127Put
128
sdy93387fa2016-12-01 01:03:44129```
130is_component_build = true
131```
thakisf28551b2016-08-09 14:42:55132
sdy93387fa2016-12-01 01:03:44133in your `args.gn` to build many small dylibs instead of a single large
134executable. This makes incremental builds much faster, at the cost of producing
135a binary that opens less quickly. Component builds work in both debug and
136release.
thakisf28551b2016-08-09 14:42:55137
138Put