These instructions explain how Windows users can set up their Cobalt development environment, clone a copy of the Cobalt code repository, and build a Cobalt binary. Note that the binary has a graphical client and must be run locally on the machine that you are using to view the client. For example, you cannot SSH into another machine and run the binary on that machine.
Set up your workstation
Install the following required packages:
Installing on Windowsinstructions)
- ninja (see the
- The following VS2022 components:
- git (see the
Install GN, which we use for our build system code. There are a few ways to get the binary, follow the instructions for whichever way you prefer here.
(Optional) Install Sccache to support build acceleration.
Make sure all of the above installed packages are on your Path environment variable.
"C:\Program Files\Git" "C:\Program Files\Ninja" "C:\Program Files\nodejs" "C:\python_38" # Python 3.8 is the oldest supported python version. You may have a newer version installed. "C:\python_38\Scripts" "C:\winflexbison" # Or wherever you chose to unpack the zip file "C:\gn" "C:\sccache"
Clone the Cobalt code repository. The following
gitcommand creates a
cobaltdirectory that contains the repository:
$ git clone https://github.com/youtube/cobalt.git
PYTHONPATHenvironment variable to include the full path to the top-level
cobaltdirectory from the previous step.
Set up Developer Tools
Enter your new
$ cd cobalt
Create a virtual evnrionment by running the following in cmd:
py -3 -m venv "%HOME%/.virtualenvs/cobalt_dev" "%HOME%/.virtualenvs/cobalt_dev/Scripts/activate.bat" pip install -r requirements.txt
Or the following in Powershell:
py -3 -m venv $env:HOME/.virtualenvs/cobalt_dev $env:HOME/.virtualenvs/cobalt_dev/Scripts/activate.ps1 pip install -r requirements.txt
Or the following in Git Bash:
py -3 -m venv ~/.virtualenvs/cobalt_dev source ~/.virtualenvs/cobalt_dev/Scripts/activate pip install -r requirements.txt
Install the pre-commit hooks:
$ pre-commit install -t post-checkout -t pre-commit -t pre-push --allow-missing-config $ git checkout -b <my-branch-name> origin/main
Build and Run Cobalt
Build the code running the following command in the top-level
cobaltdirectory. You must specify a platform when running this command. On Windows the canonical platform is
You can also use the
-ccommand-line flag to specify a
build_type. Valid build types are
gold. If you specify a build type, the command finishes sooner. Otherwise, all types are built.
$ python cobalt/build/gn.py [-c <build_type>] -p <platform>
Compile the code from the
$ ninja -C out/<platform>_<build_type> <target_name>
The previous command contains three variables:
<platform>is the platform configuration that identifies the platform. As described in the Starboard porting guide, it contains a
linux) and a
x64x11), separated by a hyphen. For Windows builds use win-win32.
<build_type>is the build you are compiling. Possible values are
<target_name>is the name assigned to the compiled code and it is used to run the code compiled in this step. The most common names are
cobaltbuilds the Cobalt app.
nplbbuilds Starboard's platform verification test suite to ensure that your platform's code passes all tests for running Cobalt.
allbuilds all targets.
ninja -C out/win-win32_debug cobalt
This command compiles the Cobalt
debugconfiguration for the
win-win32platform and creates a target named
cobaltthat you can then use to run the compiled code.
Run the compiled code to launch the Cobalt client:
# Note that 'cobalt' was the <target_name> from the previous step. $ out/win-win32_debug/cobalt [--url=<url>]
The flags in the following table are frequently used, and the full set of flags that this command supports are in cobalt/browser/switches.cc.
Indicates that you want to use
Indicates that you want to connect to an
httpshost that doesn't have a certificate that can be validated by our set of root CAs.
Defines the startup URL that Cobalt will use. If no value is set, then Cobalt uses a default URL. This option lets you point at a different app than the YouTube app.
qa configs of Cobalt expose a feature enabling
developers to trace Cobalt's callstacks per-thread. This is not only a great way
to debug application performance, but also a great way to debug issues and
better understand Cobalt's execution flow in general.
Simply build and run one of these configs and observe the terminal output.
Cobalt on Xbox One
In order to build Cobalt for Xbox One, you will need access to Microsoft's XDK. In order to sideload and run custom apps on Xbox you will need either an Xbox devkit or the ability to put an Xbox into developer mode. Those steps are outside the scope of this document.
Cobalt makes use of several template files and a settings file to generate an
AppxManifest.xml during the ninja step. The settings can be found in
starboard/xb1/appx_product_settings.py. Most of the default values are stubs
and intended to be overwritten by developers creating their own app with Cobalt,
but they should work for local testing.
To build Cobalt for the Xbox One, set the platform to
xb1 in the gn step:
$ python cobalt/build/gn.py [-c <build_type>] -p xb1
Then specify the
cobalt_install build target in the ninja step:
ninja -C out/xb1_devel cobalt_install
Package an Appx
There's a convenience script at
starboard/xb1/tools/packager.py for packaging
the compiled code into an appx and then signing the appx with the pfx file
starboard/xb1/cert/cobalt.pfx. The source, output, and product
flags must be specified, and the only valid product for an external build is
cobalt. Here's an example usage:
python starboard/xb1/tools/packager.py -s out/xb1_devel/ -o out/xb1_devel/package -p cobalt
Once the appx has been created and signed, it can be deployed to an Xbox using the WinAppDeployCmd PowerShell command.