blob: b23138d1a7f5345e3bf760e1e3b2f6339fa11fc3 [file] [log] [blame] [view]
dpranke1a70d0c2016-12-01 02:42:291# Checking out and building Chromium for iOS
2
3There are instructions for other platforms linked from the
4[get the code](get_the_code.md) page.
tfarinab8f70682016-03-01 08:41:315
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.
tfarinab8f70682016-03-01 08:41:3110
dpranke0ae7cad2016-11-30 07:47:5811[TOC]
tfarinab8f70682016-03-01 08:41:3112
dpranke0ae7cad2016-11-30 07:47:5813## System requirements
tfarinab8f70682016-03-01 08:41:3114
dpranke0ae7cad2016-11-30 07:47:5815* A 64-bit Mac running 10.11+.
16* [Xcode](https://developer.apple.com/xcode) 8.0+.
sdy93387fa2016-12-01 01:03:4417* The OS X 10.10 SDK. Run
18
19 ```shell
20 $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
21 ```
dpranke0ae7cad2016-11-30 07:47:5822
23 to check whether you have it. Building with the 10.11 SDK works too, but
24 the releases currently use the 10.10 SDK.
sdy93387fa2016-12-01 01:03:4425* The current version of the JDK (required for the Closure compiler).
tfarinab8f70682016-03-01 08:41:3126
dpranke0ae7cad2016-11-30 07:47:5827## Install `depot_tools`
tfarinab8f70682016-03-01 08:41:3128
sdy93387fa2016-12-01 01:03:4429Clone the `depot_tools` repository:
tfarinab8f70682016-03-01 08:41:3130
sdy93387fa2016-12-01 01:03:4431```shell
32$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
33```
sdefresne7f4c25f2016-09-19 09:56:0534
sdy93387fa2016-12-01 01:03:4435Add `depot_tools` to the end of your PATH (you will probably want to put this
36in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
37`/path/to/depot_tools`:
sdefresne7f4c25f2016-09-19 09:56:0538
sdy93387fa2016-12-01 01:03:4439```shell
40$ export PATH="$PATH:/path/to/depot_tools"
41```
sdefresne7f4c25f2016-09-19 09:56:0542
dpranke0ae7cad2016-11-30 07:47:5843## Get the code
tfarinab8f70682016-03-01 08:41:3144
sdy93387fa2016-12-01 01:03:4445Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:5846this whatever you like and put it wherever you like, as
47long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:5848
sdy93387fa2016-12-01 01:03:4449```shell
50$ mkdir chromium && cd chromium
51```
52
53Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:5854dependencies.
55
sdy93387fa2016-12-01 01:03:4456```shell
57$ fetch ios
58```
dpranke0ae7cad2016-11-30 07:47:5859
60If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:4461adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:5862
sdy93387fa2016-12-01 01:03:4463Expect the command to take 30 minutes on even a fast connection, and many
64hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:5865
sdy93387fa2016-12-01 01:03:4466When `fetch` completes, it will have created a hidden `.gclient` file and a
67directory called `src` in the working directory. The remaining instructions
68assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:5869
sdy93387fa2016-12-01 01:03:4470```shell
71$ cd src
72```
73
74*Optional*: You can also [install API
75keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
76build to talk to some Google services, but this is not necessary for most
77development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:5878
79## Setting up the build
80
sdy93387fa2016-12-01 01:03:4481Since the iOS build is a bit more complicated than a desktop build, we provide
82`ios/build/tools/setup-gn.py`, which will create four appropriately configured
83build directories under `out` for Release and Debug device and simulator
84builds, and generates an appropriate Xcode workspace as well.
dpranke0ae7cad2016-11-30 07:47:5885
86This script is run automatically by fetch (as part of `gclient runhooks`).
tfarinab8f70682016-03-01 08:41:3187
sdy93387fa2016-12-01 01:03:4488You can customize the build by editing the file `$HOME/.setup-gn` (create it if
89it does not exist). Look at `src/ios/build/tools/setup-gn.config` for
sdefresne7f4c25f2016-09-19 09:56:0590available configuration options.
tfarinab8f70682016-03-01 08:41:3191
sdy93387fa2016-12-01 01:03:4492From this point, you can either build from Xcode or from the command line using
93`ninja`. `setup-gn.py` creates sub-directories named
94`out/${configuration}-${platform}`, so for a `Debug` build for simulator use:
sdefresne7f4c25f2016-09-19 09:56:0595
96```shell
sdy93387fa2016-12-01 01:03:4497$ ninja -C out/Debug-iphonesimulator gn_all
sdefresne7f4c25f2016-09-19 09:56:0598```
99
100Note: you need to run `setup-gn.py` script every time one of the `BUILD.gn`
101file is updated (either by you or after rebasing). If you forget to run it,
102the list of targets and files in the Xcode solution may be stale.
103
dpranke0ae7cad2016-11-30 07:47:58104You can also follow the manual instructions on the
sdy93387fa2016-12-01 01:03:44105[Mac page](mac_build_instructions.md), but make sure you set the
dpranke0ae7cad2016-11-30 07:47:58106GN arg `target_os="ios"`.
tfarinab8f70682016-03-01 08:41:31107
rohitrao80f35ea72016-12-21 20:59:31108## Running apps from the commandline
tfarinab8f70682016-03-01 08:41:31109
sdefresnebf9b6e832016-03-02 10:41:20110Any target that is built and runs on the bots (see [below](#Troubleshooting))
rohitrao80f35ea72016-12-21 20:59:31111should run successfully in a local build. To run in the simulator from the
112command line, you can use `iossim`. For example, to run a debug build of
113`Chromium`:
tfarinab8f70682016-03-01 08:41:31114
sdefresnebf9b6e832016-03-02 10:41:20115```shell
rohitrao80f35ea72016-12-21 20:59:31116$ out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/Chromium.app
sdefresnebf9b6e832016-03-02 10:41:20117```
tfarinab8f70682016-03-01 08:41:31118
dpranke0ae7cad2016-11-30 07:47:58119## Update your checkout
tfarinab8f70682016-03-01 08:41:31120
dpranke0ae7cad2016-11-30 07:47:58121To update an existing checkout, you can run
sdefresne7f4c25f2016-09-19 09:56:05122
sdy93387fa2016-12-01 01:03:44123```shell
124$ git rebase-update
125$ gclient sync
126```
dpranke0ae7cad2016-11-30 07:47:58127
128The first command updates the primary Chromium source repository and rebases
sdy93387fa2016-12-01 01:03:44129any of your local branches on top of tip-of-tree (aka the Git branch
130`origin/master`). If you don't want to use this script, you can also just use
131`git pull` or other common Git commands to update the repo.
dpranke0ae7cad2016-11-30 07:47:58132
sdy93387fa2016-12-01 01:03:44133The second command syncs dependencies to the appropriate versions and re-runs
134hooks as needed.
dpranke0ae7cad2016-11-30 07:47:58135
136## Tips, tricks, and troubleshooting
137
dpranke0ae7cad2016-11-30 07:47:58138If you have problems building, join us in `#chromium` on `irc.freenode.net` and
139ask there. As mentioned above, be sure that the
xiaoyin.l1003c0b2016-12-06 02:51:17140[waterfall](https://build.chromium.org/buildbot/waterfall/) is green and the tree
dpranke0ae7cad2016-11-30 07:47:58141is open before checking out. This will increase your chances of success.
142
143### Improving performance of `git status`
144
145`git status` is used frequently to determine the status of your checkout. Due
sdy93387fa2016-12-01 01:03:44146to the large number of files in Chromium's checkout, `git status` performance
147can be quite variable. Increasing the system's vnode cache appears to help.
148By default, this command:
dpranke0ae7cad2016-11-30 07:47:58149
sdy93387fa2016-12-01 01:03:44150```shell
151$ sysctl -a | egrep kern\..*vnodes
152```
dpranke0ae7cad2016-11-30 07:47:58153
154Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this
155setting:
156
sdy93387fa2016-12-01 01:03:44157```shell
158$ sudo sysctl kern.maxvnodes=$((512*1024))
159```
dpranke0ae7cad2016-11-30 07:47:58160
161Higher values may be appropriate if you routinely move between different
162Chromium checkouts. This setting will reset on reboot, the startup setting can
163be set in `/etc/sysctl.conf`:
164
sdy93387fa2016-12-01 01:03:44165```shell
166$ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf
167```
dpranke0ae7cad2016-11-30 07:47:58168
169Or edit the file directly.
170
sdy93387fa2016-12-01 01:03:44171If `git --version` reports 2.6 or higher, the following may also improve
dpranke0ae7cad2016-11-30 07:47:58172performance of `git status`:
173
sdy93387fa2016-12-01 01:03:44174```shell
175$ git update-index --untracked-cache
176```
dpranke0ae7cad2016-11-30 07:47:58177
178### Xcode license agreement
179
180If you're getting the error
181
sdy93387fa2016-12-01 01:03:44182> Agreeing to the Xcode/iOS license requires admin privileges, please re-run as
183> root via sudo.
dpranke0ae7cad2016-11-30 07:47:58184
185the Xcode license hasn't been accepted yet which (contrary to the message) any
186user can do by running:
187
sdy93387fa2016-12-01 01:03:44188```shell
189$ xcodebuild -license
190```
dpranke0ae7cad2016-11-30 07:47:58191
192Only accepting for all users of the machine requires root:
193
sdy93387fa2016-12-01 01:03:44194```shell
195$ sudo xcodebuild -license
196```