11 BuildInstructionsGettingTheCode
Nicolas Auvray edited this page 2024-08-25 09:07:33 +02:00

This page explains how to download the development tools and the source code of 0 A.D., in order to start developing. If you are a user wanting to test the latest development version, or a package maintainer testing packaging on a version resembling a release, you should use the NightlyBuild repository instead.

You may be interested in BuildAndDeploymentEnvironment for a general description of the development environment.

Necessary tools

Windows

Git

0 A.D. is developed using git as a version control system.

  • If you are confortable with using git through command-line, just download and install Git for Windows. If you wish to change default installer options, make sure you still install the Git LFS extension.
  • If you are not familiar with command-line git, or prefer using a GUI, we recommend downloading and installing TortoiseGit. Make sure you reboot when it asks you to.

Subversion (SVN)

Some binaries (specifically bundled libraries) are served over Subversion.

  • Download and install TortoiseSVN. In the installer options, make sure you install the command line client tools option, and reboot when it asks you to.

macOS

  • Git is part of the Xcode Command Line Tools package, and can be installed via the GUI or the terminal.
xcode-select --install
brew install git-lfs
  • SVN is no longer part of the Xcode Command Line Tools package, but can be installed, e.g. via Homebrew.
brew install svn

Linux

Git

git is usually present on modern distributions of Linux, however, you might need to install it in some cases. You also need to install the Git LFS extension.

Depending on your Linux distribution, the method for installing packages might differ. For instance, on Ubuntu it would be:

sudo apt update
sudo apt install git git-lfs

Subversion (SVN)

Subversion is probably not installed by default on your system, but it is easily found in package managers. Depending on your Linux distribution, the method for installing packages might differ. For instance, on Ubuntu it would be:

sudo apt update
sudo apt install subversion

Getting the code

The git repository contains the 0 A.D. source code as well as all the game binaries (images, 3D models, game maps, music, fonts). Those binaries are handled using Git LFS, a git extension for holding large files: make sure you installed it as explained above.

The source code itself weighs around 100MiB. The binaries weigh around 12GiB (6GiB that are duplicated between the objects under .git and the checked-out files). Building the libraries and the engine will also take up a couple GiB, which can be reclaimed if needed. So we recommend having around 25GiB free to be safe.

Important: Avoid placing your development environment in a path containing special characters (spaces or non-ASCII characters).

Before downloading the git repository for the first time, make sure that Git LFS is properly configured on your system: you must run the following command once:

git lfs install

To checkout the latest version of the source code, run

git clone https://gitea.wildfiregames.com/0ad/0ad.git

For slow connections

If your Internet connection is slow or prone to hiccups, it it strongly recommended to clone the git repository without LFS files (only 100MiB), then pull the LFS files which is a resumable operation. To do that, run

GIT_LFS_SKIP_SMUDGE=1 git clone https://gitea.wildfiregames.com/0ad/0ad.git
cd 0ad
git lfs pull # if that command fails after a while, run it again to resume the download

For disk-constrained environments

If you have very little disk space to spare, you can save several GiB by removing the duplication of LFS assets between the .git directory and the repository folders. After git lfs pull, you can run

git lfs prune --force

to remove copies of binaries in the .git folder. Those copies will slowly reappear over time whenever you update binary files.

If you are using a filesystem that supports deduplication, such as ZFS or BTRFS, you will find the command

git lfs dedup

very useful, as it uses your filesystem capabilities to avoid the duplication of those 6 GiB.

For package maintainers and CI/CD environments

If you only plan to build the game engine and run the tests, you do not need to pull the entire repository. You only need the source (only 100MiB) and a couple test binaries (under binaries/data/{tests,mods/_test.foo}). Pulling and building the libraries and the engine will take up around ( - 160Mo). To do that, run

GIT_LFS_SKIP_SMUDGE=1 git clone https://gitea.wildfiregames.com/0ad/0ad.git
cd 0ad
git lfs pull -I binaries/data/tests
git lfs pull -I "binaries/data/mods/_test.*"
# then proceed to the build instructions

Translations

If you don't want to play and test in English, or if you want to test the translations, you can export the latest translations from the NightlyBuild. To do that, go to source/tools/i18n and run the get-nightly-translations script.

Vulkan shaders

If you want to run the game with the Vulkan graphics backend, you need SPIR-V shaders. Those are not included in the git repository to avoid frequent and massive changes. However, you can export them from the latest NightlyBuild. To do that, go to source/tools/spirv and run the get-nightly-shaders script.

Building and running the game

When you have pulled the code, you can proceed to the BuildInstructions.