blob: a137bc062e190c4f4bafd6fef8f42baeca4664c7 [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
4frequently be broken. Try #cr-fuchsia on Freenode if something seems awry.***
5
6There are instructions for other platforms linked from the
7[get the code](get_the_code.md) page.
8
9## System requirements
10
11* A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly
12 recommended.
13* At least 100GB of free disk space.
14* You must have Git and Python installed already.
15
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:2116Most development is done on Ubuntu. Mac build is supported on a best-effort
17basis.
Scott Grahamf94d84d2017-06-26 18:24:4018
19## Install `depot_tools`
20
21Clone the `depot_tools` repository:
22
23```shell
24$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
25```
26
27Add `depot_tools` to the end of your PATH (you will probably want to put this
28in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
29`/path/to/depot_tools`:
30
31```shell
32$ export PATH="$PATH:/path/to/depot_tools"
33```
34
35## Get the code
36
37Create a `chromium` directory for the checkout and change to it (you can call
38this whatever you like and put it wherever you like, as long as the full path
39has no spaces):
40
41```shell
42$ mkdir ~/chromium && cd ~/chromium
43```
44
45Run the `fetch` tool from depot_tools to check out the code and its
46dependencies.
47
48```shell
49$ fetch --nohooks chromium
50```
51
52If you don't want the full repo history, you can save a lot of time by
53adding the `--no-history` flag to `fetch`.
54
55Expect 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,
75not an entry inside the `solutions` dict.
76
Scott Grahamf94d84d2017-06-26 18:24:4077You will then need to re-run `gclient runhooks`. This makes sure the Fuchsia SDK
78is available in third\_party and keeps it up to date.
79
Adam MacBethc6fc88b52017-06-30 17:26:3180The remaining instructions assume you have switched to the `src` directory:
81
82```shell
83$ cd src
84```
Scott Grahamf94d84d2017-06-26 18:24:4085
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:2186## (Mac-only) Download additional required Clang binaries
87
88Go to [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
89and download the most recent build. Extract `bin/llvm-ar` to the clang folder
90in Chromium:
91
92```shell
93$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
94```
95
Scott Grahamf94d84d2017-06-26 18:24:4096## Setting up the build
97
Tom Bridgwatereef401542018-08-17 00:54:4398Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
99a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
100to generate `.ninja` files. You can create any number of *build directories*
101with different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40102
103```shell
Adam MacBethddd50f32017-07-10 01:42:26104$ 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:40105```
106
Wez2102c3be2017-07-12 01:09:26107You can also build for Debug, with `is_debug=true`, but since we don't currently
108have any Debug build-bots, it may be more broken than Release.
109
Scott Grahamb69a2f62017-06-26 19:32:20110`use_goma=true` is fine to use also if you're a Googler.
111
Scott Grahamf94d84d2017-06-26 18:24:40112## Build
113
114Currently, not all targets build on Fuchsia. You can build base\_unittests, for
115example:
116
117```shell
Max Morozf5b31fcd2018-08-10 21:55:48118$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40119```
120
Max Morozf5b31fcd2018-08-10 21:55:48121`autoninja` is a wrapper that automatically provides optimal values for the
122arguments passed to `ninja`.
123
Scott Grahamf94d84d2017-06-26 18:24:40124## Run
125
126Once it is built, you can run by:
127
128```shell
Wez2102c3be2017-07-12 01:09:26129$ out/fuchsia/bin/run_base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40130```
131
132This packages the built binary and test data into a disk image, and runs a QEMU
133instance from the Fuchsia SDK, outputting to the console.
134
135Common gtest arguments such as `--gtest_filter=...` are supported by the run
136script.
137
138The run script also symbolizes backtraces.
Scott Grahamb69a2f62017-06-26 19:32:20139
140A useful alias (for "Build And Run Filtered") is:
141```shell
Fabrice de Gans-Riberi8225bf82018-06-20 18:50:41142alias barf='ninja -C out/fuchsia net_unittests -j1000 && out/fuchsia/bin/run_net_unittests --test-launcher-filter-file=../../testing/buildbot/filters/fuchsia.net_unittests.filter'
Scott Grahamb69a2f62017-06-26 19:32:20143```
144to build and run only the tests that are not excluded/known-failing on the bot.