blob: 39e589fb50ad8d7ef6e2cbf9c6cfffc059a5b34f [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).
Xiaohan Wang69ee4c02021-02-18 01:28:5913- Use `is_chromeos_device` in GN and `BUILDFLAG(IS_CHROMEOS_DEVICE)` in C++ code
14 to differentiate between these two modes.
Ben Pastene5764fdd62020-08-12 22:22:1015
16[TOC]
17
18## Common setup
tfarina5b373372016-03-27 08:06:2119
20First, follow the [normal Linux build
John Palmer046f9872021-05-24 01:24:5621instructions](https://chromium.googlesource.com/chromium/src/+/main/docs/linux/build_instructions.md)
tfarina5b373372016-03-27 08:06:2122as usual to get a Chromium checkout.
23
Ben Pastene5764fdd62020-08-12 22:22:1024You'll also need to add `'chromeos'` to the `target_os` list in your `.gclient`
25configuration, which will fetch the additional build dependencies required for
26CrOS. This file is located one level up from your Chromium checkout's `src`.
Ken Rockota21ef762018-05-02 04:02:3727
28If you don't already have a `target_os` line present, simply add this to the
29end of the `.gclient` file:
30
31 target_os = ['chromeos']
32
33If you already have a `target_os` line present in your `.gclient file`, you can
34simply append `'chromeos'` to the existing list there. For example:
35
36 target_os = ['android', 'chromeos']
37
38Once your `.gclient` file is updated, you will need to run `gclient sync` once
39before proceeding with the rest of these instructions.
40
Ben Pastene5764fdd62020-08-12 22:22:1041## Chromium OS on Linux (linux-chromeos)
42
43Chromium on Chromium OS uses Linux Chromium as a base, but adds a large number
44of Chrome OS-specific features to the code. For example, the login UI, window
45manager and system UI are part of the Chromium code base and built into the
46chrome binary.
47
48Fortunately, most Chromium changes that affect Chromium OS can be built and
49tested on a Linux workstation. This build is called "linux-chromeos". In this
50configuration most system services (like the power manager, bluetooth daemon,
51etc.) are stubbed out. The entire system UI runs in a single X11 window on your
52desktop.
53
Victor Hugo Vianna Silvabd1065a2021-04-29 15:10:4754You can test sign-in/sync in this mode by adding the --login-manager flag, see
55the [Login notes](#Login-notes) section.
56
Ben Pastene5764fdd62020-08-12 22:22:1057### Building and running Chromium with Chromium OS UI on your local machine
tfarina5b373372016-03-27 08:06:2158
James Cook4dca0792018-01-24 22:57:3459Run the following in your chromium checkout:
tfarina5b373372016-03-27 08:06:2160
stevenjbec7b4e3c2016-04-18 22:52:0261 $ gn gen out/Default --args='target_os="chromeos"'
James Cook4dca0792018-01-24 22:57:3462 $ autoninja -C out/Default chrome
Joel Hockey82e00622020-08-12 05:26:1163 $ out/Default/chrome --use-system-clipboard
stevenjbec7b4e3c2016-04-18 22:52:0264
Dirk Pranke8bd55f22018-10-24 21:22:1065(`autoninja` is a wrapper that automatically provides optimal values for the
66arguments passed to `ninja`).
67
Matt Giucad8cebe42018-01-09 04:37:4668Some additional options you may wish to set by passing in `--args` to `gn gen`
69or running `gn args out/Default`:
stevenjb89ee24b2016-04-19 19:26:4270
Oleh Lamzinae82b2e2023-10-05 08:22:4671 # Googlers: Reclient is a distributed compiler service. Goma successor.
72 use_remoteexec = true
73
James Cook4dca0792018-01-24 22:57:3474 is_component_build = true # Links faster.
75 is_debug = false # Release build, runs faster.
76 dcheck_always_on = true # Enables DCHECK despite release build.
77 enable_nacl = false # Skips native client build, compiles faster.
Jacob Dufaultbfef58b2018-01-12 22:39:4878
Satoru Takabayashi5f3b2ec2023-02-17 05:31:5379 # Builds Chrome instead of Chromium. This requires a src-internal
80 # checkout. Adds internal features and branded art assets.
81 is_chrome_branded = true
82
83 # Enables many optimizations, leading to much slower compiles, links,
84 # and no runtime stack traces.
Oleh Lamzinf8ef3408d32023-10-05 08:57:4085 #
86 # Note: not compatible with `is_component_build = true`.
Satoru Takabayashi5f3b2ec2023-02-17 05:31:5387 is_official_build = true
tfarina5b373372016-03-27 08:06:2188
James Cook4dca0792018-01-24 22:57:3489NOTE: You may wish to replace 'Default' with something like 'Cros' if
90you switch back and forth between Linux and Chromium OS builds, or 'Debug'
91if you want to differentiate between Debug and Release builds (see below).
92
93See [GN Build Configuration](https://www.chromium.org/developers/gn-build-configuration)
94for more information about configuring your build.
95
96You can also build and run test targets like `unit_tests`, `browser_tests`, etc.
97
Ben Pastene5764fdd62020-08-12 22:22:1098### Flags
Joel Hockey82e00622020-08-12 05:26:1199
100Some useful flags:
101
102* `--ash-debug-shortcuts`: Enable shortcuts such as Ctl+Alt+Shift+T to toggle
103 tablet mode.
104* `--ash-host-window-bounds="0+0-800x600,800+0-800x600"`: Specify one or more
105 virtual screens, by display position and size.
106* `--enable-features=Feature1,OtherFeature2`: Enable specified features.
107 Features are often listed in chrome://flags, or in source files such as
John Palmer046f9872021-05-24 01:24:56108 [chrome_features.cc](https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/chrome_features.cc)
109 or [ash_features.cc](https://source.chromium.org/chromium/chromium/src/+/main:ash/constants/ash_features.cc).
Joel Hockey82e00622020-08-12 05:26:11110 Note that changing values in chrome://flags does not work for
111 linux-chromeos, and this flag must be used.
112* `--enable-ui-devtools[=9223]`: Allow debugging of the system UI through
113 devtools either within linux-chromeos at chrome://inspect, or from a remote
114 browser at
115 devtools://devtools/bundled/devtools_app.html?uiDevTools=true&ws=127.0.0.1:9223/0
116* `--remote-debugging-port=9222`: Allow debugging through devtools at
117 http://localhost:9222
118* `--use-system-clipboard`: Integrate clipboard with the host X11 system.
119
Ben Pastene5764fdd62020-08-12 22:22:10120### Login notes
James Cook4dca0792018-01-24 22:57:34121
122By default this build signs in with a stub user. To specify a real user:
123
124* For first run, add the following options to chrome's command line:
125 `--user-data-dir=/tmp/chrome --login-manager`
126* Go through the out-of-the-box UX and sign in with a real Gmail account.
Victor Hugo Vianna Silvabd1065a2021-04-29 15:10:47127* For subsequent runs, if you want to skip the login manager page, add:
Toby H42fa2512019-06-13 18:09:39128 `--user-data-dir=/tmp/chrome [email protected]
Victor Hugo Vianna Silvabd1065a2021-04-29 15:10:47129 [email protected]`. It's also fine to just keep
130 --login-manager instead.
James Cook4dca0792018-01-24 22:57:34131* To run in guest mode instantly, add:
132 `--user-data-dir=/tmp/chrome --bwsi --incognito --login-user='$guest'
133 --login-profile=user`
134
135Signing in as a specific user is useful for debugging features like sync
136that require a logged in user.
137
Ben Pastene5764fdd62020-08-12 22:22:10138### Graphics notes
tfarina5b373372016-03-27 08:06:21139
tfarina5b373372016-03-27 08:06:21140The Chromium OS build requires a functioning GL so if you plan on
141testing it through Chromium Remote Desktop you might face drawing
142problems (e.g. Aura window not painting anything). Possible remedies:
143
Matt Giucad8cebe42018-01-09 04:37:46144* `--ui-enable-software-compositing --ui-disable-threaded-compositing`
Alexis Hetu8c54b0b72022-02-11 14:35:59145* `--use-gl=angle --use-angle=swiftshader`, but it's slow.
tfarina5b373372016-03-27 08:06:21146
tfarina5b373372016-03-27 08:06:21147To more closely match the UI used on devices, you can install fonts used
148by Chrome OS, such as Roboto, on your Linux distro.
149
Ben Pastene5764fdd62020-08-12 22:22:10150## Chromium OS Device (Simple Chrome)
tfarina5b373372016-03-27 08:06:21151
Ben Pastene5764fdd62020-08-12 22:22:10152This configuration allows you to build a fully functional Chrome for a real
153Chrome OS device or VM. Since Chrome OS uses a different toolchain for each
154device model, you'll first need to know the name of the model (or "board") you
155want to build for. For most boards, `amd64-generic` and `arm-generic` will
156produce a functional binary, though it won't be optimized and may be missing
157functionality.
158
159### Additional gclient setup
160
161Each board has its own toolchain and misc. build dependencies. To fetch these,
162list the board under the `"cros_boards"` gclient custom var. If you were using
163the `amd64-generic` board, your `.gclient` file would look like:
164```
165solutions = [
166 {
167 "url": "https://chromium.googlesource.com/chromium/src.git",
168 "name": "src",
169 "custom_deps": {},
170 "custom_vars" : {
171 "cros_boards": "amd64-generic",
172 },
173 },
174]
175target_os = ["chromeos"]
176```
177Once your .gclient file is updated, you will need to run `gclient sync` again
178to fetch the toolchain.
179
180NOTE:
181 - If you'd like a VM image additionally downloaded for the board, add it to the
182 `"cros_boards_with_qemu_images"` gclient custom var. That var downloads the
183 SDK along with a VM image. `cros_boards` downloads only the SDK.
184 - If you'd like to fetch multiple boards, add a `:` between each board in the
185 gclient var. For example: `"cros_boards": "amd64-generic:arm-generic"`.
186
187### Building for the board
188
189After the needed toolchain has been downloaded for your ${BOARD}, a build dir
190will have been conveniently created for you at `out_$BOARD/Release`, which can
191then be used to build Chrome. For the `amd64-generic` board, this would
192look like:
193
194 $ gn gen out_amd64-generic/Release
195 $ autoninja -C out_$BOARD/Release chrome
196
197Or if you prefer to use your own build dir, simply add the following line to the
198top of your GN args: `import("//build/args/chromeos/amd64-generic.gni")`. eg:
199
200 $ gn gen out/Default --args='import("//build/args/chromeos/amd64-generic.gni")'
201 $ autoninja -C out/Default chrome
202
203That will produce a Chrome OS build of Chrome very similar to what is shipped
204for that device. You can also supply additional args or even overwrite ones
205supplied in the imported .gni file after the `import()` line.
206
207### Additional notes
208
209For more information (like copying the locally-built Chrome to a device, or
210running Tast tests), consult Simple Chrome's
John Palmer046f9872021-05-24 01:24:56211[full documentation](https://chromium.googlesource.com/chromiumos/docs/+/main/simple_chrome_workflow.md).