Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 1 | # Chrome OS Build Instructions |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 2 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 3 | Chrome for Chromium OS can be built in a couple different ways. After following |
| 4 | the [initial setup](#common-setup), you'll need to choose one of the following |
| 5 | build configurations: |
stevenjb | 89ee24b | 2016-04-19 19:26:42 | [diff] [blame] | 6 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 7 | - If you're interested in testing Chrome OS code in Chrome, but not interactions |
| 8 | with Chrome OS services, you can build for |
| 9 | [linux-chromeos](#Chromium-OS-on-Linux-linux_chromeos) using just a Linux |
| 10 | workstation. |
| 11 | - Otherwise, Chrome's full integration can be covered by building for a real |
| 12 | Chrome OS device or VM using [Simple Chrome](#Chromium-OS-Device-Simple-Chrome). |
Xiaohan Wang | 69ee4c0 | 2021-02-18 01:28:59 | [diff] [blame] | 13 | - Use `is_chromeos_device` in GN and `BUILDFLAG(IS_CHROMEOS_DEVICE)` in C++ code |
| 14 | to differentiate between these two modes. |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 15 | |
| 16 | [TOC] |
| 17 | |
| 18 | ## Common setup |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 19 | |
| 20 | First, follow the [normal Linux build |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 21 | instructions](https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md) |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 22 | as usual to get a Chromium checkout. |
| 23 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 24 | You'll also need to add `'chromeos'` to the `target_os` list in your `.gclient` |
| 25 | configuration, which will fetch the additional build dependencies required for |
| 26 | CrOS. This file is located one level up from your Chromium checkout's `src`. |
Ken Rockot | a21ef76 | 2018-05-02 04:02:37 | [diff] [blame] | 27 | |
| 28 | If you don't already have a `target_os` line present, simply add this to the |
| 29 | end of the `.gclient` file: |
| 30 | |
| 31 | target_os = ['chromeos'] |
| 32 | |
| 33 | If you already have a `target_os` line present in your `.gclient file`, you can |
| 34 | simply append `'chromeos'` to the existing list there. For example: |
| 35 | |
| 36 | target_os = ['android', 'chromeos'] |
| 37 | |
| 38 | Once your `.gclient` file is updated, you will need to run `gclient sync` once |
| 39 | before proceeding with the rest of these instructions. |
| 40 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 41 | ## Chromium OS on Linux (linux-chromeos) |
| 42 | |
| 43 | Chromium on Chromium OS uses Linux Chromium as a base, but adds a large number |
| 44 | of Chrome OS-specific features to the code. For example, the login UI, window |
| 45 | manager and system UI are part of the Chromium code base and built into the |
| 46 | chrome binary. |
| 47 | |
| 48 | Fortunately, most Chromium changes that affect Chromium OS can be built and |
| 49 | tested on a Linux workstation. This build is called "linux-chromeos". In this |
| 50 | configuration most system services (like the power manager, bluetooth daemon, |
| 51 | etc.) are stubbed out. The entire system UI runs in a single X11 window on your |
| 52 | desktop. |
| 53 | |
Victor Hugo Vianna Silva | bd1065a | 2021-04-29 15:10:47 | [diff] [blame] | 54 | You can test sign-in/sync in this mode by adding the --login-manager flag, see |
| 55 | the [Login notes](#Login-notes) section. |
| 56 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 57 | ### Building and running Chromium with Chromium OS UI on your local machine |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 58 | |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 59 | Run the following in your chromium checkout: |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 60 | |
stevenjb | ec7b4e3c | 2016-04-18 22:52:02 | [diff] [blame] | 61 | $ gn gen out/Default --args='target_os="chromeos"' |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 62 | $ autoninja -C out/Default chrome |
Joel Hockey | 82e0062 | 2020-08-12 05:26:11 | [diff] [blame] | 63 | $ out/Default/chrome --use-system-clipboard |
stevenjb | ec7b4e3c | 2016-04-18 22:52:02 | [diff] [blame] | 64 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 65 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 66 | arguments passed to `ninja`). |
| 67 | |
Matt Giuca | d8cebe4 | 2018-01-09 04:37:46 | [diff] [blame] | 68 | Some additional options you may wish to set by passing in `--args` to `gn gen` |
| 69 | or running `gn args out/Default`: |
stevenjb | 89ee24b | 2016-04-19 19:26:42 | [diff] [blame] | 70 | |
Ho Cheung | b5be747 | 2025-03-07 08:18:57 | [diff] [blame] | 71 | # Reclient is a distributed compiler service that is only available to |
| 72 | # Googlers and contributors who have access to Reclient. |
Oleh Lamzin | ae82b2e | 2023-10-05 08:22:46 | [diff] [blame] | 73 | use_remoteexec = true |
| 74 | |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 75 | is_component_build = true # Links faster. |
| 76 | is_debug = false # Release build, runs faster. |
| 77 | dcheck_always_on = true # Enables DCHECK despite release build. |
| 78 | enable_nacl = false # Skips native client build, compiles faster. |
Jacob Dufault | bfef58b | 2018-01-12 22:39:48 | [diff] [blame] | 79 | |
Satoru Takabayashi | 5f3b2ec | 2023-02-17 05:31:53 | [diff] [blame] | 80 | # Builds Chrome instead of Chromium. This requires a src-internal |
| 81 | # checkout. Adds internal features and branded art assets. |
| 82 | is_chrome_branded = true |
| 83 | |
| 84 | # Enables many optimizations, leading to much slower compiles, links, |
| 85 | # and no runtime stack traces. |
Oleh Lamzin | f8ef3408d3 | 2023-10-05 08:57:40 | [diff] [blame] | 86 | # |
| 87 | # Note: not compatible with `is_component_build = true`. |
Satoru Takabayashi | 5f3b2ec | 2023-02-17 05:31:53 | [diff] [blame] | 88 | is_official_build = true |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 89 | |
Ho Cheung | b5be747 | 2025-03-07 08:18:57 | [diff] [blame] | 90 | NOTE: |
| 91 | - You may wish to replace 'Default' with something like 'Cros' if you switch |
| 92 | back and forth between Linux and Chromium OS builds, or 'Debug' if you want |
| 93 | to differentiate between Debug and Release builds (see below). |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 94 | |
Ho Cheung | b5be747 | 2025-03-07 08:18:57 | [diff] [blame] | 95 | - See [GN Build |
| 96 | Configuration](https://www.chromium.org/developers/gn-build-configuration) |
| 97 | for more information about configuring your build. |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 98 | |
Ho Cheung | b5be747 | 2025-03-07 08:18:57 | [diff] [blame] | 99 | - You can also build and run test targets like `unit_tests`, `browser_tests`, |
| 100 | etc. |
| 101 | |
| 102 | - For contributors (Not a Googler) with access to Reclient, please follow the |
| 103 | corresponding [Linux build |
| 104 | instructions](linux/build_instructions.md#use-reclient) to configure |
| 105 | Reclient. |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 106 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 107 | ### Flags |
Joel Hockey | 82e0062 | 2020-08-12 05:26:11 | [diff] [blame] | 108 | |
| 109 | Some useful flags: |
| 110 | |
| 111 | * `--ash-debug-shortcuts`: Enable shortcuts such as Ctl+Alt+Shift+T to toggle |
| 112 | tablet mode. |
| 113 | * `--ash-host-window-bounds="0+0-800x600,800+0-800x600"`: Specify one or more |
| 114 | virtual screens, by display position and size. |
| 115 | * `--enable-features=Feature1,OtherFeature2`: Enable specified features. |
| 116 | Features are often listed in chrome://flags, or in source files such as |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 117 | [chrome_features.cc](https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/chrome_features.cc) |
| 118 | or [ash_features.cc](https://source.chromium.org/chromium/chromium/src/+/main:ash/constants/ash_features.cc). |
Joel Hockey | 82e0062 | 2020-08-12 05:26:11 | [diff] [blame] | 119 | Note that changing values in chrome://flags does not work for |
| 120 | linux-chromeos, and this flag must be used. |
| 121 | * `--enable-ui-devtools[=9223]`: Allow debugging of the system UI through |
| 122 | devtools either within linux-chromeos at chrome://inspect, or from a remote |
| 123 | browser at |
| 124 | devtools://devtools/bundled/devtools_app.html?uiDevTools=true&ws=127.0.0.1:9223/0 |
| 125 | * `--remote-debugging-port=9222`: Allow debugging through devtools at |
| 126 | http://localhost:9222 |
| 127 | * `--use-system-clipboard`: Integrate clipboard with the host X11 system. |
| 128 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 129 | ### Login notes |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 130 | |
| 131 | By default this build signs in with a stub user. To specify a real user: |
| 132 | |
| 133 | * For first run, add the following options to chrome's command line: |
| 134 | `--user-data-dir=/tmp/chrome --login-manager` |
| 135 | * Go through the out-of-the-box UX and sign in with a real Gmail account. |
Victor Hugo Vianna Silva | bd1065a | 2021-04-29 15:10:47 | [diff] [blame] | 136 | * For subsequent runs, if you want to skip the login manager page, add: |
Toby H | 42fa251 | 2019-06-13 18:09:39 | [diff] [blame] | 137 | `--user-data-dir=/tmp/chrome --login-user=username@gmail.com |
Victor Hugo Vianna Silva | bd1065a | 2021-04-29 15:10:47 | [diff] [blame] | 138 | --login-profile=username@gmail.com-hash`. It's also fine to just keep |
| 139 | --login-manager instead. |
James Cook | 4dca079 | 2018-01-24 22:57:34 | [diff] [blame] | 140 | * To run in guest mode instantly, add: |
| 141 | `--user-data-dir=/tmp/chrome --bwsi --incognito --login-user='$guest' |
| 142 | --login-profile=user` |
| 143 | |
| 144 | Signing in as a specific user is useful for debugging features like sync |
| 145 | that require a logged in user. |
| 146 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 147 | ### Graphics notes |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 148 | |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 149 | The Chromium OS build requires a functioning GL so if you plan on |
| 150 | testing it through Chromium Remote Desktop you might face drawing |
| 151 | problems (e.g. Aura window not painting anything). Possible remedies: |
| 152 | |
Matt Giuca | d8cebe4 | 2018-01-09 04:37:46 | [diff] [blame] | 153 | * `--ui-enable-software-compositing --ui-disable-threaded-compositing` |
Alexis Hetu | 8c54b0b7 | 2022-02-11 14:35:59 | [diff] [blame] | 154 | * `--use-gl=angle --use-angle=swiftshader`, but it's slow. |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 155 | |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 156 | To more closely match the UI used on devices, you can install fonts used |
| 157 | by Chrome OS, such as Roboto, on your Linux distro. |
| 158 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 159 | ## Chromium OS Device (Simple Chrome) |
tfarina | 5b37337 | 2016-03-27 08:06:21 | [diff] [blame] | 160 | |
Ben Pastene | 5764fdd6 | 2020-08-12 22:22:10 | [diff] [blame] | 161 | This configuration allows you to build a fully functional Chrome for a real |
| 162 | Chrome OS device or VM. Since Chrome OS uses a different toolchain for each |
| 163 | device model, you'll first need to know the name of the model (or "board") you |
| 164 | want to build for. For most boards, `amd64-generic` and `arm-generic` will |
| 165 | produce a functional binary, though it won't be optimized and may be missing |
| 166 | functionality. |
| 167 | |
| 168 | ### Additional gclient setup |
| 169 | |
| 170 | Each board has its own toolchain and misc. build dependencies. To fetch these, |
| 171 | list the board under the `"cros_boards"` gclient custom var. If you were using |
| 172 | the `amd64-generic` board, your `.gclient` file would look like: |
| 173 | ``` |
| 174 | solutions = [ |
| 175 | { |
| 176 | "url": "https://chromium.googlesource.com/chromium/src.git", |
| 177 | "name": "src", |
| 178 | "custom_deps": {}, |
| 179 | "custom_vars" : { |
| 180 | "cros_boards": "amd64-generic", |
| 181 | }, |
| 182 | }, |
| 183 | ] |
| 184 | target_os = ["chromeos"] |
| 185 | ``` |
| 186 | Once your .gclient file is updated, you will need to run `gclient sync` again |
| 187 | to fetch the toolchain. |
| 188 | |
| 189 | NOTE: |
| 190 | - If you'd like a VM image additionally downloaded for the board, add it to the |
| 191 | `"cros_boards_with_qemu_images"` gclient custom var. That var downloads the |
| 192 | SDK along with a VM image. `cros_boards` downloads only the SDK. |
| 193 | - If you'd like to fetch multiple boards, add a `:` between each board in the |
| 194 | gclient var. For example: `"cros_boards": "amd64-generic:arm-generic"`. |
| 195 | |
| 196 | ### Building for the board |
| 197 | |
| 198 | After the needed toolchain has been downloaded for your ${BOARD}, a build dir |
| 199 | will have been conveniently created for you at `out_$BOARD/Release`, which can |
| 200 | then be used to build Chrome. For the `amd64-generic` board, this would |
| 201 | look like: |
| 202 | |
| 203 | $ gn gen out_amd64-generic/Release |
| 204 | $ autoninja -C out_$BOARD/Release chrome |
| 205 | |
| 206 | Or if you prefer to use your own build dir, simply add the following line to the |
| 207 | top of your GN args: `import("//build/args/chromeos/amd64-generic.gni")`. eg: |
| 208 | |
| 209 | $ gn gen out/Default --args='import("//build/args/chromeos/amd64-generic.gni")' |
| 210 | $ autoninja -C out/Default chrome |
| 211 | |
| 212 | That will produce a Chrome OS build of Chrome very similar to what is shipped |
| 213 | for that device. You can also supply additional args or even overwrite ones |
| 214 | supplied in the imported .gni file after the `import()` line. |
| 215 | |
| 216 | ### Additional notes |
| 217 | |
| 218 | For more information (like copying the locally-built Chrome to a device, or |
| 219 | running Tast tests), consult Simple Chrome's |
John Palmer | 046f987 | 2021-05-24 01:24:56 | [diff] [blame] | 220 | [full documentation](https://chromium.googlesource.com/chromiumos/docs/+/main/simple_chrome_workflow.md). |