Build From Source - stalbordboat/GameEngine GitHub Wiki

Table Of Contents

Introduction

There's no plan to deliver an official pre-built binary package, it must be compiled from source. This can be done in many different ways if you're already experienced with building from source, but in order to keep this simple, this guide will focus on one of those ways. More experienced people can skip different parts of this if they wish. The majority of this guide focuses on building on Linux based systems. As such, there are sections of this guide for setting up a Linux-like environment on Windows and for specific prerequisite tools needed to build on MacOS. After that set up you should be able to follow the rest of the guide, even if you're not on Linux! If not, don't be afraid to send me an issue!

Dependencies

  • Ruby
    • Used for building the GameEngine.
  • game-mruby
    • Core Ruby API
    • RITEVM a low-memory foot print virtual machine.
  • SDL3
    • Cross-Platform Hardware Abstraction API
    • Multimedia API
  • SDL3_mixer
    • An extension of the Audio API in SDL3. This implements mixing functionality(i.e. playback, fades, etc.)
    • Currently this relies on the sdl2-api-on-sdl3 branch, since sdl3-mixer just came out; migration to release-3.2.x will happen soon.
  • PhysFS
    • Archive Format Filesystem Abstraction API

Setting Things Up On Windows

Windows is not a Unix-like system so unlike MacOS an entire Linux-compatibility layer will be needed. MSYS2 is the best in the game! Once you have that set up, you're gonna want to focus on using the MINGW64 environment, this includes packages good for native Windows development.

Setting Things Up On MacOS

MacOS is already Unix-like, but in-order to develop anything you'll need X Code. Once you have the X Code utilities set up you can follow the rest of this guide with ease. I also recommend getting the Homebrew package manager for installing packages.

Getting Base Development Tools

Install Git from a package manager:

Arch Based Systems:

pacman -Sy git cmake base-devel

Debian Based Systems:

apt install build-essential pkg-config

Setup Safe Install Path

Typically most projects are configured to install to /usr/local, but this requires superuser/root access. We want to steer clear of that for now. Instead, we want to setup our environment to a user specific install path. Include this in your .bashrc or your .zshrc(if your use zsh as your shell.)

# This will append this user's bin path to system's list of bin paths to find the command.
export PATH=$PATH:$HOME/.local/bin

# This will append this user's pkgconfig path so that pkg-config can find package configurations.
export PKG_CONFIG_PATH="$HOME/.local/lib/pkgconfig"

Getting Ruby

We'll get the latest stable version of Ruby and build it from source:

Configure the system. Here set the install prefix to $HOME/.local to the user's local directory:

./configure --prefix=$HOME/.local

Send the build command:

make

Send the install command:

make install

Check if its installed:

ruby -v

Send the Cleanup command:

make clean

Getting SDL3

Clone the release-3.4.x branch, the GameEngine relies on this version family. We only care about cloning that single branch in this case:

git clone --branch release-3.4.x --single-branch https://github.com/libsdl-org/SDL.git

Change directories into the source's directory:

cd SDL

cmake is more complicated to run than the configure script Ruby used above, so we'll use this Rakefile to automate the build instead. Copy and paste the code below into a file called Rakefile. This is will be used in the next build as well:

# General Documentation:    https://ruby.github.io/rake/
# Domain-Specific Language: https://ruby.github.io/rake/Rake/DSL.html

# TOOLS

TOOL              = 'cmake'

# Paths

BUILD_DIRNAME     = 'build'
SOURCE_DIRNAME    = '.'
PREFIX            = ENV['PREFIX'] || "#{Dir.home}/.local"

# Commands and Options

# This might something like: -D CMAKE_TOOLCHAIN_FILE=mingw64.cmake
TOOLCHAIN_PATH    = ENV['TOOLCHAIN_PATH'] || ''
CONFIGURE_OPTIONS = [
                      "-B #{BUILD_DIRNAME}",
                      "-S #{SOURCE_DIRNAME}",
                      "-D CMAKE_INSTALL_PREFIX=#{PREFIX}",
                      TOOLCHAIN_PATH,
                    ].join(' ')
BUILD_OPTIONS     = "--build #{BUILD_DIRNAME}"

INSTALL_OPTIONS   = "--install #{BUILD_DIRNAME} --prefix #{PREFIX}"
UNINSTALL_CMD     = 'make uninstall'
VERBOSE           = true

# Tasks

task :default => :all

desc 'Automate the configuration, building and installation processes'
task :all do
  %w(configure build install).each { |t| Rake::Task[t].invoke }
end

desc 'Automate the configure + generation process'
task :configure do
  sh "#{TOOL} #{CONFIGURE_OPTIONS}"
end

desc 'Automate the build process'
task :build do
  sh "#{TOOL} #{BUILD_OPTIONS}"
end

desc 'Automate the installation process'
task :install do
  sh "#{TOOL} #{INSTALL_OPTIONS}"
end

desc 'Automate the installation files removal process'
task :uninstall do
  FileUtils.cd(BUILD_DIRNAME, verbose: VERBOSE) { sh UNINSTALL_CMD }
end

desc 'Automate the removal of the build directory'
task :clean do
  FileUtils.rm_rf BUILD_DIRNAME, verbose: VERBOSE
end

To see the list of tasks run this command:

rake -T

Send configure, build, and install(to $HOME/.local/) commands:

rake

Send cleanup command:

rake clean

Exit this directory:

cd ..

Getting SDL3_mixer

Currently this relies on the sdl2-api-on-sdl3 branch, since sdl3-mixer just came out; migration to release-3.2.x will happen soon.

Clone the repository:

git clone --branch sdl2-api-on-sdl3 --single-branch https://github.com/stalbordboat/SDL_mixer.git

Change directories into the source's directory:

cd SDL_mixer

This repository already has the Rakefile so we can just run the following commands:

Send configure, build, and install(to $HOME/.local/) commands:

rake

Send cleanup command:

rake clean

Exit this directory:

cd ..

Getting Physfs

Clone the stable-3.2 branch, the GameEngine relies on this version family. We only care about cloning that single branch in this case:

git clone --branch stable-3.2 --single-branch https://github.com/icculus/physfs.git

Change into the directory:

cd physfs

Send configure, build, and install(to $HOME/.local/) commands:

rake

Send cleanup command:

rake clean

Exit this directory:

cd ..

Getting game-mruby

Clone the stable branch. We only care about cloning that single branch in this case:

git clone --branch stable --single-branch https://github.com/stalbordboat/game-mruby.git

Send configure, and build(to $HOME/.local/) commands:

rake

Send install(to $HOME/.local/) commands:

rake install

Send cleanup command:

rake clean

Exit this directory:

cd ..

Getting The GameEngine

Download the stable package.

Verify the package's integrity:

echo "<checksum> GameEngine-0.1.2.zip" | sha256sum -c -

If the output reads: GameEngine-0.1.2.zip: OK then unzip it then cd into the directory.

Send build silently:

rake -s

Send install silently:

rake -s install

Send cleanup command:

rake -s clean

Try it out

Add this line of code to the Start.rb

Log.info 'Ok!'

then send the game command:

game

Next Article

⚠️ **GitHub.com Fallback** ⚠️