Page Summary
-
Docker image definitions are provided to manage build environments, simplifying the process.
-
The
docker compose run <platform>command is used for the simplest build usage, defaulting to adebugbuild withcobaltas the target. -
Build configurations can be customized using environment variables like
CONFIGandTARGETto specify optimization levels and build targets. -
Windows builds are supported through a separate
docker-compose-windows.ymlfile, which can be specified using the-fflag. -
The base operating system image used for builds can be customized by passing the
BASE_OSargument todocker compose build, allowing for different Debian-based images.
We provide Docker image definitions to simplify managing Cobalt build environments on Linux.
Prerequisites
These instructions assume: - You have already set up your Cobalt repository workspace on the host machine. - Docker is installed and running on your host Linux machine. If you need to install Docker, refer to the official Docker installation guide for Linux.
1. Building the Linux Docker Image
To build the linux builder Docker image, run one of the following commands from your workspace root (the directory containing docker-compose.yaml):
Using docker compose:
docker compose build linux
Or using Docker directly:
docker build -t linux cobalt/docker/linux
2. Launching the Linux Container
To run build commands in the container environment, first launch the container:
docker run --rm \
--user $(id -u):$(id -g) \
-e HOME=/tmp \
-v /path/to/workspace:/cobalt \
-w /cobalt/src \
-e PYTHONPATH="/cobalt/src" \
-it linux /bin/bash
3. Building Cobalt inside the Container
Once inside the interactive container shell (at /cobalt/src), run the following commands sequentially to configure and build the Cobalt target:
Set the environment PATH variable: Configure the search path to locate
depot_toolsandninjacorrectly:export PATH="/cobalt/tools/depot_tools:/cobalt/src/third_party/ninja:/cobalt/src:$PATH"(Optional) Clean stale build locks: If a previous compilation attempt was interrupted, a stale lock file might block siso. Clean it by running:
rm -f out/linux-x64x11_devel/.siso_lockGenerate the build configuration files for the
linux-x64x11platform in thedevelconfiguration with Remote Build Execution (RBE) disabled:python3 cobalt/build/gn.py -p linux-x64x11 -C devel --no-rbeCompile the Cobalt target using
autoninja:autoninja -C out/linux-x64x11_devel cobalt
Completed builds are generated in the out/linux-x64x11_devel directory of your workspace.