blob: ad4c9a09334586db3a01b1e725c761fdb7cb5b4d [file] [log] [blame] [view]
Ben Pastene5764fdd62020-08-12 22:22:101# Chrome OS Build Instructions
tfarina5b373372016-03-27 08:06:212
Ben Pastene5764fdd62020-08-12 22:22:103Chrome for Chromium OS can be built in a couple different ways. After following
4the [initial setup](#common-setup), you'll need to choose one of the following
5build configurations:
stevenjb89ee24b2016-04-19 19:26:426
Ben Pastene5764fdd62020-08-12 22:22:107- 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
tfarina5b373372016-03-27 08:06:2117
18First, follow the [normal Linux build
Tom Anderson9f5be0792019-12-19 20:54:3219instructions](https://chromium.googlesource.com/chromium/src/+/master/docs/linux/build_instructions.md)
tfarina5b373372016-03-27 08:06:2120as usual to get a Chromium checkout.
21
Ben Pastene5764fdd62020-08-12 22:22:1022You'll also need to add `'chromeos'` to the `target_os` list in your `.gclient`
23configuration, which will fetch the additional build dependencies required for
24CrOS. This file is located one level up from your Chromium checkout's `src`.
Ken Rockota21ef762018-05-02 04:02:3725
26If you don't already have a `target_os` line present, simply add this to the
27end of the `.gclient` file:
28
29 target_os = ['chromeos']
30
31If you already have a `target_os` line present in your `.gclient file`, you can
32simply append `'chromeos'` to the existing list there. For example:
33
34 target_os = ['android', 'chromeos']
35
36Once your `.gclient` file is updated, you will need to run `gclient sync` once
37before proceeding with the rest of these instructions.
38
Ben Pastene5764fdd62020-08-12 22:22:1039## Chromium OS on Linux (linux-chromeos)
40
41Chromium on Chromium OS uses Linux Chromium as a base, but adds a large number
42of Chrome OS-specific features to the code. For example, the login UI, window
43manager and system UI are part of the Chromium code base and built into the
44chrome binary.
45
46Fortunately, most Chromium changes that affect Chromium OS can be built and
47tested on a Linux workstation. This build is called "linux-chromeos". In this
48configuration most system services (like the power manager, bluetooth daemon,
49etc.) are stubbed out. The entire system UI runs in a single X11 window on your
50desktop.
51
52### Building and running Chromium with Chromium OS UI on your local machine
tfarina5b373372016-03-27 08:06:2153
James Cook4dca0792018-01-24 22:57:3454Run the following in your chromium checkout:
tfarina5b373372016-03-27 08:06:2155
stevenjbec7b4e3c2016-04-18 22:52:0256 $ gn gen out/Default --args='target_os="chromeos"'
James Cook4dca0792018-01-24 22:57:3457 $ autoninja -C out/Default chrome
Joel Hockey82e00622020-08-12 05:26:1158 $ out/Default/chrome --use-system-clipboard
stevenjbec7b4e3c2016-04-18 22:52:0259
Dirk Pranke8bd55f22018-10-24 21:22:1060(`autoninja` is a wrapper that automatically provides optimal values for the
61arguments passed to `ninja`).
62
Matt Giucad8cebe42018-01-09 04:37:4663Some additional options you may wish to set by passing in `--args` to `gn gen`
64or running `gn args out/Default`:
stevenjb89ee24b2016-04-19 19:26:4265
James Cook4dca0792018-01-24 22:57:3466 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.
Jacob Dufaultbfef58b2018-01-12 22:39:4871
72 # Set the following true to create a Chrome (instead of Chromium) build.
James Cook4dca0792018-01-24 22:57:3473 # This requires a src-internal checkout.
74 is_chrome_branded = false # Adds internal features and branded art assets.
75 is_official_build = false # Turns on many optimizations, slower build.
tfarina5b373372016-03-27 08:06:2176
James Cook4dca0792018-01-24 22:57:3477NOTE: You may wish to replace 'Default' with something like 'Cros' if
78you switch back and forth between Linux and Chromium OS builds, or 'Debug'
79if you want to differentiate between Debug and Release builds (see below).
80
81See [GN Build Configuration](https://www.chromium.org/developers/gn-build-configuration)
82for more information about configuring your build.
83
84You can also build and run test targets like `unit_tests`, `browser_tests`, etc.
85
Ben Pastene5764fdd62020-08-12 22:22:1086### Flags
Joel Hockey82e00622020-08-12 05:26:1187
88Some useful flags:
89
90* `--ash-debug-shortcuts`: Enable shortcuts such as Ctl+Alt+Shift+T to toggle
91 tablet mode.
92* `--ash-host-window-bounds="0+0-800x600,800+0-800x600"`: Specify one or more
93 virtual screens, by display position and size.
94* `--enable-features=Feature1,OtherFeature2`: Enable specified features.
95 Features are often listed in chrome://flags, or in source files such as
96 [chrome_features.cc](https://source.chromium.org/chromium/chromium/src/+/master:chrome/common/chrome_features.cc)
97 or [chromeos_features.cc](https://source.chromium.org/chromium/chromium/src/+/master:chromeos/constants/chromeos_features.cc).
98 Note that changing values in chrome://flags does not work for
99 linux-chromeos, and this flag must be used.
100* `--enable-ui-devtools[=9223]`: Allow debugging of the system UI through
101 devtools either within linux-chromeos at chrome://inspect, or from a remote
102 browser at
103 devtools://devtools/bundled/devtools_app.html?uiDevTools=true&ws=127.0.0.1:9223/0
104* `--remote-debugging-port=9222`: Allow debugging through devtools at
105 http://localhost:9222
106* `--use-system-clipboard`: Integrate clipboard with the host X11 system.
107
Ben Pastene5764fdd62020-08-12 22:22:10108### Login notes
James Cook4dca0792018-01-24 22:57:34109
110By default this build signs in with a stub user. To specify a real user:
111
112* For first run, add the following options to chrome's command line:
113 `--user-data-dir=/tmp/chrome --login-manager`
114* Go through the out-of-the-box UX and sign in with a real Gmail account.
115* For subsequent runs, add:
Toby H42fa2512019-06-13 18:09:39116 `--user-data-dir=/tmp/chrome [email protected]
117 [email protected]`
James Cook4dca0792018-01-24 22:57:34118* To run in guest mode instantly, add:
119 `--user-data-dir=/tmp/chrome --bwsi --incognito --login-user='$guest'
120 --login-profile=user`
121
122Signing in as a specific user is useful for debugging features like sync
123that require a logged in user.
124
Ben Pastene5764fdd62020-08-12 22:22:10125### Graphics notes
tfarina5b373372016-03-27 08:06:21126
tfarina5b373372016-03-27 08:06:21127The Chromium OS build requires a functioning GL so if you plan on
128testing it through Chromium Remote Desktop you might face drawing
129problems (e.g. Aura window not painting anything). Possible remedies:
130
Matt Giucad8cebe42018-01-09 04:37:46131* `--ui-enable-software-compositing --ui-disable-threaded-compositing`
Alexis Hetu3384f062018-08-27 18:30:44132* `--use-gl=swiftshader`, but it's slow.
tfarina5b373372016-03-27 08:06:21133
tfarina5b373372016-03-27 08:06:21134To more closely match the UI used on devices, you can install fonts used
135by Chrome OS, such as Roboto, on your Linux distro.
136
Ben Pastene5764fdd62020-08-12 22:22:10137## Chromium OS Device (Simple Chrome)
tfarina5b373372016-03-27 08:06:21138
Ben Pastene5764fdd62020-08-12 22:22:10139This configuration allows you to build a fully functional Chrome for a real
140Chrome OS device or VM. Since Chrome OS uses a different toolchain for each
141device model, you'll first need to know the name of the model (or "board") you
142want to build for. For most boards, `amd64-generic` and `arm-generic` will
143produce a functional binary, though it won't be optimized and may be missing
144functionality.
145
146### Additional gclient setup
147
148Each board has its own toolchain and misc. build dependencies. To fetch these,
149list the board under the `"cros_boards"` gclient custom var. If you were using
150the `amd64-generic` board, your `.gclient` file would look like:
151```
152solutions = [
153 {
154 "url": "https://chromium.googlesource.com/chromium/src.git",
155 "name": "src",
156 "custom_deps": {},
157 "custom_vars" : {
158 "cros_boards": "amd64-generic",
159 },
160 },
161]
162target_os = ["chromeos"]
163```
164Once your .gclient file is updated, you will need to run `gclient sync` again
165to fetch the toolchain.
166
167NOTE:
168 - If you'd like a VM image additionally downloaded for the board, add it to the
169 `"cros_boards_with_qemu_images"` gclient custom var. That var downloads the
170 SDK along with a VM image. `cros_boards` downloads only the SDK.
171 - If you'd like to fetch multiple boards, add a `:` between each board in the
172 gclient var. For example: `"cros_boards": "amd64-generic:arm-generic"`.
173
174### Building for the board
175
176After the needed toolchain has been downloaded for your ${BOARD}, a build dir
177will have been conveniently created for you at `out_$BOARD/Release`, which can
178then be used to build Chrome. For the `amd64-generic` board, this would
179look like:
180
181 $ gn gen out_amd64-generic/Release
182 $ autoninja -C out_$BOARD/Release chrome
183
184Or if you prefer to use your own build dir, simply add the following line to the
185top of your GN args: `import("//build/args/chromeos/amd64-generic.gni")`. eg:
186
187 $ gn gen out/Default --args='import("//build/args/chromeos/amd64-generic.gni")'
188 $ autoninja -C out/Default chrome
189
190That will produce a Chrome OS build of Chrome very similar to what is shipped
191for that device. You can also supply additional args or even overwrite ones
192supplied in the imported .gni file after the `import()` line.
193
194### Additional notes
195
196For more information (like copying the locally-built Chrome to a device, or
197running Tast tests), consult Simple Chrome's
198[full documentation](https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md).