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