blob: 7ad7835eb2da7ee6e4068028ec93e8602e13b3ea [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,
72not an entry inside the `solutions` dict.
73
Scott Graham6b17c6522018-09-25 20:39:3674You will then need to run:
75
76```shell
77$ gclient runhooks
78```
79
80This makes sure the Fuchsia SDK is available in third\_party and keeps it up to
81date.
Scott Grahamf94d84d2017-06-26 18:24:4082
Adam MacBethc6fc88b52017-06-30 17:26:3183The remaining instructions assume you have switched to the `src` directory:
84
85```shell
86$ cd src
87```
Scott Grahamf94d84d2017-06-26 18:24:4088
Wezc03808e2018-11-06 06:27:3589### (Linux-only) Install any required host packages
90
91Chromium relies on some platform packages to be present in order to build.
92You can install the current set of required packages with:
93
94```shell
95$ build/install-build-deps.sh
96```
97
98Note that you need to do this only once, and thereafter only if new dependencies
99are added - these will be announced to the chromium-dev@ group.
100
Scott Graham6b17c6522018-09-25 20:39:36101### Update your checkout
102
103To update an existing checkout, you can run
104
105```shell
106$ git rebase-update
107$ gclient sync
108```
109
110The first command updates the primary Chromium source repository and rebases
111any of your local branches on top of tip-of-tree (aka the Git branch
112`origin/master`). If you don't want to use this script, you can also just use
113`git pull` or other common Git commands to update the repo.
114
115The second command syncs dependencies to the appropriate versions and re-runs
116hooks as needed. `gclient sync` updates dependencies to the versions specified
117in `DEPS`, so any time that file is modified (pulling, changing branches, etc.)
118`gclient sync` should be run.
119
Fabrice de Gans-Riberibbc67a1b2018-08-30 13:19:21120## (Mac-only) Download additional required Clang binaries
121
122Go to [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/)
123and download the most recent build. Extract `bin/llvm-ar` to the clang folder
124in Chromium:
125
126```shell
127$ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts
128```
129
Scott Grahamf94d84d2017-06-26 18:24:40130## Setting up the build
131
Tom Bridgwatereef401542018-08-17 00:54:43132Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
133a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
134to generate `.ninja` files. You can create any number of *build directories*
135with different configurations. To create a build directory, run:
Scott Grahamf94d84d2017-06-26 18:24:40136
137```shell
Adam MacBethddd50f32017-07-10 01:42:26138$ 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:40139```
140
Wez2102c3be2017-07-12 01:09:26141You can also build for Debug, with `is_debug=true`, but since we don't currently
142have any Debug build-bots, it may be more broken than Release.
143
Scott Grahamb69a2f62017-06-26 19:32:20144`use_goma=true` is fine to use also if you're a Googler.
145
Scott Grahamf94d84d2017-06-26 18:24:40146## Build
147
148Currently, not all targets build on Fuchsia. You can build base\_unittests, for
149example:
150
151```shell
Max Morozf5b31fcd2018-08-10 21:55:48152$ autoninja -C out/fuchsia base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40153```
154
Dirk Pranke8bd55f22018-10-24 21:22:10155(`autoninja` is a wrapper that automatically provides optimal values for the
156arguments passed to `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48157
Scott Grahamf94d84d2017-06-26 18:24:40158## Run
159
Wezc03808e2018-11-06 06:27:35160Once you've built a package, you'll want to run it!
161
162### (Recommended)(Linux-only) Enable KVM acceleration
163
164Under Linux, if your host and target CPU architectures are the same (e.g. you're
165building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's
166support for the KVM hypervisor:
167
1681. Install the KVM module for your kernel, to get a /dev/kvm device.
1692. Ensure that your system has a "kvm" group, and it owns /dev/kvm.
170You can do that by installing the QEMU system common package:
171```shell
172$ sudo apt-get install qemu-system-common
173```
1743. Add users to the "kvm" group, and have them login again, to pick-up the new
175group.
176
177### Run test target
Scott Grahamf94d84d2017-06-26 18:24:40178
179```shell
Wez2102c3be2017-07-12 01:09:26180$ out/fuchsia/bin/run_base_unittests
Scott Grahamf94d84d2017-06-26 18:24:40181```
182
183This packages the built binary and test data into a disk image, and runs a QEMU
184instance from the Fuchsia SDK, outputting to the console.
185
186Common gtest arguments such as `--gtest_filter=...` are supported by the run
187script.
188
189The run script also symbolizes backtraces.