blob: bbbed6c7c7b08fafa1d43c832efcb6b3fb4433ee [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
Ho Cheungb5be7472025-03-07 08:18:5771 # Reclient is a distributed compiler service that is only available to
72 # Googlers and contributors who have access to Reclient.
Oleh Lamzinae82b2e2023-10-05 08:22:4673 use_remoteexec = true
74
James Cook4dca0792018-01-24 22:57:3475 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 Dufaultbfef58b2018-01-12 22:39:4879
Satoru Takabayashi5f3b2ec2023-02-17 05:31:5380 # 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 Lamzinf8ef3408d32023-10-05 08:57:4086 #
87 # Note: not compatible with `is_component_build = true`.
Satoru Takabayashi5f3b2ec2023-02-17 05:31:5388 is_official_build = true
tfarina5b373372016-03-27 08:06:2189
Ho Cheungb5be7472025-03-07 08:18:5790NOTE:
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 Cook4dca0792018-01-24 22:57:3494
Ho Cheungb5be7472025-03-07 08:18:5795 - See [GN Build
96 Configuration](https://www.chromium.org/developers/gn-build-configuration)
97 for more information about configuring your build.
James Cook4dca0792018-01-24 22:57:3498
Ho Cheungb5be7472025-03-07 08:18:5799 - 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 Cook4dca0792018-01-24 22:57:34106
Ben Pastene5764fdd62020-08-12 22:22:10107### Flags
Joel Hockey82e00622020-08-12 05:26:11108
109Some 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 Palmer046f9872021-05-24 01:24:56117 [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 Hockey82e00622020-08-12 05:26:11119 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 Pastene5764fdd62020-08-12 22:22:10129### Login notes
James Cook4dca0792018-01-24 22:57:34130
131By 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 Silvabd1065a2021-04-29 15:10:47136* For subsequent runs, if you want to skip the login manager page, add:
Toby H42fa2512019-06-13 18:09:39137 `--user-data-dir=/tmp/chrome --login-user=username@gmail.com
Victor Hugo Vianna Silvabd1065a2021-04-29 15:10:47138 --login-profile=username@gmail.com-hash`. It's also fine to just keep
139 --login-manager instead.
James Cook4dca0792018-01-24 22:57:34140* To run in guest mode instantly, add:
141 `--user-data-dir=/tmp/chrome --bwsi --incognito --login-user='$guest'
142 --login-profile=user`
143
144Signing in as a specific user is useful for debugging features like sync
145that require a logged in user.
146
Ben Pastene5764fdd62020-08-12 22:22:10147### Graphics notes
tfarina5b373372016-03-27 08:06:21148
tfarina5b373372016-03-27 08:06:21149The Chromium OS build requires a functioning GL so if you plan on
150testing it through Chromium Remote Desktop you might face drawing
151problems (e.g. Aura window not painting anything). Possible remedies:
152
Matt Giucad8cebe42018-01-09 04:37:46153* `--ui-enable-software-compositing --ui-disable-threaded-compositing`
Alexis Hetu8c54b0b72022-02-11 14:35:59154* `--use-gl=angle --use-angle=swiftshader`, but it's slow.
tfarina5b373372016-03-27 08:06:21155
tfarina5b373372016-03-27 08:06:21156To more closely match the UI used on devices, you can install fonts used
157by Chrome OS, such as Roboto, on your Linux distro.
158
Ben Pastene5764fdd62020-08-12 22:22:10159## Chromium OS Device (Simple Chrome)
tfarina5b373372016-03-27 08:06:21160
Ben Pastene5764fdd62020-08-12 22:22:10161This configuration allows you to build a fully functional Chrome for a real
162Chrome OS device or VM. Since Chrome OS uses a different toolchain for each
163device model, you'll first need to know the name of the model (or "board") you
164want to build for. For most boards, `amd64-generic` and `arm-generic` will
165produce a functional binary, though it won't be optimized and may be missing
166functionality.
167
168### Additional gclient setup
169
170Each board has its own toolchain and misc. build dependencies. To fetch these,
171list the board under the `"cros_boards"` gclient custom var. If you were using
172the `amd64-generic` board, your `.gclient` file would look like:
173```
174solutions = [
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]
184target_os = ["chromeos"]
185```
186Once your .gclient file is updated, you will need to run `gclient sync` again
187to fetch the toolchain.
188
189NOTE:
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
198After the needed toolchain has been downloaded for your ${BOARD}, a build dir
199will have been conveniently created for you at `out_$BOARD/Release`, which can
200then be used to build Chrome. For the `amd64-generic` board, this would
201look like:
202
203 $ gn gen out_amd64-generic/Release
204 $ autoninja -C out_$BOARD/Release chrome
205
206Or if you prefer to use your own build dir, simply add the following line to the
207top 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
212That will produce a Chrome OS build of Chrome very similar to what is shipped
213for that device. You can also supply additional args or even overwrite ones
214supplied in the imported .gni file after the `import()` line.
215
216### Additional notes
217
218For more information (like copying the locally-built Chrome to a device, or
219running Tast tests), consult Simple Chrome's
John Palmer046f9872021-05-24 01:24:56220[full documentation](https://chromium.googlesource.com/chromiumos/docs/+/main/simple_chrome_workflow.md).