blob: d68b16c8ea3fb914134cac8d4eb7baf52e626ffa [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.
85 is_official_build = true
tfarina5b373372016-03-27 08:06:2186
James Cook4dca0792018-01-24 22:57:3487NOTE: You may wish to replace 'Default' with something like 'Cros' if
88you switch back and forth between Linux and Chromium OS builds, or 'Debug'
89if you want to differentiate between Debug and Release builds (see below).
90
91See [GN Build Configuration](https://www.chromium.org/developers/gn-build-configuration)
92for more information about configuring your build.
93
94You can also build and run test targets like `unit_tests`, `browser_tests`, etc.
95
Ben Pastene5764fdd62020-08-12 22:22:1096### Flags
Joel Hockey82e00622020-08-12 05:26:1197
98Some useful flags:
99
100* `--ash-debug-shortcuts`: Enable shortcuts such as Ctl+Alt+Shift+T to toggle
101 tablet mode.
102* `--ash-host-window-bounds="0+0-800x600,800+0-800x600"`: Specify one or more
103 virtual screens, by display position and size.
104* `--enable-features=Feature1,OtherFeature2`: Enable specified features.
105 Features are often listed in chrome://flags, or in source files such as
John Palmer046f9872021-05-24 01:24:56106 [chrome_features.cc](https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/chrome_features.cc)
107 or [ash_features.cc](https://source.chromium.org/chromium/chromium/src/+/main:ash/constants/ash_features.cc).
Joel Hockey82e00622020-08-12 05:26:11108 Note that changing values in chrome://flags does not work for
109 linux-chromeos, and this flag must be used.
110* `--enable-ui-devtools[=9223]`: Allow debugging of the system UI through
111 devtools either within linux-chromeos at chrome://inspect, or from a remote
112 browser at
113 devtools://devtools/bundled/devtools_app.html?uiDevTools=true&ws=127.0.0.1:9223/0
114* `--remote-debugging-port=9222`: Allow debugging through devtools at
115 http://localhost:9222
116* `--use-system-clipboard`: Integrate clipboard with the host X11 system.
117
Ben Pastene5764fdd62020-08-12 22:22:10118### Login notes
James Cook4dca0792018-01-24 22:57:34119
120By default this build signs in with a stub user. To specify a real user:
121
122* For first run, add the following options to chrome's command line:
123 `--user-data-dir=/tmp/chrome --login-manager`
124* Go through the out-of-the-box UX and sign in with a real Gmail account.
Victor Hugo Vianna Silvabd1065a2021-04-29 15:10:47125* For subsequent runs, if you want to skip the login manager page, add:
Toby H42fa2512019-06-13 18:09:39126 `--user-data-dir=/tmp/chrome [email protected]
Victor Hugo Vianna Silvabd1065a2021-04-29 15:10:47127 [email protected]`. It's also fine to just keep
128 --login-manager instead.
James Cook4dca0792018-01-24 22:57:34129* To run in guest mode instantly, add:
130 `--user-data-dir=/tmp/chrome --bwsi --incognito --login-user='$guest'
131 --login-profile=user`
132
133Signing in as a specific user is useful for debugging features like sync
134that require a logged in user.
135
Ben Pastene5764fdd62020-08-12 22:22:10136### Graphics notes
tfarina5b373372016-03-27 08:06:21137
tfarina5b373372016-03-27 08:06:21138The Chromium OS build requires a functioning GL so if you plan on
139testing it through Chromium Remote Desktop you might face drawing
140problems (e.g. Aura window not painting anything). Possible remedies:
141
Matt Giucad8cebe42018-01-09 04:37:46142* `--ui-enable-software-compositing --ui-disable-threaded-compositing`
Alexis Hetu8c54b0b72022-02-11 14:35:59143* `--use-gl=angle --use-angle=swiftshader`, but it's slow.
tfarina5b373372016-03-27 08:06:21144
tfarina5b373372016-03-27 08:06:21145To more closely match the UI used on devices, you can install fonts used
146by Chrome OS, such as Roboto, on your Linux distro.
147
Ben Pastene5764fdd62020-08-12 22:22:10148## Chromium OS Device (Simple Chrome)
tfarina5b373372016-03-27 08:06:21149
Ben Pastene5764fdd62020-08-12 22:22:10150This configuration allows you to build a fully functional Chrome for a real
151Chrome OS device or VM. Since Chrome OS uses a different toolchain for each
152device model, you'll first need to know the name of the model (or "board") you
153want to build for. For most boards, `amd64-generic` and `arm-generic` will
154produce a functional binary, though it won't be optimized and may be missing
155functionality.
156
157### Additional gclient setup
158
159Each board has its own toolchain and misc. build dependencies. To fetch these,
160list the board under the `"cros_boards"` gclient custom var. If you were using
161the `amd64-generic` board, your `.gclient` file would look like:
162```
163solutions = [
164 {
165 "url": "https://chromium.googlesource.com/chromium/src.git",
166 "name": "src",
167 "custom_deps": {},
168 "custom_vars" : {
169 "cros_boards": "amd64-generic",
170 },
171 },
172]
173target_os = ["chromeos"]
174```
175Once your .gclient file is updated, you will need to run `gclient sync` again
176to fetch the toolchain.
177
178NOTE:
179 - If you'd like a VM image additionally downloaded for the board, add it to the
180 `"cros_boards_with_qemu_images"` gclient custom var. That var downloads the
181 SDK along with a VM image. `cros_boards` downloads only the SDK.
182 - If you'd like to fetch multiple boards, add a `:` between each board in the
183 gclient var. For example: `"cros_boards": "amd64-generic:arm-generic"`.
184
185### Building for the board
186
187After the needed toolchain has been downloaded for your ${BOARD}, a build dir
188will have been conveniently created for you at `out_$BOARD/Release`, which can
189then be used to build Chrome. For the `amd64-generic` board, this would
190look like:
191
192 $ gn gen out_amd64-generic/Release
193 $ autoninja -C out_$BOARD/Release chrome
194
195Or if you prefer to use your own build dir, simply add the following line to the
196top of your GN args: `import("//build/args/chromeos/amd64-generic.gni")`. eg:
197
198 $ gn gen out/Default --args='import("//build/args/chromeos/amd64-generic.gni")'
199 $ autoninja -C out/Default chrome
200
201That will produce a Chrome OS build of Chrome very similar to what is shipped
202for that device. You can also supply additional args or even overwrite ones
203supplied in the imported .gni file after the `import()` line.
204
205### Additional notes
206
207For more information (like copying the locally-built Chrome to a device, or
208running Tast tests), consult Simple Chrome's
John Palmer046f9872021-05-24 01:24:56209[full documentation](https://chromium.googlesource.com/chromiumos/docs/+/main/simple_chrome_workflow.md).