Stay organized with collections
Save and categorize content based on your preferences.
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.
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 git command creates a
cobalt directory that contains the repository:
$gitclonehttps://github.com/youtube/cobalt.git
Set the PYTHONPATH environment variable to include the full path to the
top-level cobalt directory from the previous step.
Set up Developer Tools
Enter your new cobalt directory:
$cdcobalt
Create a virtual evnrionment by running the following in cmd:
Build the code running the following command in the top-level cobalt
directory. You must specify a platform when running this command. On Windows
the canonical platform is win-win32.
You can also use the -c command-line flag to specify a build_type.
Valid build types are debug, devel, qa, and gold. If you
specify a build type, the command finishes sooner. Otherwise, all types
are built.
<platform> is the platform
configuration
that identifies the platform. As described in the Starboard porting
guide, it contains a family name (like linux) and a
binary variant (like x64x11), separated by a hyphen. For Windows
builds use win-win32.
<build_type> is the build you are compiling. Possible values are
debug, devel, qa, and gold.
<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
cobalt, nplb, and all:
cobalt builds the Cobalt app.
nplb builds Starboard's platform verification test suite to
ensure that your platform's code passes all tests for running
Cobalt.
all builds all targets.
For example:
ninja -C out/win-win32_debug cobalt
This command compiles the Cobalt debug configuration for the
win-win32 platform and creates a target named cobalt that
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.
Flags
allow_http
Indicates that you want to use http instead of
https.
ignore_certificate_errors
Indicates that you want to connect to an https host
that doesn't have a certificate that can be validated by our set
of root CAs.
url
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.
Debugging Cobalt
debug, devel, and 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.
AppxManifest Settings
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.
Build Cobalt
To build Cobalt for the Xbox One, set the platform to xb1 in the gn step:
$pythoncobalt/build/gn.py[-c<build_type>]-pxb1
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
located at 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:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-01-24 UTC."],[[["\u003cp\u003eThis guide provides instructions for Windows users to set up their Cobalt development environment, including installing necessary packages and cloning the code repository.\u003c/p\u003e\n"],["\u003cp\u003eUsers can build Cobalt binaries using GN and Ninja, specifying platform and build type for compilation, enabling local execution of the graphical client.\u003c/p\u003e\n"],["\u003cp\u003eDebugging capabilities are available through specific build configurations, offering callstack tracing to understand application performance and execution flow.\u003c/p\u003e\n"],["\u003cp\u003eCobalt can be built for Xbox One with access to Microsoft's XDK and requires additional setup and packaging steps for deployment.\u003c/p\u003e\n"]]],["To set up Cobalt for Windows, install required packages like Git, Ninja, Node.js, Python3, VS2022 components, and winflexbison, ensuring they're in your PATH. Install GN, and optionally Sccache. Clone the Cobalt repository, setting the PYTHONPATH. Use the `cobalt` directory and set up a virtual environment, install pre-commit hooks, build with `gn.py` specifying the platform and build type, and compile using Ninja. Run the compiled code using the target name and optional flags. For Xbox One, set the platform to `xb1` and use the `cobalt_install` target, package the app with the `packager.py` script, `MakeAppx` or `SignTool` and deploy using `WinAppDeployCmd`.\n"],null,["# Set up your environment - Windows\n\nThese instructions explain how Windows users can set up their Cobalt development\nenvironment, clone a copy of the Cobalt code repository, and build a Cobalt\nbinary. Note that the binary has a graphical client and must be run locally on\nthe machine that you are using to view the client. For example, you cannot SSH\ninto another machine and run the binary on that machine.\n\nSet up your workstation\n-----------------------\n\n1. Install the following required packages:\n\n - [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) (see the `Installing on Windows` instructions)\n - [ninja](https://ninja-build.org/) (see the `Getting Ninja` instructions)\n - [nodejs](https://nodejs.org/en)\n - [python3](https://www.python.org/downloads/)\n - The following [VS2022](https://visualstudio.microsoft.com/vs/) components:\n - Microsoft.VisualStudio.Component.VC.14.34.17.4.x86.x64\n - Microsoft.VisualStudio.Component.VC.Llvm.Clang\n - Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset\n - Microsoft.VisualStudio.Component.Windows10SDK.18362\n - Microsoft.VisualStudio.Workload.NativeDesktop\n - [winflexbison](https://github.com/lexxmark/winflexbison)\n\n | **Note:** By default, Cobalt's build system will check `C:\\Program Files (x86)\\` for the Visual Studio install directory. If you installed it elsewhere, you can set the `VSINSTALLDIR` environment variable to point to the correct location. For example `C:/Program Files/Microsoft Visual Studio/2022/Professional`\n2. Install GN, which we use for our build system code. There are a few ways to\n get the binary, follow the instructions for whichever way you prefer\n [here](https://cobalt.googlesource.com/third_party/gn/+/refs/heads/main/#getting-a-binary).\n\n3. (Optional)\n [Install Sccache](https://github.com/mozilla/sccache#installation) to\n support build acceleration.\n\n4. Make sure all of the above installed packages are on your Path environment\n variable.\n\n \"C:\\Program Files\\Git\"\n \"C:\\Program Files\\Ninja\"\n \"C:\\Program Files\\nodejs\"\n \"C:\\python_38\" # Python 3.8 is the oldest supported python version. You may have a newer version installed.\n \"C:\\python_38\\Scripts\"\n \"C:\\winflexbison\" # Or wherever you chose to unpack the zip file\n \"C:\\gn\"\n \"C:\\sccache\"\n\n5. Clone the Cobalt code repository. The following `git` command creates a\n `cobalt` directory that contains the repository:\n\n $ git clone https://github.com/youtube/cobalt.git\n\n | **Note:** If you plan to contribute to the Cobalt codebase it is recommended that you create your own [fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks) of the [Cobalt repository](https://github.com/youtube/cobalt), apply changes to the fork, and then [create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) to merge those changes into the Cobalt repository.\n6. Set the `PYTHONPATH` environment variable to include the full path to the\n top-level `cobalt` directory from the previous step.\n\n### Set up Developer Tools\n\n1. Enter your new `cobalt` directory:\n\n $ cd cobalt\n\n2. Create a virtual evnrionment by running the following in cmd:\n\n py -3 -m venv \"%HOME%/.virtualenvs/cobalt_dev\"\n \"%HOME%/.virtualenvs/cobalt_dev/Scripts/activate.bat\"\n pip install -r requirements.txt\n\n Or the following in Powershell: \n\n py -3 -m venv $env:HOME/.virtualenvs/cobalt_dev\n $env:HOME/.virtualenvs/cobalt_dev/Scripts/activate.ps1\n pip install -r requirements.txt\n\n Or the following in Git Bash: \n\n py -3 -m venv ~/.virtualenvs/cobalt_dev\n source ~/.virtualenvs/cobalt_dev/Scripts/activate\n pip install -r requirements.txt\n\n3. Install the pre-commit hooks:\n\n $ pre-commit install -t post-checkout -t pre-commit -t pre-push --allow-missing-config\n $ git checkout -b \u003cmy-branch-name\u003e origin/main\n\nBuild and Run Cobalt\n--------------------\n\n1. Build the code running the following command in the top-level `cobalt`\n directory. You must specify a platform when running this command. On Windows\n the canonical platform is `win-win32`.\n\n You can also use the `-c` command-line flag to specify a `build_type`.\n Valid build types are `debug`, `devel`, `qa`, and `gold`. If you\n specify a build type, the command finishes sooner. Otherwise, all types\n are built. \n\n $ python cobalt/build/gn.py [-c \u003cbuild_type\u003e] -p \u003cplatform\u003e\n\n2. Compile the code from the `cobalt/` directory:\n\n $ ninja -C out/\u003cplatform\u003e_\u003cbuild_type\u003e \u003ctarget_name\u003e\n\n The previous command contains three variables:\n 1. `\u003cplatform\u003e` is the [platform\n configuration](../starboard/porting.md#1-enumerate-and-name-your-platform-configurations) that identifies the platform. As described in the Starboard porting guide, it contains a `family name` (like `linux`) and a `binary variant` (like `x64x11`), separated by a hyphen. For Windows builds use win-win32.\n 2. `\u003cbuild_type\u003e` is the build you are compiling. Possible values are `debug`, `devel`, `qa`, and `gold`.\n 3. `\u003ctarget_name\u003e` 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 `cobalt`, `nplb`, and `all`:\n - `cobalt` builds the Cobalt app.\n - `nplb` builds Starboard's platform verification test suite to ensure that your platform's code passes all tests for running Cobalt.\n - `all` builds all targets.\n\n For example: \n\n ninja -C out/win-win32_debug cobalt\n\n This command compiles the Cobalt `debug` configuration for the\n `win-win32` platform and creates a target named `cobalt` that\n you can then use to run the compiled code.\n3. Run the compiled code to launch the Cobalt client:\n\n # Note that 'cobalt' was the \u003ctarget_name\u003e from the previous step.\n $ out/win-win32_debug/cobalt [--url=\u003curl\u003e]\n\n The flags in the following table are frequently used, and the full set\n of flags that this command supports are in\n [cobalt/browser/switches.cc](https://github.com/youtube/cobalt/blob/main/cobalt/browser/switches.cc).\n\n | Flags ||\n |-----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n | `allow_http` | Indicates that you want to use `http` instead of `https`. |\n | `ignore_certificate_errors` | Indicates that you want to connect to an `https` host that doesn't have a certificate that can be validated by our set of root CAs. |\n | `url` | 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. |\n\nDebugging Cobalt\n----------------\n\n`debug`, `devel`, and `qa` configs of Cobalt expose a feature enabling\ndevelopers to trace Cobalt's callstacks per-thread. This is not only a great way\nto debug application performance, but also a great way to debug issues and\nbetter understand Cobalt's execution flow in general.\n\nSimply build and run one of these configs and observe the terminal output.\n\nCobalt on Xbox One\n------------------\n\nIn order to build Cobalt for Xbox One, you will need access to Microsoft's XDK.\nIn order to sideload and run custom apps on Xbox you will need either an Xbox\ndevkit or the ability to put an Xbox into developer mode. Those steps are\noutside the scope of this document.\n\n### AppxManifest Settings\n\nCobalt makes use of several template files and a settings file to generate an\nAppxManifest.xml during the ninja step. The settings can be found in\n`starboard/xb1/appx_product_settings.py`. Most of the default values are stubs\nand intended to be overwritten by developers creating their own app with Cobalt,\nbut they should work for local testing.\n| **Note:** if you change the value of `PUBLISHER` in `appx_product_settings.py` you **must** regenerate a pfx file in order for the packaging step below to work correctly. Follow the instructions in `starboard/xb1/cert/README.md` to generate your own pfx.\n\n### Build Cobalt\n\nTo build Cobalt for the Xbox One, set the platform to `xb1` in the gn step: \n\n $ python cobalt/build/gn.py [-c \u003cbuild_type\u003e] -p xb1\n\nThen specify the `cobalt_install` build target in the ninja step: \n\n ninja -C out/xb1_devel cobalt_install\n\n### Package an Appx\n\nThere's a convenience script at `starboard/xb1/tools/packager.py` for packaging\nthe compiled code into an appx and then signing the appx with the pfx file\nlocated at `starboard/xb1/cert/cobalt.pfx`. The source, output, and product\nflags must be specified, and the only valid product for an external build is\n`cobalt`. Here's an example usage: \n\n python starboard/xb1/tools/packager.py -s out/xb1_devel/ -o out/xb1_devel/package -p cobalt\n\nAlternatively, you can use the\n[MakeAppx](https://learn.microsoft.com/en-us/windows/win32/appxpkg/make-appx-package--makeappx-exe-)\nand\n[SignTool](https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool)\nPowerShell commands to manually perform those steps.\n\nOnce the appx has been created and signed, it can be deployed to an Xbox using\nthe\n[WinAppDeployCmd](https://learn.microsoft.com/en-us/windows/uwp/packaging/install-universal-windows-apps-with-the-winappdeploycmd-tool)\nPowerShell command."]]