blob: b63990de6e5e8fb22ee7a3534da5627b050537bc [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.
Ben Wagner70155892020-08-21 00:48:1071 use_sysroot = false # Build for local machine instead of sysroot.
Jacob Dufaultbfef58b2018-01-12 22:39:4872
73 # Set the following true to create a Chrome (instead of Chromium) build.
James Cook4dca0792018-01-24 22:57:3474 # 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.
tfarina5b373372016-03-27 08:06:2177
James Cook4dca0792018-01-24 22:57:3478NOTE: You may wish to replace 'Default' with something like 'Cros' if
79you switch back and forth between Linux and Chromium OS builds, or 'Debug'
80if you want to differentiate between Debug and Release builds (see below).
81
82See [GN Build Configuration](https://www.chromium.org/developers/gn-build-configuration)
83for more information about configuring your build.
84
85You can also build and run test targets like `unit_tests`, `browser_tests`, etc.
86
Ben Pastene5764fdd62020-08-12 22:22:1087### Flags
Joel Hockey82e00622020-08-12 05:26:1188
89Some 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 Ferreiroadddf4b2021-02-06 07:13:5698 or [ash_features.cc](https://source.chromium.org/chromium/chromium/src/+/master:ash/constants/ash_features.cc).
Joel Hockey82e00622020-08-12 05:26:1199 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 Pastene5764fdd62020-08-12 22:22:10109### Login notes
James Cook4dca0792018-01-24 22:57:34110
111By 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 H42fa2512019-06-13 18:09:39117 `--user-data-dir=/tmp/chrome [email protected]
118 [email protected]`
James Cook4dca0792018-01-24 22:57:34119* To run in guest mode instantly, add:
120 `--user-data-dir=/tmp/chrome --bwsi --incognito --login-user='$guest'
121 --login-profile=user`
122
123Signing in as a specific user is useful for debugging features like sync
124that require a logged in user.
125
Ben Pastene5764fdd62020-08-12 22:22:10126### Graphics notes
tfarina5b373372016-03-27 08:06:21127
tfarina5b373372016-03-27 08:06:21128The Chromium OS build requires a functioning GL so if you plan on
129testing it through Chromium Remote Desktop you might face drawing
130problems (e.g. Aura window not painting anything). Possible remedies:
131
Matt Giucad8cebe42018-01-09 04:37:46132* `--ui-enable-software-compositing --ui-disable-threaded-compositing`
Alexis Hetu3384f062018-08-27 18:30:44133* `--use-gl=swiftshader`, but it's slow.
tfarina5b373372016-03-27 08:06:21134
tfarina5b373372016-03-27 08:06:21135To more closely match the UI used on devices, you can install fonts used
136by Chrome OS, such as Roboto, on your Linux distro.
137
Ben Pastene5764fdd62020-08-12 22:22:10138## Chromium OS Device (Simple Chrome)
tfarina5b373372016-03-27 08:06:21139
Ben Pastene5764fdd62020-08-12 22:22:10140This configuration allows you to build a fully functional Chrome for a real
141Chrome OS device or VM. Since Chrome OS uses a different toolchain for each
142device model, you'll first need to know the name of the model (or "board") you
143want to build for. For most boards, `amd64-generic` and `arm-generic` will
144produce a functional binary, though it won't be optimized and may be missing
145functionality.
146
147### Additional gclient setup
148
149Each board has its own toolchain and misc. build dependencies. To fetch these,
150list the board under the `"cros_boards"` gclient custom var. If you were using
151the `amd64-generic` board, your `.gclient` file would look like:
152```
153solutions = [
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]
163target_os = ["chromeos"]
164```
165Once your .gclient file is updated, you will need to run `gclient sync` again
166to fetch the toolchain.
167
168NOTE:
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
177After the needed toolchain has been downloaded for your ${BOARD}, a build dir
178will have been conveniently created for you at `out_$BOARD/Release`, which can
179then be used to build Chrome. For the `amd64-generic` board, this would
180look like:
181
182 $ gn gen out_amd64-generic/Release
183 $ autoninja -C out_$BOARD/Release chrome
184
185Or if you prefer to use your own build dir, simply add the following line to the
186top 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
191That will produce a Chrome OS build of Chrome very similar to what is shipped
192for that device. You can also supply additional args or even overwrite ones
193supplied in the imported .gni file after the `import()` line.
194
195### Additional notes
196
197For more information (like copying the locally-built Chrome to a device, or
198running Tast tests), consult Simple Chrome's
199[full documentation](https://chromium.googlesource.com/chromiumos/docs/+/master/simple_chrome_workflow.md).