blob: e2974fecf889934b467fd8941de04a1c5f4d7029 [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
95dependencies.
96
97```shell
98$ fetch --nohooks chromium
99```
100
Jaeheon Yi9eaf5b522021-10-01 23:17:56101Expect the command to take 30 minutes on even a fast connection, and many hours
102on slower ones.
Scott Grahamf94d84d2017-06-26 18:24:40103
104If you've already installed the build dependencies on the machine (from another
Jaeheon Yi9eaf5b522021-10-01 23:17:56105checkout, for example), you can omit the `--nohooks` flag and `fetch` will
106automatically execute `gclient runhooks` at the end.
Scott Grahamf94d84d2017-06-26 18:24:40107
108When `fetch` completes, it will have created a hidden `.gclient` file and a
Adam MacBethc6fc88b52017-06-30 17:26:31109directory called `src` in the working directory.
Scott Grahamf94d84d2017-06-26 18:24:40110
111### Configure for building on Fuchsia
112
113Edit `.gclient` to include (this is a list, so it could also include `android`,
114etc. if necessary.)
115
116```
117target_os = ['fuchsia']
118```
119
Scott Graham9ffcea62017-06-30 21:31:37120Note that this should be added as a top-level statement in the `.gclient` file,
Sharon Yang66f3cee2019-03-19 21:16:52121not an entry inside the `solutions` dict. An example `.gclient` file would look
122as follows:
123
124```
125solutions = [
126 {
127 "url": "https://chromium.googlesource.com/chromium/src.git",
128 "managed": False,
129 "name": "src",
130 "custom_deps": {},
131 "custom_vars": {}
132 }
133]
134target_os = ['fuchsia']
135```
Scott Graham9ffcea62017-06-30 21:31:37136
Jaeheon Yi9eaf5b522021-10-01 23:17:56137The Fuchsia boot images (also called "SDK companion images") to check out are
138specified by the `checkout_fuchsia_boot_images` variable. For instance, adding
139`"checkout_fuchsia_boot_images": "qemu.x64,workstation.qemu-x64-release",` to
140the `custom_vars` section of your `.gclient` file would allow you to check out
141both images. The set of available images is listed in the
142[DEPS file](https://source.chromium.org/chromium/chromium/src/+/main:DEPS).
Chong Gu96fe8db2021-09-29 21:28:00143
Jaeheon Yi9eaf5b522021-10-01 23:17:56144Note: fxbug.dev/85552 tracks migration away from the legacy image names, like
145`qemu.x64`, which is mapped to `terminal.qemu-x64-release` by the
146[`update_images.py`](https://source.chromium.org/chromium/chromium/src/+/main:build/fuchsia/update_images.py)
147helper script.
Chong Gu96fe8db2021-09-29 21:28:00148
Scott Graham6b17c6522018-09-25 20:39:36149You will then need to run:
150
151```shell
Kevin Marshall173a1802020-06-09 18:03:32152$ gclient sync
Scott Graham6b17c6522018-09-25 20:39:36153```
154
155This makes sure the Fuchsia SDK is available in third\_party and keeps it up to
156date.
Scott Grahamf94d84d2017-06-26 18:24:40157
Adam MacBethc6fc88b52017-06-30 17:26:31158The remaining instructions assume you have switched to the `src` directory:
159
160```shell
161$ cd src
162```
Scott Grahamf94d84d2017-06-26 18:24:40163
Wezc03808e2018-11-06 06:27:35164### (Linux-only) Install any required host packages
165
Jaeheon Yi9eaf5b522021-10-01 23:17:56166Chromium relies on some platform packages to be present in order to build. You
167can install the current set of required packages with:
Wezc03808e2018-11-06 06:27:35168
169```shell
170$ build/install-build-deps.sh
171```
172
173Note that you need to do this only once, and thereafter only if new dependencies
174are added - these will be announced to the chromium-dev@ group.
175
Scott Graham6b17c6522018-09-25 20:39:36176### Update your checkout
177
178To update an existing checkout, you can run
179
180```shell
181$ git rebase-update
182$ gclient sync
183```
184
Jaeheon Yi9eaf5b522021-10-01 23:17:56185The first command updates the primary Chromium source repository and rebases any
186of your local branches on top of tip-of-tree (aka the Git branch `origin/main`).
187If you don't want to use this script, you can also just use `git pull` or other
188common Git commands to update the repo.
Scott Graham6b17c6522018-09-25 20:39:36189
190The second command syncs dependencies to the appropriate versions and re-runs
191hooks as needed. `gclient sync` updates dependencies to the versions specified
192in `DEPS`, so any time that file is modified (pulling, changing branches, etc.)
193`gclient sync` should be run.
194
Fabrice de Gansf941df7e2021-11-23 21:33:14195### (Mac-only) Download additional required Clang binaries
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21196
Jaeheon Yi9eaf5b522021-10-01 23:17:56197Go to
198[this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
199and download the most recent build. Extract `bin/llvm-ar` to the clang folder in
200Chromium:
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21201
202```shell
203$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
204```
205
Fabrice de Gansf941df7e2021-11-23 21:33:14206### Setting up the build
Scott Grahamf94d84d2017-06-26 18:24:40207
Tom Bridgwatereef401542018-08-17 00:54:43208Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Jaeheon Yi9eaf5b522021-10-01 23:17:56209a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) to
210generate `.ninja` files. You can create any number of *build directories* with
211different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40212
213```shell
Adam MacBethddd50f32017-07-10 01:42:26214$ 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:40215```
216
Wez2102c3be2017-07-12 01:09:26217You can also build for Debug, with `is_debug=true`, but since we don't currently
218have any Debug build-bots, it may be more broken than Release.
219
Scott Grahamb69a2f62017-06-26 19:32:20220`use_goma=true` is fine to use also if you're a Googler.
221
Sharon Yangf6e51ee2020-09-25 14:59:51222Architecture options are x64 (default) and arm64. This can be set with
Aidan Wolter53cde642020-10-29 16:02:26223`target_cpu=\"arm64\"`.
Sharon Yangf6e51ee2020-09-25 14:59:51224
Fabrice de Gansf941df7e2021-11-23 21:33:14225### Build
Scott Grahamf94d84d2017-06-26 18:24:40226
Scott Graham4c9dc312018-11-07 19:52:41227All targets included in the GN build should build successfully. You can also
228build a specific binary, for example, base\_unittests:
Scott Grahamf94d84d2017-06-26 18:24:40229
230```shell
Max Morozf5b31fcd2018-08-10 21:55:48231$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40232```
233
Dirk Pranke8bd55f22018-10-24 21:22:10234(`autoninja` is a wrapper that automatically provides optimal values for the
235arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48236
Scott Grahamf94d84d2017-06-26 18:24:40237## Run
238
Wezc03808e2018-11-06 06:27:35239Once you've built a package, you'll want to run it!
240
241### (Recommended)(Linux-only) Enable KVM acceleration
242
243Under Linux, if your host and target CPU architectures are the same (e.g. you're
244building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's
245support for the KVM hypervisor:
246
Jaeheon Yi9eaf5b522021-10-01 23:17:562471. Install the KVM module for your kernel, to get a /dev/kvm device.
2482. Ensure that your system has a "kvm" group, and it owns /dev/kvm. You can do
249 that by installing the QEMU system common package: `shell $ sudo apt-get
250 install qemu-system-common`
2513. Add users to the "kvm" group, and have them login again, to pick-up the new
252 group. `shell $ sudo adduser <user> kvm $ exit [log in again]`
Wezc03808e2018-11-06 06:27:35253
Fabrice de Gans-Ribericfa0fb7d82019-07-02 18:23:09254### Running test suites
255
Chong Gu4749ec12021-02-17 01:41:06256There are three types of tests available to run on Fuchsia:
Scott Grahamf94d84d2017-06-26 18:24:40257
Jaeheon Yi9eaf5b522021-10-01 23:17:562581. [Gtests](gtests.md)
2592. [GPU integration tests](gpu_testing.md)
2603. [Blink tests](web_tests.md)
Scott Grahamf94d84d2017-06-26 18:24:40261
Chong Gu4749ec12021-02-17 01:41:06262Check the documentations to learn more about how to run these tests.
Fabrice de Gansf941df7e2021-11-23 21:33:14263
264### Working with the Fuchsia tree
265
266If you have a Fuchsia checkout and build, there are GN arguments in Chromium
267that make working with both Fuchsia and Chromium checkouts easier.
268
269* `default_fuchsia_build_dir_for_installation`. Point this to an output
270 directory in Fuchsia. For instance. `/path/to/src/fuchsia/out/qemu-x64`. This
Chong Gubb94e0f2021-12-09 18:16:49271 will automatically add the `--fuchsia-out-dir` flag to wrapper scripts.
Fabrice de Gansf941df7e2021-11-23 21:33:14272* `default_fuchsia_device_node_name`. Set this to a Fuchsia device node name.
Chong Gubb94e0f2021-12-09 18:16:49273 This will automatically add the `--node-name` flag to most wrapper scripts.
274* Finally, use the `-d` flag when running the <test_target_name> wrappers to
275 execute them on an already running device or emulator, rather than starting an
276 ephemeral emulator instance. This speeds up subsequent runs since the runner
277 script does not need to wait for the emulator instance to boot and only
278 differential changes are pushed to the device.