dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 1 | # Checking out and building Cast on Linux |
| 2 | |
| 3 | **Note**: it is **not possible** to build a binary functionally |
| 4 | equivalent to a Chromecast. This is to build a single-page content |
| 5 | embedder with similar functionality to Cast products. |
| 6 | |
| 7 | ## Instructions for Google Employees |
| 8 | |
| 9 | Are 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 | |
Bruce Dawson | c266172 | 2024-06-12 19:44:29 | [diff] [blame] | 16 | * An x86-64 machine with at least 8GB of RAM. More than 16GB is highly |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 17 | recommended. |
| 18 | * At least 100GB of free disk space. |
| 19 | * You must have Git and Python installed already. |
| 20 | |
| 21 | Most development is done on Ubuntu (currently 14.04, Trusty Tahr). There are |
| 22 | some instructions for other distros below, but they are mostly unsupported. |
| 23 | |
| 24 | ## Install `depot_tools` |
| 25 | |
| 26 | Clone the `depot_tools` repository: |
| 27 | |
| 28 | ```shell |
| 29 | $ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git |
| 30 | ``` |
| 31 | |
| 32 | Add `depot_tools` to the end of your PATH (you will probably want to put this |
| 33 | in 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 | |
| 42 | Create a `chromium` directory for the checkout and change to it (you can call |
| 43 | this whatever you like and put it wherever you like, as long as the full path |
| 44 | has no spaces): |
| 45 | |
| 46 | ```shell |
| 47 | $ mkdir ~/chromium && cd ~/chromium |
| 48 | ``` |
| 49 | |
| 50 | Run the `fetch` tool from depot_tools to check out the code and its |
| 51 | dependencies. |
| 52 | |
| 53 | ```shell |
| 54 | $ fetch --nohooks chromium |
| 55 | ``` |
| 56 | |
| 57 | If you don't want the full repo history, you can save a lot of time by |
| 58 | adding the `--no-history` flag to `fetch`. |
| 59 | |
| 60 | Expect the command to take 30 minutes on even a fast connection, and many |
| 61 | hours on slower ones. |
| 62 | |
| 63 | If you've already installed the build dependencies on the machine (from another |
| 64 | checkout, for example), you can omit the `--nohooks` flag and `fetch` |
| 65 | will automatically execute `gclient runhooks` at the end. |
| 66 | |
| 67 | When `fetch` completes, it will have created a hidden `.gclient` file and a |
| 68 | directory called `src` in the working directory. The remaining instructions |
| 69 | assume you have switched to the `src` directory: |
| 70 | |
| 71 | ```shell |
| 72 | $ cd src |
| 73 | ``` |
| 74 | |
| 75 | ### Install additional build dependencies |
| 76 | |
| 77 | Once 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 | |
| 80 | You may need to adjust the build dependencies for other distros. There are |
| 81 | some [notes](#notes) at the end of this document, but we make no guarantees |
| 82 | for their accuracy. |
| 83 | |
| 84 | ### Run the hooks |
| 85 | |
| 86 | Once you've run `install-build-deps` at least once, you can now run the |
| 87 | Chromium-specific hooks, which will download additional binaries and other |
| 88 | things you might need: |
| 89 | |
| 90 | ```shell |
| 91 | $ gclient runhooks |
| 92 | ``` |
| 93 | |
| 94 | *Optional*: You can also [install API |
| 95 | keys](https://www.chromium.org/developers/how-tos/api-keys) if you want your |
| 96 | build to talk to some Google services, but this is not necessary for most |
| 97 | development and testing purposes. |
| 98 | |
| 99 | ## Setting up the build |
| 100 | |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 101 | Chromium uses [Ninja](https://ninja-build.org) as its main build tool along with |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 102 | a tool called [GN](https://gn.googlesource.com/gn/+/main/docs/quick_start.md) |
Tom Bridgwater | eef40154 | 2018-08-17 00:54:43 | [diff] [blame] | 103 | to generate `.ninja` files. You can create any number of *build directories* |
| 104 | with different configurations. To create a build directory, run: |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 105 | |
| 106 | ```shell |
mark a. foltz | d37ab56 | 2022-11-08 20:06:40 | [diff] [blame] | 107 | $ gn gen out/Default --args='enable_cast_receiver=true is_castos=true' |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 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 |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 119 | [quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md). |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 120 | |
| 121 | ### <a name="faster-builds"></a>Faster builds |
| 122 | |
| 123 | You might try some of the suggestions on the |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 124 | [Linux build setup](build_instructions.md#faster-builds). |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 125 | |
| 126 | ## Build cast\_shell |
| 127 | |
| 128 | Build cast\_shell with Ninja using the command: |
| 129 | |
| 130 | ```shell |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 131 | $ autoninja -C out/Default cast_shell |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 132 | ``` |
| 133 | |
Dirk Pranke | 8bd55f2 | 2018-10-24 21:22:10 | [diff] [blame] | 134 | (`autoninja` is a wrapper that automatically provides optimal values for the |
| 135 | arguments passed to `ninja`.) |
| 136 | |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 137 | ## Run cast\_shell |
| 138 | |
| 139 | Once 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 | |
| 147 | To update an existing checkout, you can run |
| 148 | |
| 149 | ```shell |
| 150 | $ git rebase-update |
| 151 | $ gclient sync |
| 152 | ``` |
| 153 | |
| 154 | The first command updates the primary Chromium source repository and rebases |
| 155 | any of your local branches on top of tip-of-tree (aka the Git branch |
Andrew Williams | bbc1a1e | 2021-07-21 01:51:22 | [diff] [blame] | 156 | `origin/main`). If you don't want to use this script, you can also just use |
dpranke | c641a534 | 2017-04-04 02:35:01 | [diff] [blame] | 157 | `git pull` or other common Git commands to update the repo. |
| 158 | |
| 159 | The second command syncs dependencies to the appropriate versions and re-runs |
| 160 | hooks as needed. |
| 161 | |
| 162 | ## Tips, tricks, and troubleshooting |
| 163 | |
| 164 | ### More links |
| 165 | |
| 166 | * Want to use Eclipse as your IDE? See |
Tom Anderson | 93e49e49 | 2019-12-23 19:55:37 | [diff] [blame] | 167 | [LinuxEclipseDev](eclipse_dev.md). |