dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 1 | # Checking out and building Chromium for iOS |
| 2 | |
| 3 | There are instructions for other platforms linked from the |
| 4 | [get the code](get_the_code.md) page. |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 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 | Google employee? See [go/building-chrome](https://goto.google.com/building-chrome) instead. |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 11 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 12 | [TOC] |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 13 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 14 | ## System requirements |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 15 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 16 | * A 64-bit Mac running 10.11+. |
| 17 | * [Xcode](https://developer.apple.com/xcode) 8.0+. |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 18 | * The OS X 10.10 SDK. Run |
| 19 | |
| 20 | ```shell |
| 21 | $ ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs |
| 22 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 23 | |
| 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. |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 26 | * The current version of the JDK (required for the Closure compiler). |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 27 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 28 | ## Install `depot_tools` |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 29 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 30 | Clone the `depot_tools` repository: |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 31 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 32 | ```shell |
| 33 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 34 | ``` |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 35 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 36 | Add `depot_tools` to the end of your PATH (you will probably want to put this |
| 37 | in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
| 38 | `/path/to/depot_tools`: |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 39 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 40 | ```shell |
| 41 | $ export PATH="$PATH:/path/to/depot_tools" |
| 42 | ``` |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 43 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 44 | ## Get the code |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 45 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 46 | Create a `chromium` directory for the checkout and change to it (you can call |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 47 | this whatever you like and put it wherever you like, as |
| 48 | long as the full path has no spaces): |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 49 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 50 | ```shell |
| 51 | $ mkdir chromium && cd chromium |
| 52 | ``` |
| 53 | |
| 54 | Run the `fetch` tool from `depot_tools` to check out the code and its |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 55 | dependencies. |
| 56 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 57 | ```shell |
| 58 | $ fetch ios |
| 59 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 60 | |
| 61 | If you don't want the full repo history, you can save a lot of time by |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 62 | adding the `--no-history` flag to `fetch`. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 63 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 64 | Expect the command to take 30 minutes on even a fast connection, and many |
| 65 | hours on slower ones. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 66 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 67 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 68 | directory called `src` in the working directory. The remaining instructions |
| 69 | assume you have switched to the `src` directory: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 70 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 71 | ```shell |
| 72 | $ cd src |
| 73 | ``` |
| 74 | |
| 75 | *Optional*: You can also [install API |
| 76 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 77 | build to talk to some Google services, but this is not necessary for most |
| 78 | development and testing purposes. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 79 | |
| 80 | ## Setting up the build |
| 81 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 82 | Since 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 |
| 84 | build directories under `out` for Release and Debug device and simulator |
| 85 | builds, and generates an appropriate Xcode workspace as well. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 86 | |
| 87 | This script is run automatically by fetch (as part of `gclient runhooks`). |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 88 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 89 | You can customize the build by editing the file `$HOME/.setup-gn` (create it if |
| 90 | it does not exist). Look at `src/ios/build/tools/setup-gn.config` for |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 91 | available configuration options. |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 92 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 93 | From 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: |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 96 | |
| 97 | ```shell |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 98 | $ ninja -C out/Debug-iphonesimulator gn_all |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 99 | ``` |
| 100 | |
| 101 | Note: you need to run `setup-gn.py` script every time one of the `BUILD.gn` |
| 102 | file is updated (either by you or after rebasing). If you forget to run it, |
| 103 | the list of targets and files in the Xcode solution may be stale. |
| 104 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 105 | You can also follow the manual instructions on the |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 106 | [Mac page](mac_build_instructions.md), but make sure you set the |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 107 | GN arg `target_os="ios"`. |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 108 | |
dpranke | 1a70d0c | 2016-12-01 02:42:29 | [diff] [blame] | 109 | ## Running `ios_web_shell` |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 110 | |
sdefresne | bf9b6e83 | 2016-03-02 10:41:20 | [diff] [blame] | 111 | Any target that is built and runs on the bots (see [below](#Troubleshooting)) |
| 112 | should run successfully in a local build. As of the time of writing, this is |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 113 | only the `ios_web_shell` and `ios_chrome_unittests` targets—see the note at the |
| 114 | top of this page. Check the bots periodically for updates; more targets (new |
| 115 | components) will come on line over time. |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 116 | |
| 117 | To run in the simulator from the command line, you can use `iossim`. For |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 118 | example, to run a debug build of `ios_web_shell`: |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 119 | |
sdefresne | bf9b6e83 | 2016-03-02 10:41:20 | [diff] [blame] | 120 | ```shell |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 121 | $ out/Debug-iphonesimulator/iossim out/Debug-iphonesimulator/ios_web_shell.app |
sdefresne | bf9b6e83 | 2016-03-02 10:41:20 | [diff] [blame] | 122 | ``` |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 123 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 124 | ## Update your checkout |
tfarina | b8f7068 | 2016-03-01 08:41:31 | [diff] [blame] | 125 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 126 | To update an existing checkout, you can run |
sdefresne | 7f4c25f | 2016-09-19 09:56:05 | [diff] [blame] | 127 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 128 | ```shell |
| 129 | $ git rebase-update |
| 130 | $ gclient sync |
| 131 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 132 | |
| 133 | The first command updates the primary Chromium source repository and rebases |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 134 | any 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. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 137 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 138 | The second command syncs dependencies to the appropriate versions and re-runs |
| 139 | hooks as needed. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 140 | |
| 141 | ## Tips, tricks, and troubleshooting |
| 142 | |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 143 | If you have problems building, join us in `#chromium` on `irc.freenode.net` and |
| 144 | ask there. As mentioned above, be sure that the |
xiaoyin.l | 1003c0b | 2016-12-06 02:51:17 | [diff] [blame^] | 145 | [waterfall](https://build.chromium.org/buildbot/waterfall/) is green and the tree |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 146 | is 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 |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 151 | to the large number of files in Chromium's checkout, `git status` performance |
| 152 | can be quite variable. Increasing the system's vnode cache appears to help. |
| 153 | By default, this command: |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 154 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 155 | ```shell |
| 156 | $ sysctl -a | egrep kern\..*vnodes |
| 157 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 158 | |
| 159 | Outputs `kern.maxvnodes: 263168` (263168 is 257 * 1024). To increase this |
| 160 | setting: |
| 161 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 162 | ```shell |
| 163 | $ sudo sysctl kern.maxvnodes=$((512*1024)) |
| 164 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 165 | |
| 166 | Higher values may be appropriate if you routinely move between different |
| 167 | Chromium checkouts. This setting will reset on reboot, the startup setting can |
| 168 | be set in `/etc/sysctl.conf`: |
| 169 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 170 | ```shell |
| 171 | $ echo kern.maxvnodes=$((512*1024)) | sudo tee -a /etc/sysctl.conf |
| 172 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 173 | |
| 174 | Or edit the file directly. |
| 175 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 176 | If `git --version` reports 2.6 or higher, the following may also improve |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 177 | performance of `git status`: |
| 178 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 179 | ```shell |
| 180 | $ git update-index --untracked-cache |
| 181 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 182 | |
| 183 | ### Xcode license agreement |
| 184 | |
| 185 | If you're getting the error |
| 186 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 187 | > Agreeing to the Xcode/iOS license requires admin privileges, please re-run as |
| 188 | > root via sudo. |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 189 | |
| 190 | the Xcode license hasn't been accepted yet which (contrary to the message) any |
| 191 | user can do by running: |
| 192 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 193 | ```shell |
| 194 | $ xcodebuild -license |
| 195 | ``` |
dpranke | 0ae7cad | 2016-11-30 07:47:58 | [diff] [blame] | 196 | |
| 197 | Only accepting for all users of the machine requires root: |
| 198 | |
sdy | 93387fa | 2016-12-01 01:03:44 | [diff] [blame] | 199 | ```shell |
| 200 | $ sudo xcodebuild -license |
| 201 | ``` |