Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 1 | # Checking out and building on Fuchsia |
| 2 | |
David Dorwin | fe186dd | 2022-05-20 18:35:13 | [diff] [blame] | 3 | ***If you have followed the instructions below and are still having trouble, |
| 4 | see [Contact information](README.md#contact-information).*** |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 5 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 6 | There are instructions for other platforms linked from the |
David Dorwin | f3fad4e | 2021-09-17 19:40:36 | [diff] [blame] | 7 | [get the code](../get_the_code.md) page. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 8 | |
Fabrice de Gans-Riberi | 4468e91 | 2019-08-23 23:43:54 | [diff] [blame] | 9 | [TOC] |
| 10 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 11 | ## System requirements |
| 12 | |
| 13 | * A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly |
| 14 | recommended. |
| 15 | * At least 100GB of free disk space. |
| 16 | * You must have Git and Python installed already. |
| 17 | |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 18 | Most development is done on Ubuntu. Mac build is supported on a best-effort |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 19 | basis. If you already have a Chromium checkout, continue to the |
| 20 | [next section](#instructions-for-current-chromium-developers). Otherwise, skip |
| 21 | to the [following section](#instructions-for-new-chromium-developers). If you |
| 22 | are a Fuchsia developer, see also |
| 23 | [Working with the Fuchsia tree](#working-with-the-fuchsia-tree). |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 24 | |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 25 | ## Instructions for current Chromium developers |
| 26 | |
| 27 | This section applies to you if you already have a Chromium checkout. You will |
| 28 | need to update it to install Fuchsia-specific dependencies. |
| 29 | |
| 30 | 1. Edit your `.gclient` to add `fuchsia` to the `target_os` list. The file |
| 31 | should look similar to this: |
| 32 | |
| 33 | ``` |
| 34 | solutions = [ |
| 35 | { |
| 36 | "url": "https://chromium.googlesource.com/chromium/src.git", |
| 37 | "managed": False, |
| 38 | "name": "src", |
| 39 | "custom_deps": {}, |
| 40 | "custom_vars": {} |
| 41 | } |
| 42 | ] |
| 43 | target_os = ['fuchsia'] |
| 44 | ``` |
| 45 | |
| 46 | 2. Run `gclient sync` |
| 47 | 3. Create a build directory: |
| 48 | |
| 49 | ```shell |
| 50 | $ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\"" |
| 51 | ``` |
| 52 | |
| 53 | You can add many of the usual GN arguments like `use_goma = true`. In |
| 54 | particular, when working with devices, consider using `is_debug = false` and |
| 55 | `is_component_build = false` since debug and component builds can drastically |
| 56 | increase run time and used space. |
| 57 | |
| 58 | Build the target as you would for any other platform: |
| 59 | ```shell |
| 60 | $ autoninja out/fuchsia <target_name> |
| 61 | ``` |
| 62 | |
| 63 | To run the tests in an emulator, see the [Run](#run) section. |
| 64 | |
| 65 | ## Instructions for new Chromium developers |
| 66 | |
| 67 | ### Install `depot_tools` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 68 | |
| 69 | Clone the `depot_tools` repository: |
| 70 | |
| 71 | ```shell |
| 72 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 73 | ``` |
| 74 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 75 | Add `depot_tools` to the end of your PATH (you will probably want to put this in |
| 76 | your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 77 | `/path/to/depot_tools`: |
| 78 | |
| 79 | ```shell |
| 80 | $ export PATH="$PATH:/path/to/depot_tools" |
| 81 | ``` |
| 82 | |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 83 | ### Get the code |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 84 | |
| 85 | Create a `chromium` directory for the checkout and change to it (you can call |
| 86 | this whatever you like and put it wherever you like, as long as the full path |
| 87 | has no spaces): |
| 88 | |
| 89 | ```shell |
| 90 | $ mkdir ~/chromium && cd ~/chromium |
| 91 | ``` |
| 92 | |
| 93 | Run the `fetch` tool from depot_tools to check out the code and its |
Kevin Marshall | c0ad265 | 2022-01-21 19:31:46 | [diff] [blame] | 94 | dependencies. Depending on your needs, you can check out Chromium along with |
| 95 | all of its previous revisions, or you can just check out the latest trunk. |
| 96 | Omitting the history is much faster to download and requires much less disk |
| 97 | space. If you are checking out on a slow or metered Internet connection, |
| 98 | you should consider omitting history. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 99 | |
Kevin Marshall | c0ad265 | 2022-01-21 19:31:46 | [diff] [blame] | 100 | * **No Git version history - faster** |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 101 | ```shell |
Kevin Marshall | c0ad265 | 2022-01-21 19:31:46 | [diff] [blame] | 102 | $ fetch --nohooks --no-history chromium |
| 103 | ``` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 104 | |
Kevin Marshall | c0ad265 | 2022-01-21 19:31:46 | [diff] [blame] | 105 | * **With Git version history - slower (up to 30m on fast connection)** |
| 106 | ```shell |
| 107 | $ fetch --nohooks chromium |
| 108 | ``` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 109 | |
| 110 | If you've already installed the build dependencies on the machine (from another |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 111 | checkout, for example), you can omit the `--nohooks` flag and `fetch` will |
| 112 | automatically execute `gclient runhooks` at the end. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 113 | |
| 114 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 115 | directory called `src` in the working directory. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 116 | |
| 117 | ### Configure for building on Fuchsia |
| 118 | |
| 119 | Edit `.gclient` to include (this is a list, so it could also include `android`, |
| 120 | etc. if necessary.) |
| 121 | |
| 122 | ``` |
| 123 | target_os = ['fuchsia'] |
| 124 | ``` |
| 125 | |
Scott Graham | 9ffcea6 | 2017-06-30 21:31:37 | [diff] [blame] | 126 | Note that this should be added as a top-level statement in the `.gclient` file, |
Sharon Yang | 66f3cee | 2019-03-19 21:16:52 | [diff] [blame] | 127 | not an entry inside the `solutions` dict. An example `.gclient` file would look |
| 128 | as follows: |
| 129 | |
| 130 | ``` |
| 131 | solutions = [ |
| 132 | { |
| 133 | "url": "https://chromium.googlesource.com/chromium/src.git", |
| 134 | "managed": False, |
| 135 | "name": "src", |
| 136 | "custom_deps": {}, |
| 137 | "custom_vars": {} |
| 138 | } |
| 139 | ] |
| 140 | target_os = ['fuchsia'] |
| 141 | ``` |
Scott Graham | 9ffcea6 | 2017-06-30 21:31:37 | [diff] [blame] | 142 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 143 | The Fuchsia boot images (also called "SDK companion images") to check out are |
| 144 | specified by the `checkout_fuchsia_boot_images` variable. For instance, adding |
| 145 | `"checkout_fuchsia_boot_images": "qemu.x64,workstation.qemu-x64-release",` to |
| 146 | the `custom_vars` section of your `.gclient` file would allow you to check out |
| 147 | both images. The set of available images is listed in the |
| 148 | [DEPS file](https://source.chromium.org/chromium/chromium/src/+/main:DEPS). |
Chong Gu | 96fe8db | 2021-09-29 21:28:00 | [diff] [blame] | 149 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 150 | Note: fxbug.dev/85552 tracks migration away from the legacy image names, like |
| 151 | `qemu.x64`, which is mapped to `terminal.qemu-x64-release` by the |
| 152 | [`update_images.py`](https://source.chromium.org/chromium/chromium/src/+/main:build/fuchsia/update_images.py) |
| 153 | helper script. |
Chong Gu | 96fe8db | 2021-09-29 21:28:00 | [diff] [blame] | 154 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 155 | You will then need to run: |
| 156 | |
| 157 | ```shell |
Kevin Marshall | 173a180 | 2020-06-09 18:03:32 | [diff] [blame] | 158 | $ gclient sync |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 159 | ``` |
| 160 | |
| 161 | This makes sure the Fuchsia SDK is available in third\_party and keeps it up to |
| 162 | date. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 163 | |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 164 | The remaining instructions assume you have switched to the `src` directory: |
| 165 | |
| 166 | ```shell |
| 167 | $ cd src |
| 168 | ``` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 169 | |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 170 | ### (Linux-only) Install any required host packages |
| 171 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 172 | Chromium relies on some platform packages to be present in order to build. You |
| 173 | can install the current set of required packages with: |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 174 | |
| 175 | ```shell |
| 176 | $ build/install-build-deps.sh |
| 177 | ``` |
| 178 | |
| 179 | Note that you need to do this only once, and thereafter only if new dependencies |
| 180 | are added - these will be announced to the chromium-dev@ group. |
| 181 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 182 | ### Update your checkout |
| 183 | |
| 184 | To update an existing checkout, you can run |
| 185 | |
| 186 | ```shell |
| 187 | $ git rebase-update |
| 188 | $ gclient sync |
| 189 | ``` |
| 190 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 191 | The first command updates the primary Chromium source repository and rebases any |
| 192 | of your local branches on top of tip-of-tree (aka the Git branch `origin/main`). |
| 193 | If you don't want to use this script, you can also just use `git pull` or other |
| 194 | common Git commands to update the repo. |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 195 | |
| 196 | The second command syncs dependencies to the appropriate versions and re-runs |
| 197 | hooks as needed. `gclient sync` updates dependencies to the versions specified |
| 198 | in `DEPS`, so any time that file is modified (pulling, changing branches, etc.) |
| 199 | `gclient sync` should be run. |
| 200 | |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 201 | ### (Mac-only) Download additional required Clang binaries |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 202 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 203 | Go to |
| 204 | [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/) |
| 205 | and download the most recent build. Extract `bin/llvm-ar` to the clang folder in |
| 206 | Chromium: |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 207 | |
| 208 | ```shell |
| 209 | $ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts |
| 210 | ``` |
| 211 | |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 212 | ### Setting up the build |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 213 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 214 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 215 | a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) to |
| 216 | generate `.ninja` files. You can create any number of *build directories* with |
| 217 | different configurations. To create a build directory, run: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 218 | |
| 219 | ```shell |
Adam MacBeth | ddd50f3 | 2017-07-10 01:42:26 | [diff] [blame] | 220 | $ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\"" |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 221 | ``` |
| 222 | |
Wez | 2102c3be | 2017-07-12 01:09:26 | [diff] [blame] | 223 | You can also build for Debug, with `is_debug=true`, but since we don't currently |
| 224 | have any Debug build-bots, it may be more broken than Release. |
| 225 | |
Scott Graham | b69a2f6 | 2017-06-26 19:32:20 | [diff] [blame] | 226 | `use_goma=true` is fine to use also if you're a Googler. |
| 227 | |
Sharon Yang | f6e51ee | 2020-09-25 14:59:51 | [diff] [blame] | 228 | Architecture options are x64 (default) and arm64. This can be set with |
Aidan Wolter | 53cde64 | 2020-10-29 16:02:26 | [diff] [blame] | 229 | `target_cpu=\"arm64\"`. |
Sharon Yang | f6e51ee | 2020-09-25 14:59:51 | [diff] [blame] | 230 | |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 231 | ### Build |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 232 | |
Scott Graham | 4c9dc31 | 2018-11-07 19:52:41 | [diff] [blame] | 233 | All targets included in the GN build should build successfully. You can also |
| 234 | build a specific binary, for example, base\_unittests: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 235 | |
| 236 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 237 | $ autoninja -C out/fuchsia base_unittests |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 238 | ``` |
| 239 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 240 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 241 | arguments passed to `ninja`.) |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 242 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 243 | ## Run |
| 244 | |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 245 | Once you've built a package, you'll want to run it! |
| 246 | |
| 247 | ### (Recommended)(Linux-only) Enable KVM acceleration |
| 248 | |
| 249 | Under Linux, if your host and target CPU architectures are the same (e.g. you're |
| 250 | building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's |
| 251 | support for the KVM hypervisor: |
| 252 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 253 | 1. Install the KVM module for your kernel, to get a /dev/kvm device. |
| 254 | 2. Ensure that your system has a "kvm" group, and it owns /dev/kvm. You can do |
| 255 | that by installing the QEMU system common package: `shell $ sudo apt-get |
| 256 | install qemu-system-common` |
| 257 | 3. Add users to the "kvm" group, and have them login again, to pick-up the new |
| 258 | group. `shell $ sudo adduser <user> kvm $ exit [log in again]` |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 259 | |
Fabrice de Gans-Riberi | cfa0fb7d8 | 2019-07-02 18:23:09 | [diff] [blame] | 260 | ### Running test suites |
| 261 | |
Chong Gu | 4749ec1 | 2021-02-17 01:41:06 | [diff] [blame] | 262 | There are three types of tests available to run on Fuchsia: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 263 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 264 | 1. [Gtests](gtests.md) |
| 265 | 2. [GPU integration tests](gpu_testing.md) |
| 266 | 3. [Blink tests](web_tests.md) |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 267 | |
Chong Gu | 4749ec1 | 2021-02-17 01:41:06 | [diff] [blame] | 268 | Check the documentations to learn more about how to run these tests. |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 269 | |
| 270 | ### Working with the Fuchsia tree |
| 271 | |
| 272 | If you have a Fuchsia checkout and build, there are GN arguments in Chromium |
| 273 | that make working with both Fuchsia and Chromium checkouts easier. |
| 274 | |
| 275 | * `default_fuchsia_build_dir_for_installation`. Point this to an output |
| 276 | directory in Fuchsia. For instance. `/path/to/src/fuchsia/out/qemu-x64`. This |
Chong Gu | bb94e0f | 2021-12-09 18:16:49 | [diff] [blame] | 277 | will automatically add the `--fuchsia-out-dir` flag to wrapper scripts. |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 278 | * `default_fuchsia_device_node_name`. Set this to a Fuchsia device node name. |
Chong Gu | bb94e0f | 2021-12-09 18:16:49 | [diff] [blame] | 279 | This will automatically add the `--node-name` flag to most wrapper scripts. |
| 280 | * Finally, use the `-d` flag when running the <test_target_name> wrappers to |
| 281 | execute them on an already running device or emulator, rather than starting an |
| 282 | ephemeral emulator instance. This speeds up subsequent runs since the runner |
| 283 | script does not need to wait for the emulator instance to boot and only |
| 284 | differential changes are pushed to the device. |