1# Checking out and building Cast on Linux
2
3**Note**: it is **not possible** to build a binary functionally
4equivalent to a Chromecast. This is to build a single-page content
5embedder with similar functionality to Cast products.
6
7## Instructions for Google Employees
8
9Are you a Google employee? See
10[go/building-linux-cast](https://goto.google.com/building-linux-cast) instead.
11
12[TOC]
13
14## System requirements
15
16*   A 64-bit Intel machine with at least 8GB of RAM. More than 16GB is highly
17    recommended.
18*   At least 100GB of free disk space.
19*   You must have Git and Python installed already.
20
21Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are
22some instructions for other distros below, but they are mostly unsupported.
23
24## Install `depot_tools`
25
26Clone the `depot_tools` repository:
27
28```shell
29$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
30```
31
32Add `depot_tools` to the end of your PATH (you will probably want to put this
33in your `~/.bashrc` or `~/.zshrc`). Assuming you cloned `depot_tools` to
34`/path/to/depot_tools`:
35
36```shell
37$ export PATH="$PATH:/path/to/depot_tools"
38```
39
40## Get the code
41
42Create a `chromium` directory for the checkout and change to it (you can call
43this whatever you like and put it wherever you like, as long as the full path
44has no spaces):
45
46```shell
47$ mkdir ~/chromium && cd ~/chromium
48```
49
50Run the `fetch` tool from depot_tools to check out the code and its
51dependencies.
52
53```shell
54$ fetch --nohooks chromium
55```
56
57If you don't want the full repo history, you can save a lot of time by
58adding the `--no-history` flag to `fetch`.
59
60Expect the command to take 30 minutes on even a fast connection, and many
61hours on slower ones.
62
63If you've already installed the build dependencies on the machine (from another
64checkout, for example), you can omit the `--nohooks` flag and `fetch`
65will automatically execute `gclient runhooks` at the end.
66
67When `fetch` completes, it will have created a hidden `.gclient` file and a
68directory called `src` in the working directory. The remaining instructions
69assume you have switched to the `src` directory:
70
71```shell
72$ cd src
73```
74
75### Install additional build dependencies
76
77Once you have checked out the code, and assuming you're using Ubuntu, run
78[build/install-build-deps.sh](/build/install-build-deps.sh)
79
80You may need to adjust the build dependencies for other distros. There are
81some [notes](#notes) at the end of this document, but we make no guarantees
82for their accuracy.
83
84### Run the hooks
85
86Once you've run `install-build-deps` at least once, you can now run the
87Chromium-specific hooks, which will download additional binaries and other
88things you might need:
89
90```shell
91$ gclient runhooks
92```
93
94*Optional*: You can also [install API
95keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your
96build to talk to some Google services, but this is not necessary for most
97development and testing purposes.
98
99## Setting up the build
100
101Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with
102a tool called [GN](https://gn.googlesource.com/gn/+/master/docs/quick_start.md)
103to generate `.ninja` files. You can create any number of *build directories*
104with different configurations. To create a build directory, run:
105
106```shell
107$ gn gen out/Default --args='is_chromecast=true'
108```
109
110* You only have to run this once for each new build directory, Ninja will
111  update the build files as needed.
112* You can replace `Default` with another name, but
113  it should be a subdirectory of `out`.
114* For other build arguments, including release settings, see [GN build
115  configuration](https://www.chromium.org/developers/gn-build-configuration).
116  The default will be a debug component build matching the current host
117  operating system and CPU.
118* For more info on GN, run `gn help` on the command line or read the
119  [quick start guide](https://gn.googlesource.com/gn/+/master/docs/quick_start.md).
120
121### <a name="faster-builds"></a>Faster builds
122
123You might try some of the suggestions on the
124[Linux build setup](build_instructions.md#faster-builds).
125
126## Build cast\_shell
127
128Build cast\_shell with Ninja using the command:
129
130```shell
131$ autoninja -C out/Default cast_shell
132```
133
134(`autoninja` is a wrapper that automatically provides optimal values for the
135arguments passed to `ninja`.)
136
137## Run cast\_shell
138
139Once it is built, you can simply run it:
140
141```shell
142$ out/Default/cast_shell --ozone-platform=x11 http://google.com
143```
144
145## Update your checkout
146
147To update an existing checkout, you can run
148
149```shell
150$ git rebase-update
151$ gclient sync
152```
153
154The first command updates the primary Chromium source repository and rebases
155any of your local branches on top of tip-of-tree (aka the Git branch
156`origin/master`). If you don't want to use this script, you can also just use
157`git pull` or other common Git commands to update the repo.
158
159The second command syncs dependencies to the appropriate versions and re-runs
160hooks as needed.
161
162## Tips, tricks, and troubleshooting
163
164### More links
165
166*   Want to use Eclipse as your IDE? See
167    [LinuxEclipseDev](eclipse_dev.md).
168