Skip to main content

Overview

The xb (xenia-build) script is a Python-based build tool that orchestrates the entire Xenia build process. It wraps premake5, git operations, and platform-specific build tools.
The xb command is a wrapper for xenia-build.py. You can use either:
  • xb <command> (if xb is in your PATH)
  • python xenia-build.py <command>

Requirements

  • Python 3.9+ (64-bit)
  • Git
  • Platform-specific build tools (Visual Studio, Clang, etc.)

Core Commands

setup

Initializes the build environment by setting up git submodules and running premake.
string
Target OS for cross-compilation (e.g., android)
What it does:
  1. Initializes and updates git submodules
  2. Runs premake to generate platform-specific project files
  3. Generates build/version.h with git version information

build

Builds the project using the platform’s native build tools.
string
default:"debug"
Build configuration: debug, checked, or release
string
Specific target(s) to build. Can be specified multiple times.
boolean
Forces a full rebuild (clean + build)
boolean
Skips running premake before building
string
Compiler toolchain: clang, gcc, or msc

premake

Runs premake to update project files without building.
string
Compiler toolchain: clang, gcc, or msc
string
Development environment: vs2022, xcode4, cmake, etc.
string
Target OS for cross-compilation

devenv

Runs premake and opens the development environment (IDE).
Platform behavior:
  • Windows: Opens Visual Studio with build/xenia.sln
  • macOS: Opens Xcode
  • Linux: Opens CLion (if available), otherwise CodeLite

pull

Pulls the latest changes from the repository, updates submodules, and runs premake.
boolean
Merges instead of rebasing on canary_experimental branch
string
Target OS for premake
What it does:
  1. Switches to canary_experimental branch
  2. Pulls latest changes (with rebase by default)
  3. Updates git submodules
  4. Runs premake to update project files

Code Quality Commands

format

Formats staged code using clang-format 19.
boolean
Format all files, not just changed files
boolean
Format all files changed relative to origin/canary_experimental
clang-format version 19 is required. The script will automatically detect the correct version.

lint

Checks for lint errors using clang-format without modifying files.
boolean
Lint all files, not just changed files
boolean
Lint files changed relative to origin/canary_experimental

style

Runs cpplint style checker on all code.
Checks for style violations using cpplint against the Xenia style guide.

tidy

Runs clang-tidy static analyzer on all code.
boolean
Applies suggested fixes where possible
string
Target OS for compilation database

Maintenance Commands

clean

Removes intermediate files and build outputs.
Runs premake clean to remove build artifacts while preserving the build directory structure.

nuke

Removes all build output and performs a hard git reset.
This is a destructive operation. It will:
  1. Delete the entire build/ directory
  2. Perform a hard git reset to canary_experimental
  3. Run premake to regenerate project files
Any uncommitted changes will be lost!

Testing Commands

test

Runs automated unit tests.
string
default:"debug"
Build configuration to test
string
Specific test target(s) to run
boolean
Don’t build before running tests
boolean
Don’t stop when a test fails; run all tests
Default test targets:
  • xenia-base-tests
  • xenia-cpu-ppc-tests

gputest

Runs automated GPU diff tests against reference imagery.
string
default:"debug"
Build configuration to test
boolean
Don’t build before running tests
boolean
Update all reference imagery
boolean
Create reference files for new traces

gentests

Generates test binaries from PowerPC assembly files.
What it does:
  1. Finds all .s assembly files starting with instr_ or seq_ in src/
  2. Assembles them using PowerPC binutils
  3. Generates test binaries in src/xenia/cpu/ppc/testing/bin/
Required for CPU test development. Run after modifying .s test files.

Advanced Commands

buildshaders

Generates shader binaries for inclusion in C++ files.
string
Shader target: dxbc (Direct3D) or spirv (Vulkan). Can specify multiple.
Shader targets:
  • dxbc - Direct3D 12 Shader Model 5.1 (Windows only)
  • spirv - Vulkan SPIR-V (all platforms)
Requirements:
  • DXBC: Windows with FXC (from Windows SDK)
  • SPIR-V: VULKAN_SDK environment variable set, with glslangValidator and spirv-opt

stub

Creates new source files with copyright headers.
string
Generate a single source file at the specified path
string
Generate a class pair (.cc and .h) at the specified path
string
Target OS for premake
All paths are relative to src/xenia/. The command will:
  1. Generate files with copyright headers
  2. Run premake to update project files

Common Workflows

First-Time Setup

1

Clone repository

2

Initial setup

3

Build

Daily Development

1

Pull latest changes

2

Make changes and build

3

Format code

4

Run tests

Before Committing

Clean Build

Passing Arguments to Build Tools

You can pass additional arguments to the underlying build tools using --:

Environment Variables

Linux/macOS

Windows

Troubleshooting

Use the full Python command:
Or add the xenia-canary directory to your PATH.
Ensure you have Python 3.9+ 64-bit:
Install Visual Studio 2022 with C++ development tools. The script uses vswhere.exe to locate it.
Install Clang 19 and set environment variables:
Install clang-format 19:Ubuntu/Debian:
Windows: Install via Visual Studio or download LLVM 19.

Quick Reference

Next Steps

Windows Build

Detailed Windows build guide

Linux Build

Linux build instructions

Build Setup

Build system overview