blob: 2415546108a666129c6cd64d5b8fe01312b8df83 [file] [log] [blame] [view]
dpranke0ae7cad2016-11-30 07:47:581# Checking out and building Chromium on Linux
andybons3322f762015-08-24 21:37:092
Victor Costan44af72b2017-11-13 20:01:303There are instructions for other platforms linked from the
Nicolas Norvezba040062020-01-15 01:17:264[get the code](../get_the_code.md) page.
dpranke1a70d0c2016-12-01 02:42:295
dpranke1a70d0c2016-12-01 02:42:296## Instructions for Google Employees
7
8Are you a Google employee? See
9[go/building-chrome](https://goto.google.com/building-chrome) instead.
andybons8c02a1f2015-09-04 17:02:3210
dpranke0ae7cad2016-11-30 07:47:5811[TOC]
andybonsad92aa32015-08-31 02:27:4412
dpranke0ae7cad2016-11-30 07:47:5813## System requirements
andybonsad92aa32015-08-31 02:27:4414
Bruce Dawsonc2661722024-06-12 19:44:2915* An x86-64 machine with at least 8GB of RAM. More than 16GB is highly
Omar Shawky971848ce2024-04-17 21:47:3016 recommended. If your machine has an SSD, it is recommended to have
17 \>=32GB/>=16GB of swap for machines with 8GB/16GB of RAM respectively.
18* At least 100GB of free disk space. It does not have to be on the same drive;
19 Allocate ~50-80GB on HDD for build.
zhoupeng6ebd49d2025-04-03 20:45:0020* You must have Git and Python v3.9+ installed already (and `python3` must point
21 to a Python v3.9+ binary). Depot_tools bundles an appropriate version
Dirk Pranke8766b622c2023-08-30 23:19:3622 of Python in `$depot_tools/python-bin`, if you don't have an appropriate
23 version already on your system.
Junji Watanabedab18d132025-04-09 04:04:0124* Chromium's build infrastructure and `depot_tools` currently use Python 3.11.
25 If something is broken with an older Python version, feel free to report or
26 send us fixes.
Peter Kastingbeb265c2024-10-31 20:22:5627* `libc++` is currently the only supported STL. `clang` is the only
28 officially-supported compiler, though external community members generally
29 keep things building with `gcc`. For more details, see the
30 [supported toolchains doc](../toolchain_support.md).
Ben Pastened89a45b2023-06-28 22:57:3431
32Most development is done on Ubuntu (Chromium's build infrastructure currently
33runs 22.04, Jammy Jellyfish). There are some instructions for other distros
Omar Shawky08b259c2024-03-27 19:52:1734below, but they are mostly unsupported, but installation instructions can be found in [Docker](#docker).
andybons3322f762015-08-24 21:37:0935
dpranke0ae7cad2016-11-30 07:47:5836## Install `depot_tools`
andybonsad92aa32015-08-31 02:27:4437
sdy93387fa2016-12-01 01:03:4438Clone the `depot_tools` repository:
andybons3322f762015-08-24 21:37:0939
sdy93387fa2016-12-01 01:03:4440```shell
41$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
42```
andybonsad92aa32015-08-31 02:27:4443
mark a. foltz89670afb2023-08-20 18:14:0744Add `depot_tools` to the beginning of your `PATH` (you will probably want to put
45this in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
sdy93387fa2016-12-01 01:03:4446`/path/to/depot_tools`:
andybonsad92aa32015-08-31 02:27:4447
sdy93387fa2016-12-01 01:03:4448```shell
mark a. foltz89670afb2023-08-20 18:14:0749$ export PATH="/path/to/depot_tools:$PATH"
sdy93387fa2016-12-01 01:03:4450```
andybons3322f762015-08-24 21:37:0951
Claudio DeSouzaae44ac12018-02-13 16:11:4552When cloning `depot_tools` to your home directory **do not** use `~` on PATH,
53otherwise `gclient runhooks` will fail to run. Rather, you should use either
54`$HOME` or the absolute path:
55
56```shell
mark a. foltz89670afb2023-08-20 18:14:0757$ export PATH="${HOME}/depot_tools:$PATH"
Claudio DeSouzaae44ac12018-02-13 16:11:4558```
59
dpranke0ae7cad2016-11-30 07:47:5860## Get the code
andybonsad92aa32015-08-31 02:27:4461
sdy93387fa2016-12-01 01:03:4462Create a `chromium` directory for the checkout and change to it (you can call
63this whatever you like and put it wherever you like, as long as the full path
64has no spaces):
65
66```shell
67$ mkdir ~/chromium && cd ~/chromium
68```
andybons3322f762015-08-24 21:37:0969
dpranke0ae7cad2016-11-30 07:47:5870Run the `fetch` tool from depot_tools to check out the code and its
71dependencies.
andybonsad92aa32015-08-31 02:27:4472
sdy93387fa2016-12-01 01:03:4473```shell
74$ fetch --nohooks chromium
75```
andybonsad92aa32015-08-31 02:27:4476
Delan Azabani43eefa3d2024-05-09 03:39:3377*** note
78**NixOS users:** tools like `fetch` won’t work without a Nix shell. Clone [the
79tools repo](https://chromium.googlesource.com/chromium/src/tools) with `git`,
80then run `nix-shell tools/nix/shell.nix`.
81***
82
dpranke0ae7cad2016-11-30 07:47:5883If you don't want the full repo history, you can save a lot of time by
sdy93387fa2016-12-01 01:03:4484adding the `--no-history` flag to `fetch`.
andybons3322f762015-08-24 21:37:0985
dpranke0ae7cad2016-11-30 07:47:5886Expect the command to take 30 minutes on even a fast connection, and many
87hours on slower ones.
andybonsad92aa32015-08-31 02:27:4488
dpranke0ae7cad2016-11-30 07:47:5889If you've already installed the build dependencies on the machine (from another
sdy93387fa2016-12-01 01:03:4490checkout, for example), you can omit the `--nohooks` flag and `fetch`
dpranke0ae7cad2016-11-30 07:47:5891will automatically execute `gclient runhooks` at the end.
andybons3322f762015-08-24 21:37:0992
sdy93387fa2016-12-01 01:03:4493When `fetch` completes, it will have created a hidden `.gclient` file and a
94directory called `src` in the working directory. The remaining instructions
95assume you have switched to the `src` directory:
andybons3322f762015-08-24 21:37:0996
sdy93387fa2016-12-01 01:03:4497```shell
98$ cd src
99```
andybons3322f762015-08-24 21:37:09100
dpranke0ae7cad2016-11-30 07:47:58101### Install additional build dependencies
andybons3322f762015-08-24 21:37:09102
dpranke0ae7cad2016-11-30 07:47:58103Once you have checked out the code, and assuming you're using Ubuntu, run
104[build/install-build-deps.sh](/build/install-build-deps.sh)
andybons3322f762015-08-24 21:37:09105
Aaron Gable3bc93682019-01-11 02:16:07106```shell
107$ ./build/install-build-deps.sh
108```
109
dpranke2989a782016-12-02 02:57:12110You may need to adjust the build dependencies for other distros. There are
Omar Shawky971848ce2024-04-17 21:47:30111some [notes](#notes-for-other-distros) at the end of this document, but we make no guarantees
dpranke2989a782016-12-02 02:57:12112for their accuracy.
andybonsad92aa32015-08-31 02:27:44113
dpranke0ae7cad2016-11-30 07:47:58114### Run the hooks
andybons3322f762015-08-24 21:37:09115
dpranke0ae7cad2016-11-30 07:47:58116Once you've run `install-build-deps` at least once, you can now run the
sdy93387fa2016-12-01 01:03:44117Chromium-specific hooks, which will download additional binaries and other
dpranke0ae7cad2016-11-30 07:47:58118things you might need:
andybonsad92aa32015-08-31 02:27:44119
sdy93387fa2016-12-01 01:03:44120```shell
121$ gclient runhooks
122```
andybonsad92aa32015-08-31 02:27:44123
sdy93387fa2016-12-01 01:03:44124*Optional*: You can also [install API
125keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
126build to talk to some Google services, but this is not necessary for most
127development and testing purposes.
andybons3322f762015-08-24 21:37:09128
dpranke1a70d0c2016-12-01 02:42:29129## Setting up the build
andybonsad92aa32015-08-31 02:27:44130
Richard Wang01a391712025-08-21 06:37:10131Chromium uses [Siso](https://pkg.go.dev/go.chromium.org/build/siso#section-readme)
Fumitoshi Ukaic9f326d2025-04-24 01:06:28132as its main build tool along with
Andrew Williamsbbc1a1e2021-07-21 01:51:22133a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md)
Tom Bridgwatereef401542018-08-17 00:54:43134to generate `.ninja` files. You can create any number of *build directories*
135with different configurations. To create a build directory, run:
andybons8c02a1f2015-09-04 17:02:32136
sdy93387fa2016-12-01 01:03:44137```shell
138$ gn gen out/Default
139```
dpranke0ae7cad2016-11-30 07:47:58140
Fumitoshi Ukaic9f326d2025-04-24 01:06:28141* You only have to run this once for each new build directory, Siso will
sdy93387fa2016-12-01 01:03:44142 update the build files as needed.
143* You can replace `Default` with another name, but
144 it should be a subdirectory of `out`.
145* For other build arguments, including release settings, see [GN build
146 configuration](https://www.chromium.org/developers/gn-build-configuration).
dpranke0ae7cad2016-11-30 07:47:58147 The default will be a debug component build matching the current host
148 operating system and CPU.
149* For more info on GN, run `gn help` on the command line or read the
Andrew Williamsbbc1a1e2021-07-21 01:51:22150 [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md).
dpranke0ae7cad2016-11-30 07:47:58151
Omar Shawky971848ce2024-04-17 21:47:30152### Faster builds
dpranke0ae7cad2016-11-30 07:47:58153
dpranke2989a782016-12-02 02:57:12154This section contains some things you can change to speed up your builds,
155sorted so that the things that make the biggest difference are first.
156
Fumitoshi Ukai334658572025-04-09 00:59:30157#### Use Remote Execution
Takuto Ikuta66f5de82023-09-08 03:55:44158
Takuto Ikuta776547282023-11-10 01:42:33159*** note
Philipp Wollermann43f9cb82023-11-27 05:33:19160**Warning:** If you are a Google employee, do not follow the instructions below.
Andrew Williams54da9cc2024-01-09 17:32:23161See
Fumitoshi Ukai633b1c72025-06-30 09:08:00162[go/chrome-linux-build#set-up-remote-execution](https://goto.google.com/chrome-linux-build#set-up-remote-execution)
Philipp Wollermann43f9cb82023-11-27 05:33:19163instead.
Takuto Ikuta776547282023-11-10 01:42:33164***
165
Philipp Wollermann43f9cb82023-11-27 05:33:19166Chromium's build can be sped up significantly by using a remote execution system
167compatible with [REAPI](https://github.com/bazelbuild/remote-apis). This allows
168you to benefit from remote caching and executing many build actions in parallel
169on a shared cluster of workers.
Fumitoshi Ukai8c123e92025-04-23 06:06:44170Chromium's build uses a client developed by Google called
Richard Wang01a391712025-08-21 06:37:10171[Siso](https://pkg.go.dev/go.chromium.org/build/siso#section-readme)
Fumitoshi Ukai8c123e92025-04-23 06:06:44172to remotely execute build actions.
Philipp Wollermann43f9cb82023-11-27 05:33:19173
Fumitoshi Ukai8c123e92025-04-23 06:06:44174To get started, you need access to an REAPI-compatible backend.
175
Fumitoshi Ukaid65112d72025-09-02 01:43:53176##### Google RBE
177
Fumitoshi Ukai8c123e92025-04-23 06:06:44178The following instructions assume that you received an invitation from Google
Fumitoshi Ukaid65112d72025-09-02 01:43:53179to use Chromium's Google RBE service and were granted access to it.
180Otherwise, see [non Google RBE](#non-google-rbe) instead.
181
Takuto Ikuta1b118a82023-11-28 05:55:25182For contributors who have
183[tryjob access](https://www.chromium.org/getting-involved/become-a-committer/#try-job-access)
184, please ask a Googler to email accounts@chromium.org on your behalf to access
Fumitoshi Ukai8c123e92025-04-23 06:06:44185RBE backend paid by Google. Note that remote execution for external
186contributors is a best-effort process. We do not guarantee when you will be
187invited.
Takuto Ikuta1b118a82023-11-28 05:55:25188
Fumitoshi Ukai8c123e92025-04-23 06:06:44189If you would like to use `siso` with Google's RBE,
Fumitoshi Ukai334658572025-04-09 00:59:30190you'll first need to:
Philipp Wollermann43f9cb82023-11-27 05:33:19191
Fumitoshi Ukai334658572025-04-09 00:59:301921. Run `siso login` and login with your authorized account.
Fumitoshi Ukai349627a2025-08-08 02:15:16193If it is blocked in OAuth2 flow, run `gcloud auth login` (and
194export environment variable `SISO_CREDENTIAL_HELPER=gcloud`
195since siso v1.3.12).
Philipp Wollermann43f9cb82023-11-27 05:33:19196
197Next, you'll have to specify your `rbe_instance` in your `.gclient`
198configuration to use the correct one for Chromium contributors:
199
Michael Savigny95600992024-04-10 13:59:10200*** note
201**Warning:** If you are a Google employee, do not follow the instructions below.
202See
Fumitoshi Ukai633b1c72025-06-30 09:08:00203[go/chrome-linux-build#set-up-remote-execution](https://goto.google.com/chrome-linux-build#set-up-remote-execution)
Michael Savigny95600992024-04-10 13:59:10204instead.
205***
206
Takuto Ikuta66f5de82023-09-08 03:55:44207```
208solutions = [
209 {
210 ...,
211 "custom_vars": {
Philipp Wollermann43f9cb82023-11-27 05:33:19212 # This is the correct instance name for using Chromium's RBE service.
213 # You can only use it if you were granted access to it. If you use your
Fumitoshi Ukaid65112d72025-09-02 01:43:53214 # own REAPI-compatible backend, you will need to set reapi_address,
215 # reapi_instance and reapi_backend_config_path instead.
216 # see [non Google RBE](#non-google-rbe) below.
Philipp Wollermann43f9cb82023-11-27 05:33:19217 "rbe_instance": "projects/rbe-chromium-untrusted/instances/default_instance",
Takuto Ikuta66f5de82023-09-08 03:55:44218 },
219 },
220]
221```
Philipp Wollermann43f9cb82023-11-27 05:33:19222
Fumitoshi Ukaid65112d72025-09-02 01:43:53223And run `gclient sync`. This will regenerate the config files in
224`build/config/siso/.sisoenv` and
225`build/config/siso/backend_config/backend.star` to use the Google RBE
226that you just added to your `.gclient` file.
227
228##### non Google RBE
229
230For others who have no access to Google's RBE backends, you are welcome
231to use any of the
232[other compatible backends](https://github.com/bazelbuild/remote-apis#servers),
233in which case you will have to adapt the following instructions regarding the
234authentication method, instance name, etc. to work with your backend.
235
236- If it is in closed network and no authentication, export environment variable
237`RBE_service_no_security=true`.
238- If it uses mTLS, export environment variable `RBE_tls_client_auth_key` and
239`RBE_tls_client_auth_cert`.
Fumitoshi Ukai8befc28b2025-09-03 01:49:20240- If it uses Google OAuth2, you may use `gcloud`. run `gcloud auth login`
Fumitoshi Ukaid65112d72025-09-02 01:43:53241 (and export environment variable `SISO_CREDENTIAL_HELPER=gcloud` since
242 siso v1.3.12).
243- Otherwise, you may need to use your own
244 [credential helper](https://github.com/EngFlow/credential-helper-spec/blob/main/spec.md).
245 export environment variable
246 `SISO_CREDENTIAL_HELPER=/path/to/your/credhelper`.
247
248For own REAPI backend other than Google RBE, you need to prepare own
249backend.star.
250
251e.g. for backend with no large worker pool
252```
253load("@builtin//struct.star", "module")
254
255def __platform_properties(ctx):
Fumitoshi Ukai3901d6b2025-09-02 07:06:51256 # fyi: this image is created by
257 # https://chromium.googlesource.com/infra/infra/+/refs/heads/main/rbe/images/siso-chromium/linux/Dockerfile
Fumitoshi Ukaid65112d72025-09-02 01:43:53258 container_image = "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:d7cb1ab14a0f20aa669c23f22c15a9dead761dcac19f43985bf9dd5f41fbef3a"
259 return {
260 "default": {
Fumitoshi Ukai3901d6b2025-09-02 07:06:51261 # set platform properties for your worker.
262 # it depends on how you configure your workers.
Fumitoshi Ukaid65112d72025-09-02 01:43:53263 "OSFamily": "Linux",
264 "container-image": container_image,
Fumitoshi Ukai3901d6b2025-09-02 07:06:51265 # e.g. to use worker in worker pool "linux_x64".
266 # "Pool": "linux_x64",
Fumitoshi Ukaid65112d72025-09-02 01:43:53267 },
Fumitoshi Ukai3901d6b2025-09-02 07:06:51268 # no Large workers. empty platform properties will run locally.
Fumitoshi Ukaid65112d72025-09-02 01:43:53269 "large": {},
270 }
271
272backend = module(
273 "backend",
274 platform_properties = __platform_properties,
275)
276```
277See
Fumitoshi Ukai3901d6b2025-09-02 07:06:51278[build/config/siso/backend_config/README.md](../../build/config/siso/backend_config/README.md),
279[remote apis platform lexicon](https://github.com/bazelbuild/remote-apis/blob/main/build/bazel/remote/execution/v2/platform.md).
280Also check your REAPI documentations.
Fumitoshi Ukaid65112d72025-09-02 01:43:53281
282Set `reapi_address`, `reapi_instance` and `reapi_backend_config_path` which
283is the path name for the your backend.star above.
Fumitoshi Ukaidd41b9032025-08-12 05:23:46284
285```
286solutions = [
287 {
288 "custom_vars": {
Fumitoshi Ukaid65112d72025-09-02 01:43:53289 "reapi_instance": "default", # your instance name
290 "reapi_address": "remotebuild.example.com:443", # your backend address
291 "reapi_backend_config_path": "/path/to/your/backend.star",
Fumitoshi Ukaidd41b9032025-08-12 05:23:46292 },
293 }
294]
295```
296
Omar Shawky971848ce2024-04-17 21:47:30297And run `gclient sync`. This will regenerate the config files in
Fumitoshi Ukaid65112d72025-09-02 01:43:53298`build/config/siso/.sisoenv` and
Fumitoshi Ukaidd41b9032025-08-12 05:23:46299`build/config/siso/backend_config/backend.star` to use the REAPI instance
Fumitoshi Ukai334658572025-04-09 00:59:30300that you just added to your `.gclient` file.
Fumitoshi Ukai8c123e92025-04-23 06:06:44301
Fumitoshi Ukaid65112d72025-09-02 01:43:53302Tip: you may want to use `--reapi_grpc_conn_pool=1` or so to limit
303connection pool for reapi access.
304
305Tip: you may want to use `--reapi_keep_exec_stream` if your backend
306terminates action when grpc stream is cancelled or closed, and
307doesn't work with WaitExecution.
308
Fumitoshi Ukai913b8fe2025-09-04 05:15:42309Tip: you can put these flags in `build/config/siso/.sisorc` like
310
311```shell
312ninja --reapi_grpc_conn_pool=1 --reapi_keep_exec_stream
313```
314so siso will use these flags for `siso ninja`, or `autoninja`.
315
Fumitoshi Ukaid65112d72025-09-02 01:43:53316##### gn setup for remote execution
Philipp Wollermann43f9cb82023-11-27 05:33:19317
318Then, add the following GN args to your `args.gn`:
319
Takuto Ikuta66f5de82023-09-08 03:55:44320```
Philipp Wollermann43f9cb82023-11-27 05:33:19321use_remoteexec = true
Fumitoshi Ukai334658572025-04-09 00:59:30322use_siso = true
Takuto Ikuta66f5de82023-09-08 03:55:44323```
324
Fumitoshi Ukai8c123e92025-04-23 06:06:44325If `args.gn` contains `use_reclient=true`, drop it or replace it with
326`use_reclient=false`.
327
Philipp Wollermann43f9cb82023-11-27 05:33:19328That's it. Remember to always use `autoninja` for building Chromium as described
Fumitoshi Ukaic9f326d2025-04-24 01:06:28329below, instead of directly invoking `siso` or `ninja`.
Philipp Wollermann43f9cb82023-11-27 05:33:19330
Fumitoshi Ukai8c123e92025-04-23 06:06:44331Reach out to
332[build@chromium.org](https://groups.google.com/a/chromium.org/g/build)
333if you have any questions about remote execution usage.
334
dpranke2989a782016-12-02 02:57:12335#### Include fewer debug symbols
336
337By default GN produces a build with all of the debug assertions enabled
338(`is_debug=true`) and including full debug info (`symbol_level=2`). Setting
339`symbol_level=1` will produce enough information for stack traces, but not
340line-by-line debugging. Setting `symbol_level=0` will include no debug
341symbols at all. Either will speed up the build compared to full symbols.
342
Bruce Dawson63e0be72021-11-29 20:34:41343#### Disable debug symbols for Blink and v8
dpranke2989a782016-12-02 02:57:12344
345Due to its extensive use of templates, the Blink code produces about half
346of our debug symbols. If you don't ever need to debug Blink, you can set
Bruce Dawson63e0be72021-11-29 20:34:41347the GN arg `blink_symbol_level=0`. Similarly, if you don't need to debug v8 you
348can improve build speeds by setting the GN arg `v8_symbol_level=0`.
dpranke2989a782016-12-02 02:57:12349
350#### Use Icecc
351
352[Icecc](https://github.com/icecc/icecream) is the distributed compiler with a
353central scheduler to share build load. Currently, many external contributors use
Fumitoshi Ukai334658572025-04-09 00:59:30354it. e.g. Intel, Opera, Samsung (this is not useful if you're using Siso).
dpranke2989a782016-12-02 02:57:12355
356In order to use `icecc`, set the following GN args:
357
358```
dpranke2989a782016-12-02 02:57:12359use_debug_fission=false
360is_clang=false
dpranke2989a782016-12-02 02:57:12361```
362
Victor Costan44af72b2017-11-13 20:01:30363See these links for more on the
dpranke2989a782016-12-02 02:57:12364[bundled_binutils limitation](https://github.com/icecc/icecream/commit/b2ce5b9cc4bd1900f55c3684214e409fa81e7a92),
365the [debug fission limitation](http://gcc.gnu.org/wiki/DebugFission).
366
367Using the system linker may also be necessary when using glibc 2.21 or newer.
368See [related bug](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808181).
369
370#### ccache
371
David Sandersddc9a7f2022-01-28 03:19:19372You can use [ccache](https://ccache.dev) to speed up local builds (again,
Fumitoshi Ukai334658572025-04-09 00:59:30373this is not useful if you're using Siso).
dpranke2989a782016-12-02 02:57:12374
375Increase your ccache hit rate by setting `CCACHE_BASEDIR` to a parent directory
376that the working directories all have in common (e.g.,
377`/home/yourusername/development`). Consider using
378`CCACHE_SLOPPINESS=include_file_mtime` (since if you are using multiple working
379directories, header times in svn sync'ed portions of your trees will be
380different - see
David Sandersddc9a7f2022-01-28 03:19:19381[the ccache troubleshooting section](https://ccache.dev/manual/latest.html#_troubleshooting)
dpranke2989a782016-12-02 02:57:12382for additional information). If you use symbolic links from your home directory
383to get to the local physical disk directory where you keep those working
384development directories, consider putting
385
Omar Shawky971848ce2024-04-17 21:47:30386```
387alias cd="cd -P"
388```
dpranke2989a782016-12-02 02:57:12389
390in your `.bashrc` so that `$PWD` or `cwd` always refers to a physical, not
391logical directory (and make sure `CCACHE_BASEDIR` also refers to a physical
392parent).
393
394If you tune ccache correctly, a second working directory that uses a branch
395tracking trunk and is up to date with trunk and was gclient sync'ed at about the
396same time should build chrome in about 1/3 the time, and the cache misses as
397reported by `ccache -s` should barely increase.
398
Song Fangzhen4b68a6e32021-07-14 05:53:40399This is especially useful if you use
400[git-worktree](http://git-scm.com/docs/git-worktree) and keep multiple local
dpranke2989a782016-12-02 02:57:12401working directories going at once.
402
403#### Using tmpfs
404
405You can use tmpfs for the build output to reduce the amount of disk writes
406required. I.e. mount tmpfs to the output directory where the build output goes:
407
408As root:
Omar Shawky971848ce2024-04-17 21:47:30409```
410mount -t tmpfs -o size=20G,nr_inodes=40k,mode=1777 tmpfs /path/to/out
411```
dpranke2989a782016-12-02 02:57:12412
413*** note
414**Caveat:** You need to have enough RAM + swap to back the tmpfs. For a full
415debug build, you will need about 20 GB. Less for just building the chrome target
416or for a release build.
417***
418
419Quick and dirty benchmark numbers on a HP Z600 (Intel core i7, 16 cores
420hyperthreaded, 12 GB RAM)
421
Omar Shawky971848ce2024-04-17 21:47:30422* With tmpfs:
423 * 12m:20s
424* Without tmpfs
425 * 15m:40s
dpranke2989a782016-12-02 02:57:12426
Bruce Dawsonbe823202022-03-10 23:40:50427### Smaller builds
428
429The Chrome binary contains embedded symbols by default. You can reduce its size
430by using the Linux `strip` command to remove this debug information. You can
Peter BostrÃļm38748962023-05-08 21:24:26431also reduce binary size and turn on all optimizations by enabling official build
432mode, with the GN arg `is_official_build = true`.
Bruce Dawsonbe823202022-03-10 23:40:50433
dpranke0ae7cad2016-11-30 07:47:58434## Build Chromium
435
Fumitoshi Ukaic9f326d2025-04-24 01:06:28436Build Chromium (the "chrome" target) with Siso or Ninja using the command:
dpranke0ae7cad2016-11-30 07:47:58437
sdy93387fa2016-12-01 01:03:44438```shell
Max Morozf5b31fcd2018-08-10 21:55:48439$ autoninja -C out/Default chrome
sdy93387fa2016-12-01 01:03:44440```
dpranke0ae7cad2016-11-30 07:47:58441
Dirk Pranke8bd55f22018-10-24 21:22:10442(`autoninja` is a wrapper that automatically provides optimal values for the
Fumitoshi Ukaic9f326d2025-04-24 01:06:28443arguments passed to `siso` or `ninja`.)
Max Morozf5b31fcd2018-08-10 21:55:48444
sdy93387fa2016-12-01 01:03:44445You can get a list of all of the other build targets from GN by running `gn ls
Fumitoshi Ukaic9f326d2025-04-24 01:06:28446out/Default` from the command line. To compile one, pass the GN label to
447Siso/Ninja with no preceding "//" (so, for `//chrome/test:unit_tests` use
448`autoninja -C out/Default chrome/test:unit_tests`).
dpranke0ae7cad2016-11-30 07:47:58449
Fumitoshi Ukai8a888852025-09-05 01:42:55450Tips: See [Siso tips](../siso_tips.md).
Junji Watanabe7037b95f2024-04-22 06:14:15451
dpranke0ae7cad2016-11-30 07:47:58452## Run Chromium
453
454Once it is built, you can simply run the browser:
455
sdy93387fa2016-12-01 01:03:44456```shell
457$ out/Default/chrome
458```
dpranke0ae7cad2016-11-30 07:47:58459
Victor Viannaeda6fcc42023-03-14 17:18:22460If you're using a remote machine that supports Chrome Remote Desktop, you can
461add this to your .bashrc / .bash_profile.
462
463```shell
464if [[ -z "${DISPLAY}" ]]; then
Victor Hugo Vianna Silva451142c22024-07-08 21:37:41465 # In reality, Chrome Remote Desktop starts with 20 and increases until it
466 # finds an available ID [1]. So this isn't guaranteed to always work, but
467 # should work on the vast majoriy of cases.
468 #
469 # [1] https://source.chromium.org/chromium/chromium/src/+/main:remoting/host/linux/linux_me2me_host.py;l=112;drc=464a632e21bcec76c743930d4db8556613e21fd8
470 export DISPLAY=:20
Victor Viannaeda6fcc42023-03-14 17:18:22471fi
472```
473
474This means if you launch Chrome from an SSH session, the UI output will be
475available in Chrome Remote Desktop.
476
dpranke0ae7cad2016-11-30 07:47:58477## Running test targets
478
Andrew Williamsfa9b7d62023-03-20 15:48:28479Tests are split into multiple test targets based on their type and where they
480exist in the directory structure. To see what target a given unit test or
481browser test file corresponds to, the following command can be used:
482
483```shell
484$ gn refs out/Default --testonly=true --type=executable --all chrome/browser/ui/browser_list_unittest.cc
485//chrome/test:unit_tests
486```
487
488In the example above, the target is unit_tests. The unit_tests binary can be
489built by running the following command:
Fred Shih865fb8f2022-02-03 03:54:19490
491```shell
492$ autoninja -C out/Default unit_tests
493```
494
495You can run the tests by running the unit_tests binary. You can also limit which
496tests are run using the `--gtest_filter` arg, e.g.:
dpranke0ae7cad2016-11-30 07:47:58497
sdy93387fa2016-12-01 01:03:44498```shell
Andrew Williamsfa9b7d62023-03-20 15:48:28499$ out/Default/unit_tests --gtest_filter="BrowserListUnitTest.*"
sdy93387fa2016-12-01 01:03:44500```
dpranke0ae7cad2016-11-30 07:47:58501
502You can find out more about GoogleTest at its
503[GitHub page](https://github.com/google/googletest).
504
505## Update your checkout
506
507To update an existing checkout, you can run
508
sdy93387fa2016-12-01 01:03:44509```shell
510$ git rebase-update
511$ gclient sync
512```
dpranke0ae7cad2016-11-30 07:47:58513
514The first command updates the primary Chromium source repository and rebases
sdy93387fa2016-12-01 01:03:44515any of your local branches on top of tip-of-tree (aka the Git branch
Andrew Williamsbbc1a1e2021-07-21 01:51:22516`origin/main`). If you don't want to use this script, you can also just use
sdy93387fa2016-12-01 01:03:44517`git pull` or other common Git commands to update the repo.
dpranke0ae7cad2016-11-30 07:47:58518
sdy93387fa2016-12-01 01:03:44519The second command syncs dependencies to the appropriate versions and re-runs
520hooks as needed.
dpranke0ae7cad2016-11-30 07:47:58521
522## Tips, tricks, and troubleshooting
andybons3322f762015-08-24 21:37:09523
524### Linker Crashes
andybonsad92aa32015-08-31 02:27:44525
andybons3322f762015-08-24 21:37:09526If, during the final link stage:
andybonsad92aa32015-08-31 02:27:44527
sdy93387fa2016-12-01 01:03:44528```
529LINK out/Debug/chrome
530```
andybonsad92aa32015-08-31 02:27:44531
andybons3322f762015-08-24 21:37:09532You get an error like:
andybons3322f762015-08-24 21:37:09533
sdy93387fa2016-12-01 01:03:44534```
535collect2: ld terminated with signal 6 Aborted terminate called after throwing an instance of 'std::bad_alloc'
536collect2: ld terminated with signal 11 [Segmentation fault], core dumped
537```
andybonsad92aa32015-08-31 02:27:44538
Song Qinglin5ac3cf922022-11-09 04:12:22539or:
540
541```
542LLVM ERROR: out of memory
543```
544
brettwc25693b32016-05-26 01:11:52545you are probably running out of memory when linking. You *must* use a 64-bit
546system to build. Try the following build settings (see [GN build
547configuration](https://www.chromium.org/developers/gn-build-configuration) for
sdy93387fa2016-12-01 01:03:44548other settings):
andybonsad92aa32015-08-31 02:27:44549
Omar Shawky971848ce2024-04-17 21:47:30550* Build in release mode (debugging symbols require more memory):
brettwc25693b32016-05-26 01:11:52551 `is_debug = false`
Omar Shawky971848ce2024-04-17 21:47:30552* Turn off symbols: `symbol_level = 0`
553* Build in component mode (this is for development only, it will be slower and
sdy93387fa2016-12-01 01:03:44554 may have broken functionality): `is_component_build = true`
Omar Shawky971848ce2024-04-17 21:47:30555* For official (ThinLTO) builds on Linux, increase the vm.max_map_count kernel
Song Qinglin5ac3cf922022-11-09 04:12:22556 parameter: increase the `vm.max_map_count` value from default (like 65530)
557 to for example 262144. You can run the `sudo sysctl -w vm.max_map_count=262144`
558 command to set it in the current session from the shell, or add the
559 `vm.max_map_count=262144` to /etc/sysctl.conf to save it permanently.
andybons3322f762015-08-24 21:37:09560
dpranke0ae7cad2016-11-30 07:47:58561### More links
andybons3322f762015-08-24 21:37:09562
Omar Shawky971848ce2024-04-17 21:47:30563* Information about [building with Clang](../clang.md).
564* You may want to [use a chroot](using_a_chroot.md) to
dpranke0ae7cad2016-11-30 07:47:58565 isolate yourself from versioning or packaging conflicts.
Omar Shawky971848ce2024-04-17 21:47:30566* Cross-compiling for ARM? See [LinuxChromiumArm](chromium_arm.md).
567* Want to use Eclipse as your IDE? See
Tom Anderson93e49e492019-12-23 19:55:37568 [LinuxEclipseDev](eclipse_dev.md).
Omar Shawky971848ce2024-04-17 21:47:30569* Want to use your built version as your default browser? See
Tom Anderson93e49e492019-12-23 19:55:37570 [LinuxDevBuildAsDefaultBrowser](dev_build_as_default_browser.md).
andybons3322f762015-08-24 21:37:09571
dpranke2989a782016-12-02 02:57:12572## Next Steps
andybonsad92aa32015-08-31 02:27:44573
574If you want to contribute to the effort toward a Chromium-based browser for
Tom Anderson93e49e492019-12-23 19:55:37575Linux, please check out the [Linux Development page](development.md) for
andybonsad92aa32015-08-31 02:27:44576more information.
dpranke2989a782016-12-02 02:57:12577
Omar Shawky971848ce2024-04-17 21:47:30578## Notes for other distros
dpranke2989a782016-12-02 02:57:12579
580### Arch Linux
581
582Instead of running `install-build-deps.sh` to install build dependencies, run:
583
584```shell
585$ sudo pacman -S --needed python perl gcc gcc-libs bison flex gperf pkgconfig \
Tom Anderson761687a2023-06-14 17:27:39586nss alsa-lib glib2 gtk3 nspr freetype2 cairo dbus xorg-server-xvfb \
587xorg-xdpyinfo
dpranke2989a782016-12-02 02:57:12588```
589
590For the optional packages on Arch Linux:
591
Omar Shawky971848ce2024-04-17 21:47:30592* `php-cgi` is provided with `pacman`
593* `wdiff` is not in the main repository but `dwdiff` is. You can get `wdiff`
dpranke2989a782016-12-02 02:57:12594 in AUR/`yaourt`
dpranke2989a782016-12-02 02:57:12595
Kenneth Russell56293772018-09-21 01:46:15596### Crostini (Debian based)
597
David Munro9b5f4c4f2019-07-24 08:23:27598First install the `file` and `lsb-release` commands for the script to run properly:
Kenneth Russell56293772018-09-21 01:46:15599
600```shell
David Munro9b5f4c4f2019-07-24 08:23:27601$ sudo apt-get install file lsb-release
Kenneth Russell56293772018-09-21 01:46:15602```
603
604Then invoke install-build-deps.sh with the `--no-arm` argument,
605because the ARM toolchain doesn't exist for this configuration:
606
607```shell
608$ sudo install-build-deps.sh --no-arm
609```
610
dpranke2989a782016-12-02 02:57:12611### Fedora
612
613Instead of running `build/install-build-deps.sh`, run:
614
615```shell
616su -c 'yum install git python bzip2 tar pkgconfig atk-devel alsa-lib-devel \
617bison binutils brlapi-devel bluez-libs-devel bzip2-devel cairo-devel \
618cups-devel dbus-devel dbus-glib-devel expat-devel fontconfig-devel \
Tom Anderson287339e2018-08-22 21:52:02619freetype-devel gcc-c++ glib2-devel glibc.i686 gperf glib2-devel \
Tim Brown36312fc2017-12-15 22:56:20620gtk3-devel java-1.*.0-openjdk-devel libatomic libcap-devel libffi-devel \
Tom Anderson761687a2023-06-14 17:27:39621libgcc.i686 libjpeg-devel libstdc++.i686 libX11-devel libXScrnSaver-devel \
622libXtst-devel libxkbcommon-x11-devel ncurses-compat-libs nspr-devel nss-devel \
623pam-devel pango-devel pciutils-devel pulseaudio-libs-devel zlib.i686 httpd \
624mod_ssl php php-cli python-psutil wdiff xorg-x11-server-Xvfb'
dpranke2989a782016-12-02 02:57:12625```
626
Kent Tamura59ffb022018-11-27 05:30:56627The fonts needed by Blink's web tests can be obtained by following [these
Victor Costan44af72b2017-11-13 20:01:30628instructions](https://gist.github.com/pwnall/32a3b11c2b10f6ae5c6a6de66c1e12ae).
629For the optional packages:
dpranke2989a782016-12-02 02:57:12630
631* `php-cgi` is provided by the `php-cli` package.
Victor Costan44af72b2017-11-13 20:01:30632* `sun-java6-fonts` is covered by the instructions linked above.
dpranke2989a782016-12-02 02:57:12633
634### Gentoo
635
636You can just run `emerge www-client/chromium`.
637
Delan Azabani43eefa3d2024-05-09 03:39:33638### NixOS
639
640To get a shell with the dev environment:
641
642```sh
643$ nix-shell tools/nix/shell.nix
644```
645
646To run a command in the dev environment:
647
648```sh
649$ NIX_SHELL_RUN='autoninja -C out/Default chrome' nix-shell tools/nix/shell.nix
650```
651
652To set up clangd with remote indexing support, run the command below, then copy
653the path into your editor config:
654
655```sh
656$ NIX_SHELL_RUN='readlink /usr/bin/clangd' nix-shell tools/nix/shell.nix
657```
658
dpranke2989a782016-12-02 02:57:12659### OpenSUSE
660
661Use `zypper` command to install dependencies:
662
663(openSUSE 11.1 and higher)
664
665```shell
Tim Brown36312fc2017-12-15 22:56:20666sudo zypper in subversion pkg-config python perl bison flex gperf \
667 mozilla-nss-devel glib2-devel gtk-devel wdiff lighttpd gcc gcc-c++ \
668 mozilla-nspr mozilla-nspr-devel php5-fastcgi alsa-devel libexpat-devel \
dpranke2989a782016-12-02 02:57:12669 libjpeg-devel libbz2-devel
670```
671
672For 11.0, use `libnspr4-0d` and `libnspr4-dev` instead of `mozilla-nspr` and
Tom Anderson287339e2018-08-22 21:52:02673`mozilla-nspr-devel`, and use `php5-cgi` instead of `php5-fastcgi`.
dpranke2989a782016-12-02 02:57:12674
675(openSUSE 11.0)
676
677```shell
678sudo zypper in subversion pkg-config python perl \
679 bison flex gperf mozilla-nss-devel glib2-devel gtk-devel \
680 libnspr4-0d libnspr4-dev wdiff lighttpd gcc gcc-c++ libexpat-devel \
Tom Anderson287339e2018-08-22 21:52:02681 php5-cgi alsa-devel gtk3-devel jpeg-devel
dpranke2989a782016-12-02 02:57:12682```
683
684The Ubuntu package `sun-java6-fonts` contains a subset of Java of the fonts used.
685Since this package requires Java as a prerequisite anyway, we can do the same
686thing by just installing the equivalent openSUSE Sun Java package:
687
688```shell
689sudo zypper in java-1_6_0-sun
690```
691
692WebKit is currently hard-linked to the Microsoft fonts. To install these using `zypper`
693
694```shell
695sudo zypper in fetchmsttfonts pullin-msttf-fonts
696```
697
698To make the fonts installed above work, as the paths are hardcoded for Ubuntu,
699create symlinks to the appropriate locations:
700
701```shell
702sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts
703sudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttf
704sudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf
705sudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf
706sudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf
707sudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf
708sudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf
709sudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf
710sudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf
711sudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf
712sudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf
713sudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttf
714sudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf
715sudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf
716sudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf
717sudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf
718sudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf
719sudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf
720sudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf
721sudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf
722```
723
724The Ubuntu package `sun-java6-fonts` contains a subset of Java of the fonts used.
725Since this package requires Java as a prerequisite anyway, we can do the same
726thing by just installing the equivalent openSUSE Sun Java package:
727
728```shell
729sudo zypper in java-1_6_0-sun
730```
731
732WebKit is currently hard-linked to the Microsoft fonts. To install these using `zypper`
733
734```shell
735sudo zypper in fetchmsttfonts pullin-msttf-fonts
736```
737
738To make the fonts installed above work, as the paths are hardcoded for Ubuntu,
739create symlinks to the appropriate locations:
740
741```shell
742sudo mkdir -p /usr/share/fonts/truetype/msttcorefonts
743sudo ln -s /usr/share/fonts/truetype/arial.ttf /usr/share/fonts/truetype/msttcorefonts/Arial.ttf
744sudo ln -s /usr/share/fonts/truetype/arialbd.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf
745sudo ln -s /usr/share/fonts/truetype/arialbi.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Bold_Italic.ttf
746sudo ln -s /usr/share/fonts/truetype/ariali.ttf /usr/share/fonts/truetype/msttcorefonts/Arial_Italic.ttf
747sudo ln -s /usr/share/fonts/truetype/comic.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf
748sudo ln -s /usr/share/fonts/truetype/comicbd.ttf /usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS_Bold.ttf
749sudo ln -s /usr/share/fonts/truetype/cour.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf
750sudo ln -s /usr/share/fonts/truetype/courbd.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf
751sudo ln -s /usr/share/fonts/truetype/courbi.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf
752sudo ln -s /usr/share/fonts/truetype/couri.ttf /usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf
753sudo ln -s /usr/share/fonts/truetype/impact.ttf /usr/share/fonts/truetype/msttcorefonts/Impact.ttf
754sudo ln -s /usr/share/fonts/truetype/times.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman.ttf
755sudo ln -s /usr/share/fonts/truetype/timesbd.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold.ttf
756sudo ln -s /usr/share/fonts/truetype/timesbi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Bold_Italic.ttf
757sudo ln -s /usr/share/fonts/truetype/timesi.ttf /usr/share/fonts/truetype/msttcorefonts/Times_New_Roman_Italic.ttf
758sudo ln -s /usr/share/fonts/truetype/verdana.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana.ttf
759sudo ln -s /usr/share/fonts/truetype/verdanab.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold.ttf
760sudo ln -s /usr/share/fonts/truetype/verdanai.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Italic.ttf
761sudo ln -s /usr/share/fonts/truetype/verdanaz.ttf /usr/share/fonts/truetype/msttcorefonts/Verdana_Bold_Italic.ttf
762```
763
764And then for the Java fonts:
765
766```shell
767sudo mkdir -p /usr/share/fonts/truetype/ttf-lucida
768sudo find /usr/lib*/jvm/java-1.6.*-sun-*/jre/lib -iname '*.ttf' -print \
769 -exec ln -s {} /usr/share/fonts/truetype/ttf-lucida \;
770```
Omar Shawky08b259c2024-03-27 19:52:17771
772### Docker
773
774#### Prerequisites
775
776While it is not a common setup, Chromium compilation should work from within a
777Docker container. If you choose to compile from within a container for whatever
778reason, you will need to make sure that the following tools are available:
779
780* `curl`
781* `git`
782* `lsb_release`
783* `python3`
784* `sudo`
785* `file`
786
787There may be additional Docker-specific issues during compilation. See
788[this bug](https://crbug.com/1377520) for additional details on this.
789
Omar Shawky971848ce2024-04-17 21:47:30790Note: [Clone depot_tools](#install-depot_tools) first.
Omar Shawky08b259c2024-03-27 19:52:17791
792#### Build Steps
793
7941. Put the following Dockerfile in `/path/to/chromium/`.
795
796```docker
797# Use an official Ubuntu base image with Docker already installed
798FROM ubuntu:22.04
799
800# Set environment variables
801ENV DEBIAN_FRONTEND=noninteractive
802
803# Install Mantatory tools (curl git python3) and optional tools (vim sudo)
804RUN apt-get update && \
805 apt-get install -y curl git lsb-release python3 git file vim sudo && \
806 rm -rf /var/lib/apt/lists/*
807
808# Export depot_tools path
809ENV PATH="/depot_tools:${PATH}"
810
811# Configure git for safe.directory
Ho Cheung7c53eaf2024-05-31 00:31:26812RUN git config --global --add safe.directory /depot_tools && \
813 git config --global --add safe.directory /chromium/src
Omar Shawky08b259c2024-03-27 19:52:17814
Ho Cheung7c53eaf2024-05-31 00:31:26815# Set the working directory to the existing Chromium source directory.
816# This can be either "/chromium/src" or "/chromium".
817WORKDIR /chromium/src
Omar Shawky08b259c2024-03-27 19:52:17818
819# Expose any necessary ports (if needed)
820# EXPOSE 8080
mohamedhany015ae34802024-10-16 16:34:41821
822# Create a dummy user and group to avoid permission issues
823RUN groupadd -g 1001 chrom-d && \
824 useradd -u 1000 -g 1001 -m chrom-d
Ho Cheung7c53eaf2024-05-31 00:31:26825
826# Create normal user with name "chrom-d". Optional and you can use root but
827# not advised.
828USER chrom-d
Omar Shawky08b259c2024-03-27 19:52:17829
Omar Shawky971848ce2024-04-17 21:47:30830# Start Chromium Builder "chrom-d" (modify this command as needed)
Omar Shawky08b259c2024-03-27 19:52:17831# CMD ["autoninja -C out/Default chrome"]
832CMD ["bash"]
833```
834
8352. Build Container
836
837```shell
838# chrom-b is just a name; You can change it but you must reflect the renaming
839# in all commands below
840$ docker build -t chrom-b .
841```
842
8433. Run container as root to install dependencies
844
845```shell
mohamedhany015ae34802024-10-16 16:34:41846$ docker run
Omar Shawky08b259c2024-03-27 19:52:17847 -it \ # Run docker interactively
Omar Shawky971848ce2024-04-17 21:47:30848 --name chrom-b \ # with name "chrom-b"
849 -u root \ # with user root
850 -v /path/on/machine/to/chromium:/chromium \ # With chromium folder mounted
851 -v /path/on/machine/to/depot_tools:/depot_tools \ # With depot_tools mounted
852 chrom-b # Run container with image name "chrom-b"
Omar Shawky08b259c2024-03-27 19:52:17853```
854
mohamedhany015ae34802024-10-16 16:34:41855*** note
856**Note:** When running the command as a single line in bash, please remove the
857comments (after the `#`) to avoid breaking the command.
858***
859
Omar Shawky971848ce2024-04-17 21:47:308604. Install dependencies:
Omar Shawky08b259c2024-03-27 19:52:17861
862```shell
Ho Cheung7c53eaf2024-05-31 00:31:26863./build/install-build-deps.sh
Omar Shawky08b259c2024-03-27 19:52:17864```
865
Ho Cheung7c53eaf2024-05-31 00:31:268665. [Run hooks](#run-the-hooks) (On docker or machine if you installed depot_tools on machine)
867
mohamedhany015ae34802024-10-16 16:34:41868*** note
869**Before running hooks:** Ensure that all directories within
870`third_party` are added as safe directories in Git. This is required
871when running in the container because the ownership of the `src/`
872directory (e.g., `chrom-b`) differs from the current user
873(e.g., `root`). To prevent Git **warnings** about "dubious ownership"
874run the following command after installing the dependencies:
875
876```shell
877# Loop through each directory in /chromium/src/third_party and add
878# them as safe directories in Git
879$ for dir in /chromium/src/third_party/*; do
880 if [ -d "$dir" ]; then
881 git config --global --add safe.directory "$dir"
882 fi
883done
884```
885***
886
Ho Cheung7c53eaf2024-05-31 00:31:268876. Exit container
888
8897. Save container image with tag-id name `dpv1.0`. Run this on the machine, not in container
Omar Shawky971848ce2024-04-17 21:47:30890
Omar Shawky08b259c2024-03-27 19:52:17891```shell
mohamedhany015ae34802024-10-16 16:34:41892# Get docker running/stopped containers, copy the "chrom-b" id
893$ docker container ls -a
Omar Shawky971848ce2024-04-17 21:47:30894# Save/tag running docker container with name "chrom-b" with "dpv1.0"
895# You can choose any tag name you want but propagate name accordingly
896# You will need to create new tags when working on different parts of
897# chromium which requires installing additional dependencies
Omar Shawky08b259c2024-03-27 19:52:17898$ docker commit <ID from above step> chrom-b:dpv1.0
899# Optional, just saves space by deleting unnecessary images
900$ docker image rmi chrom-b:latest && docker image prune \
901 && docker container prune && docker builder prune
902```
903
Omar Shawky08b259c2024-03-27 19:52:17904#### Run container
905
906```shell
907$ docker run --rm \ # close instance upon exit
908 -it \ # Run docker interactively
Omar Shawky971848ce2024-04-17 21:47:30909 --name chrom-b \ # with name "chrom-b"
Omar Shawky08b259c2024-03-27 19:52:17910 -u $(id -u):$(id -g) \ # Run container as a non-root user with same UID & GID
Omar Shawky971848ce2024-04-17 21:47:30911 -v /path/on/machine/to/chromium:/chromium \ # With chromium folder mounted
912 -v /path/on/machine/to/depot_tools:/depot_tools \ # With depot_tools mounted
913 chrom-b:dpv1.0 # Run container with image name "chrom-b" and tag dpv1.0
Omar Shawky08b259c2024-03-27 19:52:17914```
mohamedhany015ae34802024-10-16 16:34:41915
916*** note
917**Note:** When running the command as a single line in bash, please remove the
918comments (after the `#`) to avoid breaking the command.
919***