Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 1 | # Checking out and building on Fuchsia |
| 2 | |
David Dorwin | f3fad4e | 2021-09-17 19:40:36 | [diff] [blame] | 3 | ***If you have followed the instructions below and things still having trouble, |
| 4 | try `#cr-fuchsia` on [Chromium Slack](https://www.chromium.org/developers/slack) |
| 5 | if something seems awry.*** |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 6 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 7 | There are instructions for other platforms linked from the |
David Dorwin | f3fad4e | 2021-09-17 19:40:36 | [diff] [blame] | 8 | [get the code](../get_the_code.md) page. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 9 | |
Fabrice de Gans-Riberi | 4468e91 | 2019-08-23 23:43:54 | [diff] [blame] | 10 | [TOC] |
| 11 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 12 | ## 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-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 19 | Most development is done on Ubuntu. Mac build is supported on a best-effort |
| 20 | basis. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 21 | |
| 22 | ## Install `depot_tools` |
| 23 | |
| 24 | Clone the `depot_tools` repository: |
| 25 | |
| 26 | ```shell |
| 27 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 28 | ``` |
| 29 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 30 | Add `depot_tools` to the end of your PATH (you will probably want to put this in |
| 31 | your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 32 | `/path/to/depot_tools`: |
| 33 | |
| 34 | ```shell |
| 35 | $ export PATH="$PATH:/path/to/depot_tools" |
| 36 | ``` |
| 37 | |
| 38 | ## Get the code |
| 39 | |
| 40 | Create a `chromium` directory for the checkout and change to it (you can call |
| 41 | this whatever you like and put it wherever you like, as long as the full path |
| 42 | has no spaces): |
| 43 | |
| 44 | ```shell |
| 45 | $ mkdir ~/chromium && cd ~/chromium |
| 46 | ``` |
| 47 | |
| 48 | Run the `fetch` tool from depot_tools to check out the code and its |
| 49 | dependencies. |
| 50 | |
| 51 | ```shell |
| 52 | $ fetch --nohooks chromium |
| 53 | ``` |
| 54 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 55 | Expect the command to take 30 minutes on even a fast connection, and many hours |
| 56 | on slower ones. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 57 | |
| 58 | If you've already installed the build dependencies on the machine (from another |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 59 | checkout, for example), you can omit the `--nohooks` flag and `fetch` will |
| 60 | automatically execute `gclient runhooks` at the end. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 61 | |
| 62 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 63 | directory called `src` in the working directory. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 64 | |
| 65 | ### Configure for building on Fuchsia |
| 66 | |
| 67 | Edit `.gclient` to include (this is a list, so it could also include `android`, |
| 68 | etc. if necessary.) |
| 69 | |
| 70 | ``` |
| 71 | target_os = ['fuchsia'] |
| 72 | ``` |
| 73 | |
Scott Graham | 9ffcea6 | 2017-06-30 21:31:37 | [diff] [blame] | 74 | Note that this should be added as a top-level statement in the `.gclient` file, |
Sharon Yang | 66f3cee | 2019-03-19 21:16:52 | [diff] [blame] | 75 | not an entry inside the `solutions` dict. An example `.gclient` file would look |
| 76 | as follows: |
| 77 | |
| 78 | ``` |
| 79 | solutions = [ |
| 80 | { |
| 81 | "url": "https://chromium.googlesource.com/chromium/src.git", |
| 82 | "managed": False, |
| 83 | "name": "src", |
| 84 | "custom_deps": {}, |
| 85 | "custom_vars": {} |
| 86 | } |
| 87 | ] |
| 88 | target_os = ['fuchsia'] |
| 89 | ``` |
Scott Graham | 9ffcea6 | 2017-06-30 21:31:37 | [diff] [blame] | 90 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 91 | The Fuchsia boot images (also called "SDK companion images") to check out are |
| 92 | specified by the `checkout_fuchsia_boot_images` variable. For instance, adding |
| 93 | `"checkout_fuchsia_boot_images": "qemu.x64,workstation.qemu-x64-release",` to |
| 94 | the `custom_vars` section of your `.gclient` file would allow you to check out |
| 95 | both images. The set of available images is listed in the |
| 96 | [DEPS file](https://source.chromium.org/chromium/chromium/src/+/main:DEPS). |
Chong Gu | 96fe8db | 2021-09-29 21:28:00 | [diff] [blame] | 97 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 98 | Note: fxbug.dev/85552 tracks migration away from the legacy image names, like |
| 99 | `qemu.x64`, which is mapped to `terminal.qemu-x64-release` by the |
| 100 | [`update_images.py`](https://source.chromium.org/chromium/chromium/src/+/main:build/fuchsia/update_images.py) |
| 101 | helper script. |
Chong Gu | 96fe8db | 2021-09-29 21:28:00 | [diff] [blame] | 102 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 103 | You will then need to run: |
| 104 | |
| 105 | ```shell |
Kevin Marshall | 173a180 | 2020-06-09 18:03:32 | [diff] [blame] | 106 | $ gclient sync |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 107 | ``` |
| 108 | |
| 109 | This makes sure the Fuchsia SDK is available in third\_party and keeps it up to |
| 110 | date. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 111 | |
Adam MacBeth | c6fc88b5 | 2017-06-30 17:26:31 | [diff] [blame] | 112 | The remaining instructions assume you have switched to the `src` directory: |
| 113 | |
| 114 | ```shell |
| 115 | $ cd src |
| 116 | ``` |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 117 | |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 118 | ### (Linux-only) Install any required host packages |
| 119 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 120 | Chromium relies on some platform packages to be present in order to build. You |
| 121 | can install the current set of required packages with: |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 122 | |
| 123 | ```shell |
| 124 | $ build/install-build-deps.sh |
| 125 | ``` |
| 126 | |
| 127 | Note that you need to do this only once, and thereafter only if new dependencies |
| 128 | are added - these will be announced to the chromium-dev@ group. |
| 129 | |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 130 | ### Update your checkout |
| 131 | |
| 132 | To update an existing checkout, you can run |
| 133 | |
| 134 | ```shell |
| 135 | $ git rebase-update |
| 136 | $ gclient sync |
| 137 | ``` |
| 138 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 139 | The first command updates the primary Chromium source repository and rebases any |
| 140 | of your local branches on top of tip-of-tree (aka the Git branch `origin/main`). |
| 141 | If you don't want to use this script, you can also just use `git pull` or other |
| 142 | common Git commands to update the repo. |
Scott Graham | 6b17c652 | 2018-09-25 20:39:36 | [diff] [blame] | 143 | |
| 144 | The second command syncs dependencies to the appropriate versions and re-runs |
| 145 | hooks as needed. `gclient sync` updates dependencies to the versions specified |
| 146 | in `DEPS`, so any time that file is modified (pulling, changing branches, etc.) |
| 147 | `gclient sync` should be run. |
| 148 | |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 149 | ## (Mac-only) Download additional required Clang binaries |
| 150 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 151 | Go to |
| 152 | [this page](https://chrome-infra-packages.appspot.com/p/fuchsia/clang/mac-amd64/+/) |
| 153 | and download the most recent build. Extract `bin/llvm-ar` to the clang folder in |
| 154 | Chromium: |
Fabrice de Gans-Riberi | bbc67a1b | 2018-08-30 13:19:21 | [diff] [blame] | 155 | |
| 156 | ```shell |
| 157 | $ unzip /path/to/clang.zip bin/llvm-ar -d ${CHROMIUM_SRC}/third_party/llvm-build/Release+Asserts |
| 158 | ``` |
| 159 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 160 | ## Setting up the build |
| 161 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 162 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 163 | a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) to |
| 164 | generate `.ninja` files. You can create any number of *build directories* with |
| 165 | different configurations. To create a build directory, run: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 166 | |
| 167 | ```shell |
Adam MacBeth | ddd50f3 | 2017-07-10 01:42:26 | [diff] [blame] | 168 | $ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\"" |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 169 | ``` |
| 170 | |
Wez | 2102c3be | 2017-07-12 01:09:26 | [diff] [blame] | 171 | You can also build for Debug, with `is_debug=true`, but since we don't currently |
| 172 | have any Debug build-bots, it may be more broken than Release. |
| 173 | |
Scott Graham | b69a2f6 | 2017-06-26 19:32:20 | [diff] [blame] | 174 | `use_goma=true` is fine to use also if you're a Googler. |
| 175 | |
Sharon Yang | f6e51ee | 2020-09-25 14:59:51 | [diff] [blame] | 176 | Architecture options are x64 (default) and arm64. This can be set with |
Aidan Wolter | 53cde64 | 2020-10-29 16:02:26 | [diff] [blame] | 177 | `target_cpu=\"arm64\"`. |
Sharon Yang | f6e51ee | 2020-09-25 14:59:51 | [diff] [blame] | 178 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 179 | ## Build |
| 180 | |
Scott Graham | 4c9dc31 | 2018-11-07 19:52:41 | [diff] [blame] | 181 | All targets included in the GN build should build successfully. You can also |
| 182 | build a specific binary, for example, base\_unittests: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 183 | |
| 184 | ```shell |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 185 | $ autoninja -C out/fuchsia base_unittests |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 186 | ``` |
| 187 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 188 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 189 | arguments passed to `ninja`.) |
Max Moroz | f5b31fcd | 2018-08-10 21:55:48 | [diff] [blame] | 190 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 191 | ## Run |
| 192 | |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 193 | Once you've built a package, you'll want to run it! |
| 194 | |
| 195 | ### (Recommended)(Linux-only) Enable KVM acceleration |
| 196 | |
| 197 | Under Linux, if your host and target CPU architectures are the same (e.g. you're |
| 198 | building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's |
| 199 | support for the KVM hypervisor: |
| 200 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 201 | 1. Install the KVM module for your kernel, to get a /dev/kvm device. |
| 202 | 2. Ensure that your system has a "kvm" group, and it owns /dev/kvm. You can do |
| 203 | that by installing the QEMU system common package: `shell $ sudo apt-get |
| 204 | install qemu-system-common` |
| 205 | 3. Add users to the "kvm" group, and have them login again, to pick-up the new |
| 206 | group. `shell $ sudo adduser <user> kvm $ exit [log in again]` |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 207 | |
Fabrice de Gans-Riberi | cfa0fb7d8 | 2019-07-02 18:23:09 | [diff] [blame] | 208 | ### Running test suites |
| 209 | |
Chong Gu | 4749ec1 | 2021-02-17 01:41:06 | [diff] [blame] | 210 | There are three types of tests available to run on Fuchsia: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 211 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame^] | 212 | 1. [Gtests](gtests.md) |
| 213 | 2. [GPU integration tests](gpu_testing.md) |
| 214 | 3. [Blink tests](web_tests.md) |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 215 | |
Chong Gu | 4749ec1 | 2021-02-17 01:41:06 | [diff] [blame] | 216 | Check the documentations to learn more about how to run these tests. |