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