blob: 89684d84236868f9a0b08955024af34b7b57a787 [file] [log] [blame] [view]
Scott Grahamf94d84d2017-06-26 18:24:401# Checking out and building on Fuchsia
2
3***Note that the Fuchsia port is in the early stages, and things are likely to
Fabrice de Gans-Riberi4468e912019-08-23 23:43:544frequently be broken. Try #cr-fuchsia on Freenode or Slack if something seems
5awry.***
Scott Grahamf94d84d2017-06-26 18:24:406
Scott Graham6b17c6522018-09-25 20:39:367There are instructions for other platforms linked from the
Scott Grahamf94d84d2017-06-26 18:24:408[get the code](get_the_code.md) page.
9
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
20basis.
Scott Grahamf94d84d2017-06-26 18:24:4021
22## Install `depot_tools`
23
24Clone the `depot_tools` repository:
25
26```shell
27$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
28```
29
30Add `depot_tools` to the end of your PATH (you will probably want to put this
31in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
32`/path/to/depot_tools`:
33
34```shell
35$ export PATH="$PATH:/path/to/depot_tools"
36```
37
38## Get the code
39
40Create a `chromium` directory for the checkout and change to it (you can call
41this whatever you like and put it wherever you like, as long as the full path
42has no spaces):
43
44```shell
45$ mkdir ~/chromium && cd ~/chromium
46```
47
48Run the `fetch` tool from depot_tools to check out the code and its
49dependencies.
50
51```shell
52$ fetch --nohooks chromium
53```
54
Scott Grahamf94d84d2017-06-26 18:24:4055Expect the command to take 30 minutes on even a fast connection, and many
56hours on slower ones.
57
58If you've already installed the build dependencies on the machine (from another
59checkout, for example), you can omit the `--nohooks` flag and `fetch`
60will automatically execute `gclient runhooks` at the end.
61
62When `fetch` completes, it will have created a hidden `.gclient` file and a
Adam MacBethc6fc88b52017-06-30 17:26:3163directory called `src` in the working directory.
Scott Grahamf94d84d2017-06-26 18:24:4064
65### Configure for building on Fuchsia
66
67Edit `.gclient` to include (this is a list, so it could also include `android`,
68etc. if necessary.)
69
70```
71target_os = ['fuchsia']
72```
73
Scott Graham9ffcea62017-06-30 21:31:3774Note that this should be added as a top-level statement in the `.gclient` file,
Sharon Yang66f3cee2019-03-19 21:16:5275not an entry inside the `solutions` dict. An example `.gclient` file would look
76as follows:
77
78```
79solutions = [
80 {
81 "url": "https://chromium.googlesource.com/chromium/src.git",
82 "managed": False,
83 "name": "src",
84 "custom_deps": {},
85 "custom_vars": {}
86 }
87]
88target_os = ['fuchsia']
89```
Scott Graham9ffcea62017-06-30 21:31:3790
Scott Graham6b17c6522018-09-25 20:39:3691You will then need to run:
92
93```shell
94$ gclient runhooks
95```
96
97This makes sure the Fuchsia SDK is available in third\_party and keeps it up to
98date.
Scott Grahamf94d84d2017-06-26 18:24:4099
Adam MacBethc6fc88b52017-06-30 17:26:31100The remaining instructions assume you have switched to the `src` directory:
101
102```shell
103$ cd src
104```
Scott Grahamf94d84d2017-06-26 18:24:40105
Wezc03808e2018-11-06 06:27:35106### (Linux-only) Install any required host packages
107
108Chromium relies on some platform packages to be present in order to build.
109You can install the current set of required packages with:
110
111```shell
112$ build/install-build-deps.sh
113```
114
115Note that you need to do this only once, and thereafter only if new dependencies
116are added - these will be announced to the chromium-dev@ group.
117
Scott Graham6b17c6522018-09-25 20:39:36118### Update your checkout
119
120To update an existing checkout, you can run
121
122```shell
123$ git rebase-update
124$ gclient sync
125```
126
127The first command updates the primary Chromium source repository and rebases
128any of your local branches on top of tip-of-tree (aka the Git branch
129`origin/master`). If you don't want to use this script, you can also just use
130`git pull` or other common Git commands to update the repo.
131
132The second command syncs dependencies to the appropriate versions and re-runs
133hooks as needed. `gclient sync` updates dependencies to the versions specified
134in `DEPS`, so any time that file is modified (pulling, changing branches, etc.)
135`gclient sync` should be run.
136
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21137## (Mac-only) Download additional required Clang binaries
138
139Go to [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
140and download the most recent build. Extract `bin/llvm-ar` to the clang folder
141in Chromium:
142
143```shell
144$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
145```
146
Scott Grahamf94d84d2017-06-26 18:24:40147## Setting up the build
148
Tom Bridgwatereef401542018-08-17 00:54:43149Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
150a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
151to generate `.ninja` files. You can create any number of *build directories*
152with different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40153
154```shell
Adam MacBethddd50f32017-07-10 01:42:26155$ 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:40156```
157
Wez2102c3be2017-07-12 01:09:26158You can also build for Debug, with `is_debug=true`, but since we don't currently
159have any Debug build-bots, it may be more broken than Release.
160
Scott Grahamb69a2f62017-06-26 19:32:20161`use_goma=true` is fine to use also if you're a Googler.
162
Scott Grahamf94d84d2017-06-26 18:24:40163## Build
164
Scott Graham4c9dc312018-11-07 19:52:41165All targets included in the GN build should build successfully. You can also
166build a specific binary, for example, base\_unittests:
Scott Grahamf94d84d2017-06-26 18:24:40167
168```shell
Max Morozf5b31fcd2018-08-10 21:55:48169$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40170```
171
Dirk Pranke8bd55f22018-10-24 21:22:10172(`autoninja` is a wrapper that automatically provides optimal values for the
173arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48174
Scott Grahamf94d84d2017-06-26 18:24:40175## Run
176
Wezc03808e2018-11-06 06:27:35177Once you've built a package, you'll want to run it!
178
179### (Recommended)(Linux-only) Enable KVM acceleration
180
181Under Linux, if your host and target CPU architectures are the same (e.g. you're
182building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's
183support for the KVM hypervisor:
184
1851. Install the KVM module for your kernel, to get a /dev/kvm device.
1862. Ensure that your system has a "kvm" group, and it owns /dev/kvm.
187You can do that by installing the QEMU system common package:
188```shell
189$ sudo apt-get install qemu-system-common
190```
1913. Add users to the "kvm" group, and have them login again, to pick-up the new
192group.
193
Fabrice de Gans-Ribericfa0fb7d82019-07-02 18:23:09194### Running test suites
195
196Building test suites generate a launcher script to run them on a QEMU instance
197or a physical device. These scripts are generated at `out/fuchsia/bin`. For
198instance,to run the `base_unittests` target, launch:
Scott Grahamf94d84d2017-06-26 18:24:40199
200```shell
Wez2102c3be2017-07-12 01:09:26201$ out/fuchsia/bin/run_base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40202```
203
Scott Grahamf94d84d2017-06-26 18:24:40204Common gtest arguments such as `--gtest_filter=...` are supported by the run
Fabrice de Gans-Ribericfa0fb7d82019-07-02 18:23:09205script. The launcher script also symbolizes backtraces.
Fabrice de Gans-Riberi4468e912019-08-23 23:43:54206
207To run a test suite on an *unprovisioned device* in a zedboot state, simply add
208`-d` to the test runner script arguments. Subsequent runs of the test runner
209script will be able to pick up the same device.
210
211To run a test suite on a device that is *already provisioned*, add the following
212arguments to the test runner script:
213
214* `-d` to run the test suite on a device.
215* `--fuchsia-out-dir=[/path/to/fuchsia/out/directory]` or
216 `--ssh-config=[/path/to/ssh_config]` to specify the SSH configuration used for
217 connecting to the target device.
218* (Optional) `--host=[IP]` to specify the test device IP. Typically, this is the
219value obtained from the command `fx netaddr --fuchsia`.
220* (Optional) `--port=[port]` to specify the SSH port, if different from 22.
221
222### Troubleshooting a test
223
224To troubleshoot a specific test, consider a combination of the following
225arguments to the test runner script:
226
227* `--gtest_filter="[TestSuite.TestName]"` to only run a specific test, or a
228 comma-separated list to run a set of tests. Wildcards can also be used to run
229 a set of tests or an entire test suite, e.g. `--gtest_filter="[TestSuite.*]"`.
230* `--test-launcher-jobs=1` to only have one batch of tests running at a time.
231 This bypasses the test launcher buffering of test log output, making it
232 possible to access the log output from successful test runs.
233* `--single-process-tests` to run all the tests in the same process. Unlike the
234 above option, this will run the tests directly in the test launcher process,
235 making it easier to attach a debugger.
236* `system-log-file=[/path/to/syslog]` to specify the file to write system logs
237 to. Or `system-log-file=-` to write the system logs to stdout. By default,
238 Chromium logs are written to the system log on Fuchsia. This argument is known
239 to cause `IOError` python exceptions with a QEMU target.
240* `--gtest_repeat=[number] --gtest_break_on_failure` to run a test or test suite
241 a certain number of times until it fails. This is useful to investigate flaky
242 tests.