blob: 9444110b02161f7e577538d487416fc90e3066c2 [file] [log] [blame] [view]
Scott Grahamf94d84d2017-06-26 18:24:401# Checking out and building on Fuchsia
2
David Dorwinf3fad4e2021-09-17 19:40:363***If you have followed the instructions below and things still having trouble,
4try `#cr-fuchsia` on [Chromium Slack](https://www.chromium.org/developers/slack)
Fabrice de Gansf941df7e2021-11-23 21:33:145or [fuchsia-dev@chromium.org](mailto:fuchsia-dev@chromium.org).***
Scott Grahamf94d84d2017-06-26 18:24:406
Scott Graham6b17c6522018-09-25 20:39:367There are instructions for other platforms linked from the
David Dorwinf3fad4e2021-09-17 19:40:368[get the code](../get_the_code.md) page.
Scott Grahamf94d84d2017-06-26 18:24:409
Fabrice de Gans-Riberi4468e912019-08-23 23:43:5410[TOC]
11
Scott Grahamf94d84d2017-06-26 18:24:4012## System requirements
13
14* A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly
15 recommended.
16* At least 100GB of free disk space.
17* You must have Git and Python installed already.
18
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:2119Most development is done on Ubuntu. Mac build is supported on a best-effort
Fabrice de Gansf941df7e2021-11-23 21:33:1420basis. If you already have a Chromium checkout, continue to the
21[next section](#instructions-for-current-chromium-developers). Otherwise, skip
22to the [following section](#instructions-for-new-chromium-developers). If you
23are a Fuchsia developer, see also
24[Working with the Fuchsia tree](#working-with-the-fuchsia-tree).
Scott Grahamf94d84d2017-06-26 18:24:4025
Fabrice de Gansf941df7e2021-11-23 21:33:1426## Instructions for current Chromium developers
27
28This section applies to you if you already have a Chromium checkout. You will
29need to update it to install Fuchsia-specific dependencies.
30
311. Edit your `.gclient` to add `fuchsia` to the `target_os` list. The file
32 should look similar to this:
33
34 ```
35 solutions = [
36 {
37 "url": "https://chromium.googlesource.com/chromium/src.git",
38 "managed": False,
39 "name": "src",
40 "custom_deps": {},
41 "custom_vars": {}
42 }
43 ]
44 target_os = ['fuchsia']
45 ```
46
472. Run `gclient sync`
483. Create a build directory:
49
50 ```shell
51 $ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\""
52 ```
53
54 You can add many of the usual GN arguments like `use_goma = true`. In
55 particular, when working with devices, consider using `is_debug = false` and
56 `is_component_build = false` since debug and component builds can drastically
57 increase run time and used space.
58
59Build the target as you would for any other platform:
60```shell
61$ autoninja out/fuchsia <target_name>
62```
63
64To run the tests in an emulator, see the [Run](#run) section.
65
66## Instructions for new Chromium developers
67
68### Install `depot_tools`
Scott Grahamf94d84d2017-06-26 18:24:4069
70Clone the `depot_tools` repository:
71
72```shell
73$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
74```
75
Jaeheon Yi9eaf5b522021-10-01 23:17:5676Add `depot_tools` to the end of your PATH (you will probably want to put this in
77your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
Scott Grahamf94d84d2017-06-26 18:24:4078`/path/to/depot_tools`:
79
80```shell
81$ export PATH="$PATH:/path/to/depot_tools"
82```
83
Fabrice de Gansf941df7e2021-11-23 21:33:1484### Get the code
Scott Grahamf94d84d2017-06-26 18:24:4085
86Create a `chromium` directory for the checkout and change to it (you can call
87this whatever you like and put it wherever you like, as long as the full path
88has no spaces):
89
90```shell
91$ mkdir ~/chromium && cd ~/chromium
92```
93
94Run the `fetch` tool from depot_tools to check out the code and its
Kevin Marshallc0ad2652022-01-21 19:31:4695dependencies. Depending on your needs, you can check out Chromium along with
96all of its previous revisions, or you can just check out the latest trunk.
97Omitting the history is much faster to download and requires much less disk
98space. If you are checking out on a slow or metered Internet connection,
99you should consider omitting history.
Scott Grahamf94d84d2017-06-26 18:24:40100
Kevin Marshallc0ad2652022-01-21 19:31:46101* **No Git version history - faster**
Scott Grahamf94d84d2017-06-26 18:24:40102```shell
Kevin Marshallc0ad2652022-01-21 19:31:46103 $ fetch --nohooks --no-history chromium
104 ```
Scott Grahamf94d84d2017-06-26 18:24:40105
Kevin Marshallc0ad2652022-01-21 19:31:46106* **With Git version history - slower (up to 30m on fast connection)**
107 ```shell
108 $ fetch --nohooks chromium
109 ```
Scott Grahamf94d84d2017-06-26 18:24:40110
111If you've already installed the build dependencies on the machine (from another
Jaeheon Yi9eaf5b522021-10-01 23:17:56112checkout, for example), you can omit the `--nohooks` flag and `fetch` will
113automatically execute `gclient runhooks` at the end.
Scott Grahamf94d84d2017-06-26 18:24:40114
115When `fetch` completes, it will have created a hidden `.gclient` file and a
Adam MacBethc6fc88b52017-06-30 17:26:31116directory called `src` in the working directory.
Scott Grahamf94d84d2017-06-26 18:24:40117
118### Configure for building on Fuchsia
119
120Edit `.gclient` to include (this is a list, so it could also include `android`,
121etc. if necessary.)
122
123```
124target_os = ['fuchsia']
125```
126
Scott Graham9ffcea62017-06-30 21:31:37127Note that this should be added as a top-level statement in the `.gclient` file,
Sharon Yang66f3cee2019-03-19 21:16:52128not an entry inside the `solutions` dict. An example `.gclient` file would look
129as follows:
130
131```
132solutions = [
133 {
134 "url": "https://chromium.googlesource.com/chromium/src.git",
135 "managed": False,
136 "name": "src",
137 "custom_deps": {},
138 "custom_vars": {}
139 }
140]
141target_os = ['fuchsia']
142```
Scott Graham9ffcea62017-06-30 21:31:37143
Jaeheon Yi9eaf5b522021-10-01 23:17:56144The Fuchsia boot images (also called "SDK companion images") to check out are
145specified by the `checkout_fuchsia_boot_images` variable. For instance, adding
146`"checkout_fuchsia_boot_images": "qemu.x64,workstation.qemu-x64-release",` to
147the `custom_vars` section of your `.gclient` file would allow you to check out
148both images. The set of available images is listed in the
149[DEPS file](https://source.chromium.org/chromium/chromium/src/+/main:DEPS).
Chong Gu96fe8db2021-09-29 21:28:00150
Jaeheon Yi9eaf5b522021-10-01 23:17:56151Note: fxbug.dev/85552 tracks migration away from the legacy image names, like
152`qemu.x64`, which is mapped to `terminal.qemu-x64-release` by the
153[`update_images.py`](https://source.chromium.org/chromium/chromium/src/+/main:build/fuchsia/update_images.py)
154helper script.
Chong Gu96fe8db2021-09-29 21:28:00155
Scott Graham6b17c6522018-09-25 20:39:36156You will then need to run:
157
158```shell
Kevin Marshall173a1802020-06-09 18:03:32159$ gclient sync
Scott Graham6b17c6522018-09-25 20:39:36160```
161
162This makes sure the Fuchsia SDK is available in third\_party and keeps it up to
163date.
Scott Grahamf94d84d2017-06-26 18:24:40164
Adam MacBethc6fc88b52017-06-30 17:26:31165The remaining instructions assume you have switched to the `src` directory:
166
167```shell
168$ cd src
169```
Scott Grahamf94d84d2017-06-26 18:24:40170
Wezc03808e2018-11-06 06:27:35171### (Linux-only) Install any required host packages
172
Jaeheon Yi9eaf5b522021-10-01 23:17:56173Chromium relies on some platform packages to be present in order to build. You
174can install the current set of required packages with:
Wezc03808e2018-11-06 06:27:35175
176```shell
177$ build/install-build-deps.sh
178```
179
180Note that you need to do this only once, and thereafter only if new dependencies
181are added - these will be announced to the chromium-dev@ group.
182
Scott Graham6b17c6522018-09-25 20:39:36183### Update your checkout
184
185To update an existing checkout, you can run
186
187```shell
188$ git rebase-update
189$ gclient sync
190```
191
Jaeheon Yi9eaf5b522021-10-01 23:17:56192The first command updates the primary Chromium source repository and rebases any
193of your local branches on top of tip-of-tree (aka the Git branch `origin/main`).
194If you don't want to use this script, you can also just use `git pull` or other
195common Git commands to update the repo.
Scott Graham6b17c6522018-09-25 20:39:36196
197The second command syncs dependencies to the appropriate versions and re-runs
198hooks as needed. `gclient sync` updates dependencies to the versions specified
199in `DEPS`, so any time that file is modified (pulling, changing branches, etc.)
200`gclient sync` should be run.
201
Fabrice de Gansf941df7e2021-11-23 21:33:14202### (Mac-only) Download additional required Clang binaries
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21203
Jaeheon Yi9eaf5b522021-10-01 23:17:56204Go to
205[this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
206and download the most recent build. Extract `bin/llvm-ar` to the clang folder in
207Chromium:
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21208
209```shell
210$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
211```
212
Fabrice de Gansf941df7e2021-11-23 21:33:14213### Setting up the build
Scott Grahamf94d84d2017-06-26 18:24:40214
Tom Bridgwatereef401542018-08-17 00:54:43215Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Jaeheon Yi9eaf5b522021-10-01 23:17:56216a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) to
217generate `.ninja` files. You can create any number of *build directories* with
218different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40219
220```shell
Adam MacBethddd50f32017-07-10 01:42:26221$ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\""
Scott Grahamf94d84d2017-06-26 18:24:40222```
223
Wez2102c3be2017-07-12 01:09:26224You can also build for Debug, with `is_debug=true`, but since we don't currently
225have any Debug build-bots, it may be more broken than Release.
226
Scott Grahamb69a2f62017-06-26 19:32:20227`use_goma=true` is fine to use also if you're a Googler.
228
Sharon Yangf6e51ee2020-09-25 14:59:51229Architecture options are x64 (default) and arm64. This can be set with
Aidan Wolter53cde642020-10-29 16:02:26230`target_cpu=\"arm64\"`.
Sharon Yangf6e51ee2020-09-25 14:59:51231
Fabrice de Gansf941df7e2021-11-23 21:33:14232### Build
Scott Grahamf94d84d2017-06-26 18:24:40233
Scott Graham4c9dc312018-11-07 19:52:41234All targets included in the GN build should build successfully. You can also
235build a specific binary, for example, base\_unittests:
Scott Grahamf94d84d2017-06-26 18:24:40236
237```shell
Max Morozf5b31fcd2018-08-10 21:55:48238$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40239```
240
Dirk Pranke8bd55f22018-10-24 21:22:10241(`autoninja` is a wrapper that automatically provides optimal values for the
242arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48243
Scott Grahamf94d84d2017-06-26 18:24:40244## Run
245
Wezc03808e2018-11-06 06:27:35246Once you've built a package, you'll want to run it!
247
248### (Recommended)(Linux-only) Enable KVM acceleration
249
250Under Linux, if your host and target CPU architectures are the same (e.g. you're
251building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's
252support for the KVM hypervisor:
253
Jaeheon Yi9eaf5b522021-10-01 23:17:562541. Install the KVM module for your kernel, to get a /dev/kvm device.
2552. Ensure that your system has a "kvm" group, and it owns /dev/kvm. You can do
256 that by installing the QEMU system common package: `shell $ sudo apt-get
257 install qemu-system-common`
2583. Add users to the "kvm" group, and have them login again, to pick-up the new
259 group. `shell $ sudo adduser <user> kvm $ exit [log in again]`
Wezc03808e2018-11-06 06:27:35260
Fabrice de Gans-Ribericfa0fb7d82019-07-02 18:23:09261### Running test suites
262
Chong Gu4749ec12021-02-17 01:41:06263There are three types of tests available to run on Fuchsia:
Scott Grahamf94d84d2017-06-26 18:24:40264
Jaeheon Yi9eaf5b522021-10-01 23:17:562651. [Gtests](gtests.md)
2662. [GPU integration tests](gpu_testing.md)
2673. [Blink tests](web_tests.md)
Scott Grahamf94d84d2017-06-26 18:24:40268
Chong Gu4749ec12021-02-17 01:41:06269Check the documentations to learn more about how to run these tests.
Fabrice de Gansf941df7e2021-11-23 21:33:14270
271### Working with the Fuchsia tree
272
273If you have a Fuchsia checkout and build, there are GN arguments in Chromium
274that make working with both Fuchsia and Chromium checkouts easier.
275
276* `default_fuchsia_build_dir_for_installation`. Point this to an output
277 directory in Fuchsia. For instance. `/path/to/src/fuchsia/out/qemu-x64`. This
Chong Gubb94e0f2021-12-09 18:16:49278 will automatically add the `--fuchsia-out-dir` flag to wrapper scripts.
Fabrice de Gansf941df7e2021-11-23 21:33:14279* `default_fuchsia_device_node_name`. Set this to a Fuchsia device node name.
Chong Gubb94e0f2021-12-09 18:16:49280 This will automatically add the `--node-name` flag to most wrapper scripts.
281* Finally, use the `-d` flag when running the <test_target_name> wrappers to
282 execute them on an already running device or emulator, rather than starting an
283 ephemeral emulator instance. This speeds up subsequent runs since the runner
284 script does not need to wait for the emulator instance to boot and only
285 differential changes are pushed to the device.