blob: 46d5605c35683b35512774fd9bd3c5257ff1e365 [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
Scott Graham6b17c6522018-09-25 20:39:366There are instructions for other platforms linked from the
Scott Grahamf94d84d2017-06-26 18:24:407[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
Scott Grahamf94d84d2017-06-26 18:24:4052Expect the command to take 30 minutes on even a fast connection, and many
53hours on slower ones.
54
55If you've already installed the build dependencies on the machine (from another
56checkout, for example), you can omit the `--nohooks` flag and `fetch`
57will automatically execute `gclient runhooks` at the end.
58
59When `fetch` completes, it will have created a hidden `.gclient` file and a
Adam MacBethc6fc88b52017-06-30 17:26:3160directory called `src` in the working directory.
Scott Grahamf94d84d2017-06-26 18:24:4061
62### Configure for building on Fuchsia
63
64Edit `.gclient` to include (this is a list, so it could also include `android`,
65etc. if necessary.)
66
67```
68target_os = ['fuchsia']
69```
70
Scott Graham9ffcea62017-06-30 21:31:3771Note that this should be added as a top-level statement in the `.gclient` file,
Sharon Yang66f3cee2019-03-19 21:16:5272not an entry inside the `solutions` dict. An example `.gclient` file would look
73as follows:
74
75```
76solutions = [
77 {
78 "url": "https://chromium.googlesource.com/chromium/src.git",
79 "managed": False,
80 "name": "src",
81 "custom_deps": {},
82 "custom_vars": {}
83 }
84]
85target_os = ['fuchsia']
86```
Scott Graham9ffcea62017-06-30 21:31:3787
Scott Graham6b17c6522018-09-25 20:39:3688You will then need to run:
89
90```shell
91$ gclient runhooks
92```
93
94This makes sure the Fuchsia SDK is available in third\_party and keeps it up to
95date.
Scott Grahamf94d84d2017-06-26 18:24:4096
Adam MacBethc6fc88b52017-06-30 17:26:3197The remaining instructions assume you have switched to the `src` directory:
98
99```shell
100$ cd src
101```
Scott Grahamf94d84d2017-06-26 18:24:40102
Wezc03808e2018-11-06 06:27:35103### (Linux-only) Install any required host packages
104
105Chromium relies on some platform packages to be present in order to build.
106You can install the current set of required packages with:
107
108```shell
109$ build/install-build-deps.sh
110```
111
112Note that you need to do this only once, and thereafter only if new dependencies
113are added - these will be announced to the chromium-dev@ group.
114
Scott Graham6b17c6522018-09-25 20:39:36115### Update your checkout
116
117To update an existing checkout, you can run
118
119```shell
120$ git rebase-update
121$ gclient sync
122```
123
124The first command updates the primary Chromium source repository and rebases
125any of your local branches on top of tip-of-tree (aka the Git branch
126`origin/master`). If you don't want to use this script, you can also just use
127`git pull` or other common Git commands to update the repo.
128
129The second command syncs dependencies to the appropriate versions and re-runs
130hooks as needed. `gclient sync` updates dependencies to the versions specified
131in `DEPS`, so any time that file is modified (pulling, changing branches, etc.)
132`gclient sync` should be run.
133
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21134## (Mac-only) Download additional required Clang binaries
135
136Go to [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
137and download the most recent build. Extract `bin/llvm-ar` to the clang folder
138in Chromium:
139
140```shell
141$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
142```
143
Scott Grahamf94d84d2017-06-26 18:24:40144## Setting up the build
145
Tom Bridgwatereef401542018-08-17 00:54:43146Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
147a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
148to generate `.ninja` files. You can create any number of *build directories*
149with different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40150
151```shell
Adam MacBethddd50f32017-07-10 01:42:26152$ 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:40153```
154
Wez2102c3be2017-07-12 01:09:26155You can also build for Debug, with `is_debug=true`, but since we don't currently
156have any Debug build-bots, it may be more broken than Release.
157
Scott Grahamb69a2f62017-06-26 19:32:20158`use_goma=true` is fine to use also if you're a Googler.
159
Scott Grahamf94d84d2017-06-26 18:24:40160## Build
161
Scott Graham4c9dc312018-11-07 19:52:41162All targets included in the GN build should build successfully. You can also
163build a specific binary, for example, base\_unittests:
Scott Grahamf94d84d2017-06-26 18:24:40164
165```shell
Max Morozf5b31fcd2018-08-10 21:55:48166$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40167```
168
Dirk Pranke8bd55f22018-10-24 21:22:10169(`autoninja` is a wrapper that automatically provides optimal values for the
170arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48171
Scott Grahamf94d84d2017-06-26 18:24:40172## Run
173
Wezc03808e2018-11-06 06:27:35174Once you've built a package, you'll want to run it!
175
176### (Recommended)(Linux-only) Enable KVM acceleration
177
178Under Linux, if your host and target CPU architectures are the same (e.g. you're
179building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's
180support for the KVM hypervisor:
181
1821. Install the KVM module for your kernel, to get a /dev/kvm device.
1832. Ensure that your system has a "kvm" group, and it owns /dev/kvm.
184You can do that by installing the QEMU system common package:
185```shell
186$ sudo apt-get install qemu-system-common
187```
1883. Add users to the "kvm" group, and have them login again, to pick-up the new
189group.
190
191### Run test target
Scott Grahamf94d84d2017-06-26 18:24:40192
193```shell
Wez2102c3be2017-07-12 01:09:26194$ out/fuchsia/bin/run_base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40195```
196
197This packages the built binary and test data into a disk image, and runs a QEMU
198instance from the Fuchsia SDK, outputting to the console.
199
200Common gtest arguments such as `--gtest_filter=...` are supported by the run
201script.
202
203The run script also symbolizes backtraces.