blob: d557aad1ae82919d505396dd8637aee76ebbedef [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.
dpranke0ae7cad2016-11-30 07:47:5810Google employee? See [go/building-chrome](https://goto.google.com/building-chrome) instead.
tfarinab8f70682016-03-01 08:41:3111
dpranke0ae7cad2016-11-30 07:47:5812[TOC]
tfarinab8f70682016-03-01 08:41:3113
dpranke0ae7cad2016-11-30 07:47:5814## System requirements
tfarinab8f70682016-03-01 08:41:3115
dpranke0ae7cad2016-11-30 07:47:5816* A 64-bit Mac running 10.11+.
17* [Xcode](https://developer.apple.com/xcode) 8.0+.
sdy93387fa2016-12-01 01:03:4418* The OS X 10.10 SDK. Run
19
20 ```shell
21 $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
22 ```
dpranke0ae7cad2016-11-30 07:47:5823
24 to check whether you have it. Building with the 10.11 SDK works too, but
25 the releases currently use the 10.10 SDK.
sdy93387fa2016-12-01 01:03:4426* The current version of the JDK (required for the Closure compiler).
tfarinab8f70682016-03-01 08:41:3127
dpranke0ae7cad2016-11-30 07:47:5828## Install `depot_tools`
tfarinab8f70682016-03-01 08:41:3129
sdy93387fa2016-12-01 01:03:4430Clone the `depot_tools` repository:
tfarinab8f70682016-03-01 08:41:3131
sdy93387fa2016-12-01 01:03:4432```shell
33$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
34```
sdefresne7f4c25f2016-09-19 09:56:0535
sdy93387fa2016-12-01 01:03:4436Add `depot_tools` to the end of your PATH (you will probably want to put this
37in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
38`/path/to/depot_tools`:
sdefresne7f4c25f2016-09-19 09:56:0539
sdy93387fa2016-12-01 01:03:4440```shell
41$ export PATH="$PATH:/path/to/depot_tools"
42```
sdefresne7f4c25f2016-09-19 09:56:0543
dpranke0ae7cad2016-11-30 07:47:5844## Get the code
tfarinab8f70682016-03-01 08:41:3145
sdy93387fa2016-12-01 01:03:4446Create a `chromium` directory for the checkout and change to it (you can call
dpranke0ae7cad2016-11-30 07:47:5847this whatever you like and put it wherever you like, as
48long as the full path has no spaces):
dpranke0ae7cad2016-11-30 07:47:5849
sdy93387fa2016-12-01 01:03:4450```shell
51$ mkdir chromium && cd chromium
52```
53
54Run the `fetch` tool from `depot_tools` to check out the code and its
dpranke0ae7cad2016-11-30 07:47:5855dependencies.
56
sdy93387fa2016-12-01 01:03:4457```shell
58$ fetch ios
59```
dpranke0ae7cad2016-11-30 07:47:5860
61If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:4462adding the `--no-history` flag to `fetch`.
dpranke0ae7cad2016-11-30 07:47:5863
sdy93387fa2016-12-01 01:03:4464Expect the command to take 30 minutes on even a fast connection, and many
65hours on slower ones.
dpranke0ae7cad2016-11-30 07:47:5866
sdy93387fa2016-12-01 01:03:4467When `fetch` completes, it will have created a hidden `.gclient` file and a
68directory called `src` in the working directory. The remaining instructions
69assume you have switched to the `src` directory:
dpranke0ae7cad2016-11-30 07:47:5870
sdy93387fa2016-12-01 01:03:4471```shell
72$ cd src
73```
74
75*Optional*: You can also [install API
76keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
77build to talk to some Google services, but this is not necessary for most
78development and testing purposes.
dpranke0ae7cad2016-11-30 07:47:5879
80## Setting up the build
81
sdy93387fa2016-12-01 01:03:4482Since the iOS build is a bit more complicated than a desktop build, we provide
83`ios/build/tools/setup-gn.py`, which will create four appropriately configured
84build directories under `out` for Release and Debug device and simulator
85builds, and generates an appropriate Xcode workspace as well.
dpranke0ae7cad2016-11-30 07:47:5886
87This script is run automatically by fetch (as part of `gclient runhooks`).
tfarinab8f70682016-03-01 08:41:3188
sdy93387fa2016-12-01 01:03:4489You can customize the build by editing the file `$HOME/.setup-gn` (create it if
90it does not exist). Look at `src/ios/build/tools/setup-gn.config` for
sdefresne7f4c25f2016-09-19 09:56:0591available configuration options.
tfarinab8f70682016-03-01 08:41:3192
sdy93387fa2016-12-01 01:03:4493From this point, you can either build from Xcode or from the command line using
94`ninja`. `setup-gn.py` creates sub-directories named
95`out/${configuration}-${platform}`, so for a `Debug` build for simulator use:
sdefresne7f4c25f2016-09-19 09:56:0596
97```shell
sdy93387fa2016-12-01 01:03:4498$ ninja -C out/Debug-iphonesimulator gn_all
sdefresne7f4c25f2016-09-19 09:56:0599```
100
101Note: you need to run `setup-gn.py` script every time one of the `BUILD.gn`
102file is updated (either by you or after rebasing). If you forget to run it,
103the list of targets and files in the Xcode solution may be stale.
104
dpranke0ae7cad2016-11-30 07:47:58105You can also follow the manual instructions on the
sdy93387fa2016-12-01 01:03:44106[Mac page](mac_build_instructions.md), but make sure you set the
dpranke0ae7cad2016-11-30 07:47:58107GN arg `target_os="ios"`.
tfarinab8f70682016-03-01 08:41:31108
dpranke1a70d0c2016-12-01 02:42:29109## Running `ios_web_shell`
tfarinab8f70682016-03-01 08:41:31110
sdefresnebf9b6e832016-03-02 10:41:20111Any target that is built and runs on the bots (see [below](#Troubleshooting))
112should run successfully in a local build. As of the time of writing, this is
sdy93387fa2016-12-01 01:03:44113only the `ios_web_shell` and `ios_chrome_unittests` targets—see the note at the
114top of this page. Check the bots periodically for updates; more targets (new
115components) will come on line over time.
tfarinab8f70682016-03-01 08:41:31116
117To run in the simulator from the command line, you can use `iossim`. For
sdy93387fa2016-12-01 01:03:44118example, to run a debug build of `ios_web_shell`:
tfarinab8f70682016-03-01 08:41:31119
sdefresnebf9b6e832016-03-02 10:41:20120```shell
sdy93387fa2016-12-01 01:03:44121$ out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/ios_web_shell.app
sdefresnebf9b6e832016-03-02 10:41:20122```
tfarinab8f70682016-03-01 08:41:31123
dpranke0ae7cad2016-11-30 07:47:58124## Update your checkout
tfarinab8f70682016-03-01 08:41:31125
dpranke0ae7cad2016-11-30 07:47:58126To update an existing checkout, you can run
sdefresne7f4c25f2016-09-19 09:56:05127
sdy93387fa2016-12-01 01:03:44128```shell
129$ git rebase-update
130$ gclient sync
131```
dpranke0ae7cad2016-11-30 07:47:58132
133The first command updates the primary Chromium source repository and rebases
sdy93387fa2016-12-01 01:03:44134any of your local branches on top of tip-of-tree (aka the Git branch
135`origin/master`). If you don't want to use this script, you can also just use
136`git pull` or other common Git commands to update the repo.
dpranke0ae7cad2016-11-30 07:47:58137
sdy93387fa2016-12-01 01:03:44138The second command syncs dependencies to the appropriate versions and re-runs
139hooks as needed.
dpranke0ae7cad2016-11-30 07:47:58140
141## Tips, tricks, and troubleshooting
142
dpranke0ae7cad2016-11-30 07:47:58143If you have problems building, join us in `#chromium` on `irc.freenode.net` and
144ask there. As mentioned above, be sure that the
xiaoyin.l1003c0b2016-12-06 02:51:17145[waterfall](https://build.chromium.org/buildbot/waterfall/) is green and the tree
dpranke0ae7cad2016-11-30 07:47:58146is open before checking out. This will increase your chances of success.
147
148### Improving performance of `git status`
149
150`git status` is used frequently to determine the status of your checkout. Due
sdy93387fa2016-12-01 01:03:44151to the large number of files in Chromium's checkout, `git status` performance
152can be quite variable. Increasing the system's vnode cache appears to help.
153By default, this command:
dpranke0ae7cad2016-11-30 07:47:58154
sdy93387fa2016-12-01 01:03:44155```shell
156$ sysctl -a | egrep kern\..*vnodes
157```
dpranke0ae7cad2016-11-30 07:47:58158
159Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this
160setting:
161
sdy93387fa2016-12-01 01:03:44162```shell
163$ sudo sysctl kern.maxvnodes=$((512*1024))
164```
dpranke0ae7cad2016-11-30 07:47:58165
166Higher values may be appropriate if you routinely move between different
167Chromium checkouts. This setting will reset on reboot, the startup setting can
168be set in `/etc/sysctl.conf`:
169
sdy93387fa2016-12-01 01:03:44170```shell
171$ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf
172```
dpranke0ae7cad2016-11-30 07:47:58173
174Or edit the file directly.
175
sdy93387fa2016-12-01 01:03:44176If `git --version` reports 2.6 or higher, the following may also improve
dpranke0ae7cad2016-11-30 07:47:58177performance of `git status`:
178
sdy93387fa2016-12-01 01:03:44179```shell
180$ git update-index --untracked-cache
181```
dpranke0ae7cad2016-11-30 07:47:58182
183### Xcode license agreement
184
185If you're getting the error
186
sdy93387fa2016-12-01 01:03:44187> Agreeing to the Xcode/iOS license requires admin privileges, please re-run as
188> root via sudo.
dpranke0ae7cad2016-11-30 07:47:58189
190the Xcode license hasn't been accepted yet which (contrary to the message) any
191user can do by running:
192
sdy93387fa2016-12-01 01:03:44193```shell
194$ xcodebuild -license
195```
dpranke0ae7cad2016-11-30 07:47:58196
197Only accepting for all users of the machine requires root:
198
sdy93387fa2016-12-01 01:03:44199```shell
200$ sudo xcodebuild -license
201```