blob: 4b823caaca664ae023f0cf92fbdb7a3e9273721d [file] [log] [blame] [view]
Scott Grahamf94d84d2017-06-26 18:24:401# Checking out and building on Fuchsia
2
David Dorwinfe186dd2022-05-20 18:35:133***If you have followed the instructions below and are still having trouble,
4see [Contact information](README.md#contact-information).***
Scott Grahamf94d84d2017-06-26 18:24:405
Scott Graham6b17c6522018-09-25 20:39:366There are instructions for other platforms linked from the
David Dorwinf3fad4e2021-09-17 19:40:367[get the code](../get_the_code.md) page.
Scott Grahamf94d84d2017-06-26 18:24:408
Fabrice de Gans-Riberi4468e912019-08-23 23:43:549[TOC]
10
Scott Grahamf94d84d2017-06-26 18:24:4011## 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-Riberibbc67a1b2018-08-30 13:19:2118Most development is done on Ubuntu. Mac build is supported on a best-effort
Fabrice de Gansf941df7e2021-11-23 21:33:1419basis. If you already have a Chromium checkout, continue to the
20[next section](#instructions-for-current-chromium-developers). Otherwise, skip
21to the [following section](#instructions-for-new-chromium-developers). If you
22are a Fuchsia developer, see also
23[Working with the Fuchsia tree](#working-with-the-fuchsia-tree).
Scott Grahamf94d84d2017-06-26 18:24:4024
Fabrice de Gansf941df7e2021-11-23 21:33:1425## Instructions for current Chromium developers
26
27This section applies to you if you already have a Chromium checkout. You will
28need to update it to install Fuchsia-specific dependencies.
29
301. 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
462. Run `gclient sync`
473. 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
58Build the target as you would for any other platform:
59```shell
60$ autoninja out/fuchsia <target_name>
61```
62
63To run the tests in an emulator, see the [Run](#run) section.
64
65## Instructions for new Chromium developers
66
67### Install `depot_tools`
Scott Grahamf94d84d2017-06-26 18:24:4068
69Clone the `depot_tools` repository:
70
71```shell
72$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
73```
74
Jaeheon Yi9eaf5b522021-10-01 23:17:5675Add `depot_tools` to the end of your PATH (you will probably want to put this in
76your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
Scott Grahamf94d84d2017-06-26 18:24:4077`/path/to/depot_tools`:
78
79```shell
80$ export PATH="$PATH:/path/to/depot_tools"
81```
82
Fabrice de Gansf941df7e2021-11-23 21:33:1483### Get the code
Scott Grahamf94d84d2017-06-26 18:24:4084
85Create a `chromium` directory for the checkout and change to it (you can call
86this whatever you like and put it wherever you like, as long as the full path
87has no spaces):
88
89```shell
90$ mkdir ~/chromium && cd ~/chromium
91```
92
93Run the `fetch` tool from depot_tools to check out the code and its
Kevin Marshallc0ad2652022-01-21 19:31:4694dependencies. Depending on your needs, you can check out Chromium along with
95all of its previous revisions, or you can just check out the latest trunk.
96Omitting the history is much faster to download and requires much less disk
97space. If you are checking out on a slow or metered Internet connection,
98you should consider omitting history.
Scott Grahamf94d84d2017-06-26 18:24:4099
Kevin Marshallc0ad2652022-01-21 19:31:46100* **No Git version history - faster**
Scott Grahamf94d84d2017-06-26 18:24:40101```shell
Kevin Marshallc0ad2652022-01-21 19:31:46102 $ fetch --nohooks --no-history chromium
103 ```
Scott Grahamf94d84d2017-06-26 18:24:40104
Kevin Marshallc0ad2652022-01-21 19:31:46105* **With Git version history - slower (up to 30m on fast connection)**
106 ```shell
107 $ fetch --nohooks chromium
108 ```
Scott Grahamf94d84d2017-06-26 18:24:40109
110If you've already installed the build dependencies on the machine (from another
Jaeheon Yi9eaf5b522021-10-01 23:17:56111checkout, for example), you can omit the `--nohooks` flag and `fetch` will
112automatically execute `gclient runhooks` at the end.
Scott Grahamf94d84d2017-06-26 18:24:40113
114When `fetch` completes, it will have created a hidden `.gclient` file and a
Adam MacBethc6fc88b52017-06-30 17:26:31115directory called `src` in the working directory.
Scott Grahamf94d84d2017-06-26 18:24:40116
117### Configure for building on Fuchsia
118
119Edit `.gclient` to include (this is a list, so it could also include `android`,
120etc. if necessary.)
121
122```
123target_os = ['fuchsia']
124```
125
Scott Graham9ffcea62017-06-30 21:31:37126Note that this should be added as a top-level statement in the `.gclient` file,
Sharon Yang66f3cee2019-03-19 21:16:52127not an entry inside the `solutions` dict. An example `.gclient` file would look
128as follows:
129
130```
131solutions = [
132 {
133 "url": "https://chromium.googlesource.com/chromium/src.git",
134 "managed": False,
135 "name": "src",
136 "custom_deps": {},
137 "custom_vars": {}
138 }
139]
140target_os = ['fuchsia']
141```
Scott Graham9ffcea62017-06-30 21:31:37142
Jaeheon Yi9eaf5b522021-10-01 23:17:56143The Fuchsia boot images (also called "SDK companion images") to check out are
144specified by the `checkout_fuchsia_boot_images` variable. For instance, adding
145`"checkout_fuchsia_boot_images": "qemu.x64,workstation.qemu-x64-release",` to
146the `custom_vars` section of your `.gclient` file would allow you to check out
147both images. The set of available images is listed in the
148[DEPS file](https://source.chromium.org/chromium/chromium/src/+/main:DEPS).
Chong Gu96fe8db2021-09-29 21:28:00149
Jaeheon Yi9eaf5b522021-10-01 23:17:56150Note: 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)
153helper script.
Chong Gu96fe8db2021-09-29 21:28:00154
Scott Graham6b17c6522018-09-25 20:39:36155You will then need to run:
156
157```shell
Kevin Marshall173a1802020-06-09 18:03:32158$ gclient sync
Scott Graham6b17c6522018-09-25 20:39:36159```
160
161This makes sure the Fuchsia SDK is available in third\_party and keeps it up to
162date.
Scott Grahamf94d84d2017-06-26 18:24:40163
Adam MacBethc6fc88b52017-06-30 17:26:31164The remaining instructions assume you have switched to the `src` directory:
165
166```shell
167$ cd src
168```
Scott Grahamf94d84d2017-06-26 18:24:40169
Wezc03808e2018-11-06 06:27:35170### (Linux-only) Install any required host packages
171
Jaeheon Yi9eaf5b522021-10-01 23:17:56172Chromium relies on some platform packages to be present in order to build. You
173can install the current set of required packages with:
Wezc03808e2018-11-06 06:27:35174
175```shell
176$ build/install-build-deps.sh
177```
178
179Note that you need to do this only once, and thereafter only if new dependencies
180are added - these will be announced to the chromium-dev@ group.
181
Scott Graham6b17c6522018-09-25 20:39:36182### Update your checkout
183
184To update an existing checkout, you can run
185
186```shell
187$ git rebase-update
188$ gclient sync
189```
190
Jaeheon Yi9eaf5b522021-10-01 23:17:56191The first command updates the primary Chromium source repository and rebases any
192of your local branches on top of tip-of-tree (aka the Git branch `origin/main`).
193If you don't want to use this script, you can also just use `git pull` or other
194common Git commands to update the repo.
Scott Graham6b17c6522018-09-25 20:39:36195
196The second command syncs dependencies to the appropriate versions and re-runs
197hooks as needed. `gclient sync` updates dependencies to the versions specified
198in `DEPS`, so any time that file is modified (pulling, changing branches, etc.)
199`gclient sync` should be run.
200
Fabrice de Gansf941df7e2021-11-23 21:33:14201### (Mac-only) Download additional required Clang binaries
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21202
Jaeheon Yi9eaf5b522021-10-01 23:17:56203Go to
204[this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
205and download the most recent build. Extract `bin/llvm-ar` to the clang folder in
206Chromium:
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21207
208```shell
209$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
210```
211
Fabrice de Gansf941df7e2021-11-23 21:33:14212### Setting up the build
Scott Grahamf94d84d2017-06-26 18:24:40213
Tom Bridgwatereef401542018-08-17 00:54:43214Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
Jaeheon Yi9eaf5b522021-10-01 23:17:56215a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) to
216generate `.ninja` files. You can create any number of *build directories* with
217different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40218
219```shell
Adam MacBethddd50f32017-07-10 01:42:26220$ 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:40221```
222
Wez2102c3be2017-07-12 01:09:26223You can also build for Debug, with `is_debug=true`, but since we don't currently
224have any Debug build-bots, it may be more broken than Release.
225
Scott Grahamb69a2f62017-06-26 19:32:20226`use_goma=true` is fine to use also if you're a Googler.
227
Sharon Yangf6e51ee2020-09-25 14:59:51228Architecture options are x64 (default) and arm64. This can be set with
Aidan Wolter53cde642020-10-29 16:02:26229`target_cpu=\"arm64\"`.
Sharon Yangf6e51ee2020-09-25 14:59:51230
Fabrice de Gansf941df7e2021-11-23 21:33:14231### Build
Scott Grahamf94d84d2017-06-26 18:24:40232
Scott Graham4c9dc312018-11-07 19:52:41233All targets included in the GN build should build successfully. You can also
234build a specific binary, for example, base\_unittests:
Scott Grahamf94d84d2017-06-26 18:24:40235
236```shell
Max Morozf5b31fcd2018-08-10 21:55:48237$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40238```
239
Dirk Pranke8bd55f22018-10-24 21:22:10240(`autoninja` is a wrapper that automatically provides optimal values for the
241arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48242
Scott Grahamf94d84d2017-06-26 18:24:40243## Run
244
Wezc03808e2018-11-06 06:27:35245Once you've built a package, you'll want to run it!
246
247### (Recommended)(Linux-only) Enable KVM acceleration
248
249Under Linux, if your host and target CPU architectures are the same (e.g. you're
250building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's
251support for the KVM hypervisor:
252
Jaeheon Yi9eaf5b522021-10-01 23:17:562531. Install the KVM module for your kernel, to get a /dev/kvm device.
2542. 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`
2573. 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]`
Wezc03808e2018-11-06 06:27:35259
Fabrice de Gans-Ribericfa0fb7d82019-07-02 18:23:09260### Running test suites
261
Chong Gu4749ec12021-02-17 01:41:06262There are three types of tests available to run on Fuchsia:
Scott Grahamf94d84d2017-06-26 18:24:40263
Jaeheon Yi9eaf5b522021-10-01 23:17:562641. [Gtests](gtests.md)
2652. [GPU integration tests](gpu_testing.md)
2663. [Blink tests](web_tests.md)
Scott Grahamf94d84d2017-06-26 18:24:40267
Chong Gu4749ec12021-02-17 01:41:06268Check the documentations to learn more about how to run these tests.
Fabrice de Gansf941df7e2021-11-23 21:33:14269
270### Working with the Fuchsia tree
271
272If you have a Fuchsia checkout and build, there are GN arguments in Chromium
273that 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 Gubb94e0f2021-12-09 18:16:49277 will automatically add the `--fuchsia-out-dir` flag to wrapper scripts.
Fabrice de Gansf941df7e2021-11-23 21:33:14278* `default_fuchsia_device_node_name`. Set this to a Fuchsia device node name.
Chong Gubb94e0f2021-12-09 18:16:49279 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.