Build From Source - stalbordboat/GameEngine GitHub Wiki
- Introduction
- Dependencies
- Setting Things Up On Windows
- Setting Things Up On MacOS
- Getting Base Development Tools
- Setup Safe Install Path
- Getting Ruby
- Getting SDL3
- Getting SDL3_mixer
- Getting Physfs
- Getting game-mruby
- Getting The GameEngine
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!
-
Ruby- Used for building the
GameEngine.
- Used for building the
-
game-mruby- Core Ruby API
-
RITEVMa 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-sdl3branch, sincesdl3-mixerjust came out; migration torelease-3.2.xwill happen soon.
- An extension of the Audio API in
-
PhysFS- Archive Format Filesystem Abstraction API
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.
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.
Install Git from a package manager:
Arch Based Systems:
pacman -Sy git cmake base-develDebian Based Systems:
apt install build-essential pkg-configTypically 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"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/.localSend the build command:
makeSend the install command:
make installCheck if its installed:
ruby -vSend the Cleanup command:
make cleanClone 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.gitChange directories into the source's directory:
cd SDLcmake 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
endTo see the list of tasks run this command:
rake -TSend configure, build, and install(to $HOME/.local/) commands:
rakeSend cleanup command:
rake cleanExit this directory:
cd ..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.gitChange directories into the source's directory:
cd SDL_mixerThis repository already has the Rakefile so we can just run the following commands:
Send configure, build, and install(to $HOME/.local/) commands:
rakeSend cleanup command:
rake cleanExit this directory:
cd ..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.gitChange into the directory:
cd physfsSend configure, build, and install(to $HOME/.local/) commands:
rakeSend cleanup command:
rake cleanExit this directory:
cd ..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.gitSend configure, and build(to $HOME/.local/) commands:
rakeSend install(to $HOME/.local/) commands:
rake installSend cleanup command:
rake cleanExit this directory:
cd ..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 -sSend install silently:
rake -s installSend cleanup command:
rake -s cleanAdd this line of code to the Start.rb
Log.info 'Ok!'then send the game command:
game