Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
A description of how Brushfire Games uses Vagrant and the Steam Runtime to produce Linux builds of our game Polychromatic.
Brushfire Games recently announced that our next game Polychromatic would be coming to Windows, Mac, and Linux on Steam later this year. All of our development takes place on OS X and Windows, but supporting Linux is important to us. To assist in our efforts, we are leveraging Vagrant and the Steam Runtime to greatly simplify building our game for Linux.
Since we're not Linux experts, we decided to jump in with the Steam Runtime, a build/runtime environment Valve created for Linux to simplify the process of building games with libraries made for Linux. One builds in the Steam Runtime "chroot" environment which provides a number of libraries that Steam manages. This has some great benefits:
We don't have to figure out how to build the libraries in a way that work across platforms and architectures.
We don't have to distribute the libraries ourselves which reduces download size and disk usage for customers.
Building in Steam Runtime was largely just an effort of creating a Makefile and following the instructions in their Building in the Runtime section of the wiki. For our game we just had to add "-lSDL2 -lSDL2_image" to our linker flags and "-I/usr/include/SDL2" to our compiler flags and we were off and running.
I definitely recommend any developers looking into Linux consider using the runtime. You can use the runtime even if you're not shipping on Steam. Given Valve's interest in Linux as a gaming platform, it's definitely wise to lean on their experience in this area if you're not an expert.
Vagrant's tagline says it all:
Create and configure lightweight, reproducible, and portable development environments.
Vagrant is a hero in our environment, given that neither of us at Brushfire Games use Linux. As such we need a virtual machine on which to do our builds. Vagrant allows us to configure a VM and commit that configuration to our code repository while making it trivial to spin up the VM for builds.
Vagrant has pretty great documentation, but I'll outline our basic steps below which contain some specifics to our setup for building against the Steam Runtime. Here is our current Vagrantfile that you can use as a base for your own game:
Vagrant.configure(2) do |config| config.vm.box = "hashicorp/precise64" config.vm.provision "shell", privileged: false, inline: <<-SHELL sudo apt-get update sudo apt-get install -y git schroot ia32-libs ruby1.9.1 SHELL config.vm.provision "shell", privileged: false, inline: <<-SHELL echo "#!/bin/sh -ex git clone --depth 1 https://github.com/ValveSoftware/steam-runtime ~/steam-runtime cd ~/steam-runtime ./setup_chroot.sh --i386 ./setup_chroot.sh --amd64 sudo chown vagrant:vagrant /etc/schroot/default/fstab sudo echo "/vagrant /vagrant none rw,bind 0 0" >> /etc/schroot/default/fstab " > ~/setup.sh chmod +x ~/setup.sh SHELL config.vm.provision "shell", privileged: false, inline: <<-SHELL echo "#!/bin/sh -ex ruby /vagrant/script/steam-build-linux.rb " > ~/build.sh chmod +x ~/build.sh SHELL end
The basics here are that we setup a 64-bit Ubuntu 12.04 LTS VM and run three provisioning steps:
Install git and schroot (required to get and use the Steam Runtime) as well as ia32-libs (required to use Steam commandline tools on 64-bit Linux) and Ruby (required for our project scripts).
Create a setup.sh script that can be run by the user after logging into the VM. More on this below.
Create a simple wrapper script that calls into one of our build scripts. This is just a convenience for me to make it even simpler to run my builds.
Now for that setup.sh script. In my testing, trying to setup the Steam Runtime chroots directly when provisioning always failed. The chroot wouldn't be able to run "make" or "g++" which made it generally useless to me. In addition, one must modify the schroot configuration to allow the chroot to be able to see the /vagrant directory. Since I can't seem to do this in the provisioning step, the next best solution is to have it create a script with those steps so I can easily run it after setting up the VM.
With this Vagrantfile in place, I can build and upload 32- and 64-bit Linux builds by opening up a terminal and four simple commands:
vagrant up
vagrant ssh
./setup.sh
./build.sh
In those four commands I've completely setup a Linux VM, logged in, setup the full Steam Runtime environment for 32- and 64-bit, and built and uploaded the game for Steam. The best part is that I can then logout and run "vagrant destroy" to delete the VM from my hard drive. When it's this easy to spin the VM up, there's little reason to hang onto the VM longer than necessary.
If you are planning to support Linux on Steam, perhaps this article will help you in setting up a build pipeline for your game. Vagrant and the Steam Runtime have been tremendous for us in being able to reliably produce builds that work on both 32- and 64-bit flavors of all distros supported by the Steam Runtime.
Read more about:
Featured BlogsYou May Also Like