Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 1 | # Checking out and building on Fuchsia |
| 2 | |
David Dorwin | fe186dd | 2022-05-20 18:35:13 | [diff] [blame] | 3 | ***If you have followed the instructions below and are still having trouble, |
| 4 | see [Contact information](README.md#contact-information).*** |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 5 | |
Fabrice de Gans-Riberi | 4468e91 | 2019-08-23 23:43:54 | [diff] [blame] | 6 | [TOC] |
| 7 | |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 8 | ## System requirements |
| 9 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 10 | Building and running on Linux is officially supported, mac build is not. If you |
| 11 | are willing to run emulator based tests locally, KVM is required. You may check |
| 12 | if `/dev/kvm` exists on the system, or follow the [Enable KVM](#enable-kvm) |
| 13 | section. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 14 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 15 | 1. Follow up [chromium for linux](../linux/build_instructions.md) to setup |
| 16 | chromium environment. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 17 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 18 | 2. Edit your `.gclient` to add `fuchsia` to the `target_os` list. The file |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 19 | should look similar to this: |
| 20 | |
| 21 | ``` |
| 22 | solutions = [ |
| 23 | { |
| 24 | "url": "https://chromium.googlesource.com/chromium/src.git", |
| 25 | "managed": False, |
| 26 | "name": "src", |
| 27 | "custom_deps": {}, |
| 28 | "custom_vars": {} |
| 29 | } |
| 30 | ] |
| 31 | target_os = ['fuchsia'] |
| 32 | ``` |
| 33 | |
| 34 | 2. Run `gclient sync` |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 35 | |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 36 | 3. Create a build directory: |
| 37 | |
| 38 | ```shell |
| 39 | $ gn gen out/fuchsia --args="is_debug=false dcheck_always_on=true is_component_build=false target_os=\"fuchsia\"" |
| 40 | ``` |
| 41 | |
Takuto Ikuta | 7e61637 | 2024-05-15 06:00:42 | [diff] [blame] | 42 | You can add many of the usual GN arguments like `use_remoteexec = true`. In |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 43 | particular, when working with devices, consider using `is_debug = false` and |
| 44 | `is_component_build = false` since debug and component builds can drastically |
| 45 | increase run time and used space. |
| 46 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 47 | 4. Build the target as you would for any other platform, you may specify the |
| 48 | targets to build at the end of the command line: |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 49 | ```shell |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 50 | $ autoninja -C out/fuchsia |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 51 | ``` |
| 52 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 53 | 5. Most of the gtests based tests can be executed via |
| 54 | `out/fuchsia/bin/run_***_unittests`, e.g. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 55 | ```shell |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 56 | $ out/fuchsia/bin/run_base_unittests |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 57 | ``` |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 58 | It starts a fresh new emulator instance and executes the tests on it under |
| 59 | the hood. Also see the [Running test suites](#running-test-suites) section |
| 60 | for other types of tests. |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 61 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 62 | ## Enable KVM |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 63 | Under Linux, if your host and target CPU architectures are the same (e.g. you're |
| 64 | building for Fuchsia/x64 on a Linux/x64 host) then you can benefit from QEMU's |
| 65 | support for the KVM hypervisor: |
| 66 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 67 | 1. Install the KVM module for your kernel, to get a /dev/kvm device. |
| 68 | 2. Ensure that your system has a "kvm" group, and it owns /dev/kvm. You can do |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 69 | that by installing the QEMU system common package: `$ sudo apt-get |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 70 | install qemu-system-common` |
| 71 | 3. Add users to the "kvm" group, and have them login again, to pick-up the new |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 72 | group. |
| 73 | ```shell |
| 74 | $ sudo adduser <user> kvm |
| 75 | $ exit [log in again] |
| 76 | ``` |
Wez | c03808e | 2018-11-06 06:27:35 | [diff] [blame] | 77 | |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 78 | ## Running test suites |
Fabrice de Gans-Riberi | cfa0fb7d8 | 2019-07-02 18:23:09 | [diff] [blame] | 79 | |
Chong Gu | ae2c09a | 2023-01-11 17:07:45 | [diff] [blame] | 80 | There are four types of tests available to run on Fuchsia: |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 81 | |
Jaeheon Yi | 9eaf5b52 | 2021-10-01 23:17:56 | [diff] [blame] | 82 | 1. [Gtests](gtests.md) |
| 83 | 2. [GPU integration tests](gpu_testing.md) |
| 84 | 3. [Blink tests](web_tests.md) |
Chong Gu | ae2c09a | 2023-01-11 17:07:45 | [diff] [blame] | 85 | 4. [Webpage tests](webpage_tests.md) |
Scott Graham | f94d84d | 2017-06-26 18:24:40 | [diff] [blame] | 86 | |
Chong Gu | 4749ec1 | 2021-02-17 01:41:06 | [diff] [blame] | 87 | Check the documentations to learn more about how to run these tests. |
Fabrice de Gans | f941df7e | 2021-11-23 21:33:14 | [diff] [blame] | 88 | |
David Dorwin | badcdae | 2023-02-03 04:03:17 | [diff] [blame] | 89 | Documentation for the underlying testing scripts work can be found |
Zijie He | bd2aca07 | 2024-11-06 19:35:27 | [diff] [blame] | 90 | [here](test_scripts.md). |