Skip to content

Commit

Permalink
Merge pull request Astrabit-ST#53 from Speak2Erase/master
Browse files Browse the repository at this point in the history
Add static build option
  • Loading branch information
Matthew Lyons authored May 2, 2022
2 parents 6944074 + edb9776 commit 8f8457a
Show file tree
Hide file tree
Showing 7 changed files with 682 additions and 661 deletions.
39 changes: 18 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ModShot-Core
[![Build ModShot Ubuntu ](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-ubuntu.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-ubuntu.yml)[![Build ModShot Windows](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-windows.yml/badge.svg)](https://github.com/Astrabit-ST/ModShot-Core/actions/workflows/build-windows.yml)
---

This is a even more MORE specialized fork of a specialized fork of ([mkxp by Ancurio](https://github.com/Ancurio/mkxp) designed for [*OneShot*](http://oneshot-game.com/)) for OneShot mods.

Expand Down Expand Up @@ -28,17 +27,30 @@ The main upshot of this, of course, is remaining on par with ruby in terms of ge
Previously, C extensions were very jank with ModShot, **however** now you can use a C extension right from your own Ruby install!
(Provided the version is the same, and the msys2 evironment is the same. I'll get back to this later.)

# Building on Windows
## Build options

Unfortunately because of the way ModShot is set up, you will need to pass build options to Make **and** Meson, if it pertains to dependencies. (ruby ver, opt level, etc.)

# Options

```
RUBY_VER && -Dmri_version (default 3.1) sets the ruby version.
-Dsteam (default false) sets the build to use steam.
--build-type (default Release) sets the build type.
-Dbuild_static (default true) sets the build to be static. (True is faster, but with longer startup times.)
```

## Building on Windows

First, you'll need to download [msys2](https://www.msys2.org/) and install it.
Then, you'll want to determine what Ruby version you're using, as this will determine what build environment you'll be using.
As is, ModShot is set up to use Ruby 3.1, so keep that in mind. Please refer to this table to determine the environment.
(You *can* use the wrong environment and it will work fine, just not with C extensions.)

```
Ruby >3.1 UCRT64
Ruby >3.1 UCRT64 (Default)
Ruby 3.0-2.0 MINGW64
Ruby <1.9 MINGW32
Ruby <1.9 MINGW32 (NOT SUPPORTED!)
```

Once you've figured out the environment you need to use, pull up an msys2 shell of it.
Expand All @@ -57,10 +69,10 @@ cd ..; meson build --prefix="$PWD/build.out" --bindir=.
cd build && ninja install
```

# Building on Linux
## Building on Linux

Building on Linux is fairly easy, as long as you're using one of the supported distros. (Manjaro, Debian/Ubuntu, Fedora/Red Hat)
Unlinke Windows, you don't have to worry about msys2 environments. Just use gcc and you'll be good to go.
Unlike Windows, you don't have to worry about msys2 environments. Just use gcc and you'll be good to go.
If you're not, fear not, as you can usually just install all the dependencies right from your package manager. See `setup.sh`.

```sh
Expand All @@ -77,21 +89,6 @@ cd build && ninja install

This should create a folder called `out` with your build of ModShot all ready to go!

## Sepecific ruby versions

When running `make` in the second step, you'll want to pass in an argument telling make what Ruby version to use:
```sh
make RUBY_VER='3.0'
```
This is a blunt method however and will not let you use a specific exact version, just a specific version with a major number.

Then, in the meson step, pass in an argument to specify the Ruby version:
```sh
meson build build --prefix="$PWD/build.out" --bindir=. -Dmri_version="3.0"
```

ModShot should handle the rest.

## Configuration

*ModShot* reads configuration data from the file "oneshot.conf". The format is ini-style. Do *not* use quotes around file paths (spaces won't break). Lines starting with '#' are comments. See 'oneshot.conf.sample' for a list of accepted entries. Note that this feature appears to be brpken for the moment until we get around to fixing it. Using command line options does work, however.
Expand Down
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ if get_option('steam') == true
steam = true
endif

build_static = false
if get_option('build_static') == true
build_static = true
endif

subdir('src')
subdir('binding-mri')
subdir('shader')
Expand Down
2 changes: 2 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ option('workdir_current', type: 'boolean', value: false, description: 'Keep curr

option('steam', type: 'boolean', value: false, description: 'Add steamworks support')

option('build_static', type: 'boolean', value: true, description: 'Use static libraries')

option('gfx_backend', type: 'combo', value: 'gl', choices: ['gl', 'gles'], description: 'Graphics rendering API to use.')
6 changes: 3 additions & 3 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if [[ $OSTYPE == msys ]]; then
echo "* Installing dependencies..."
pacman -S pactoys --noconfirm
pacboy -S libtool: autoconf: automake: git: gcc:p make:p cmake:p bison: doxygen:p ruby:p \
SDL2:p SDL2_image:p SDL2_ttf:p openal:p vim: \
SDL2:p SDL2_image:p SDL2_ttf:p openal:p vim: freetype:p \
physfs:p pixman:p libwebp:p zlib:p meson:p clang:p \
bzip2:p libvorbis:p libogg:p zeromq:p libsigc++:p \
boost:p libpng:p libjpeg-turbo:p libtiff:p --noconfirm
Expand All @@ -19,7 +19,7 @@ else
libphysfs-dev libpixman-1-dev libwebp-dev libbz2-dev \
libvorbis-dev libogg-dev libsodium-dev libboost-dev libpng-dev \
libjpeg-dev libtiff-dev libsigc++-2.0-dev meson vim libgtk2.0-dev \
libxfconf-0-dev
libxfconf-0-dev libfreetype-dev

fi

Expand All @@ -31,7 +31,7 @@ else
libpng libjpeg libtiff zeromq mm-common base-devel vim gtk2
echo "* Installing dependencies with pamac..."
sudo pamac install sdl2_image sdl2_ttf physfs boost boost-libs \
libsigc++ sdl_sound m4 meson --no-confirm
libsigc++ sdl_sound m4 meson freetype --no-confirm
fi

if [[ $(cat /etc/redhat-release) ]]; then
Expand Down
13 changes: 13 additions & 0 deletions src/audio/headers/al-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define AL_ALEXT_PROTOTYPES
#include <al.h>
#include <efx.h>
#include <alext.h>
#include <SDL2/SDL_audio.h>
#include <assert.h>

Expand Down Expand Up @@ -319,6 +320,10 @@ inline uint8_t formatSampleSize(int sdlFormat)
case AUDIO_S16MSB :
return 2;

case AUDIO_F32LSB :
case AUDIO_F32MSB :
return 4;

default :
assert(!"Unhandled sample format");
}
Expand All @@ -343,6 +348,14 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount)
case 1 : return AL_FORMAT_MONO16;
case 2 : return AL_FORMAT_STEREO16;
}

case 4 :
switch (channelCount)
{
case 1 : return AL_FORMAT_MONO_FLOAT32;
case 2 : return AL_FORMAT_STEREO_FLOAT32;
}

default :
assert(!"Unhandled sample size / channel count");
}
Expand Down
34 changes: 19 additions & 15 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
boost = dependency('boost', version: '>=1.49', modules: ['program_options'])
physfs = dependency('physfs', version: '>=2.1')
boost = dependency('boost', version: '>=1.49', modules: ['program_options'], static: build_static)
physfs = dependency('physfs', version: '>=2.1', static: build_static)
openal = dependency('openal')
vorbisfile = dependency('vorbisfile')
vorbis = dependency('vorbis')
ogg = dependency('ogg')
vorbisfile = dependency('vorbisfile', static: build_static)
vorbis = dependency('vorbis', static: build_static)
ogg = dependency('ogg', static: build_static)
sdl2 = dependency('SDL2')
sdl_sound = compilers['cpp'].find_library('SDL2_sound')
sdl2_ttf = dependency('SDL2_ttf')
sdl2_image = dependency('SDL2_image')
sigcxx = dependency('sigc++-2.0')
pixman = dependency('pixman-1')
png = dependency('libpng')
jpeg = dependency('libjpeg')
zlib = dependency('zlib')
nsgif = dependency('libnsgif')
freetype = dependency('freetype', static: build_static)
sdl_sound = dependency('SDL2_sound', static: build_static)
sdl2_ttf = dependency('SDL2_ttf', static: build_static)
sdl2_image = dependency('SDL2_image', static: build_static)
sigcxx = dependency('sigc++-2.0', static: build_static)
pixman = dependency('pixman-1', static: build_static)
png = dependency('libpng', static: build_static)
jpeg = dependency('libjpeg', static: build_static)
tiff = dependency('libtiff-4', static: build_static)
webp = dependency('libwebp', static: build_static)
zlib = dependency('zlib', static: build_static)
nsgif = dependency('libnsgif', static: build_static)

if host_system == 'windows'
bz2 = dependency('bzip2')
Expand Down Expand Up @@ -48,7 +51,8 @@ global_include_dirs += include_directories('.',
'opengl/headers'
)

global_dependencies += [boost, bz2, openal, zlib, sdl2, sdl_sound, pixman, physfs, vorbisfile, vorbis, iconv, ogg, sdl2_ttf, sigcxx, sdl2_image, png, jpeg, nsgif]
global_dependencies += [boost, bz2, openal, zlib, sdl2, sdl_sound, pixman, physfs, vorbisfile, vorbis, iconv, ogg, sdl2_ttf, sigcxx, sdl2_image, png, jpeg, nsgif, freetype, tiff, webp]

if host_system == 'windows'
global_dependencies += compilers['cpp'].find_library('wsock32')
global_dependencies += compilers['cpp'].find_library('winmm')
Expand Down
Loading

0 comments on commit 8f8457a

Please sign in to comment.