Linux AppImage support

This commit is contained in:
Eliza Velasquez 2020-06-16 15:53:22 -07:00
parent 8c3ffd303d
commit 8572f65917
6 changed files with 114 additions and 93 deletions

View file

@ -277,6 +277,8 @@ source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS})
## Setup main executable ##
set(CMAKE_CXX_STANDARD 11)
add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32
${MAIN_HEADERS}
${MAIN_SOURCE}

View file

@ -10,71 +10,42 @@ Thanks to [hunternet93](https://github.com/hunternet93) for starting the reimple
*OneShot* also makes use of [steamshim](https://hg.icculus.org/icculus/steamshim/) for GPL compliance while making use of Steamworks features. See LICENSE.steamshim.txt for details.
## Dependencies / Building
## Building (Supported on Windows, Ubuntu Linux, in progress on macOS)
* Qt5
* CMake
* Conan
* Boost.Unordered (headers only)
* Boost.Program_options
* Boost.CRC
* Vim XXD (vim-common in apt)
* libsigc++ 2.0
* PhysFS (latest hg)
* OpenAL
* SDL2
* SDL2_image
* SDL2_ttf
* [Ancurio's SDL_sound fork](https://github.com/Ancurio/SDL_sound)
* vorbisfile
* pixman
* OpenGL header (alternatively GLES2 with `DEFINES+=GLES2_HEADER`)
* Ruby
* Python 3 (journal reimplementation only)
* PyQt5 for Python 3 (journal reimplementation only)
* Steamworks SDK (optional, place contents of sdk folder in ZIP into "steamworks" folder in root)
Preface: This only supports Visual Studio on Windows and Xcode on macOS. Ubuntu should work with either GCC or clang. You can probably compile with other platforms/setups, but beware.
### Building with QMake
The `make-oneshot-mac.command` and `make-oneshot-linux.sh` files automate the entire process for you. Just run the applicable file to compile and install the engine into OneShot's default Steam directory.
qmake will use pkg-config to locate the respective include/library paths. If you installed any dependencies into non-standard prefixes, make sure to adjust your `PKG_CONFIG_PATH` variable accordingly.
The exception is boost, which is weird in that it still hasn't managed to pull off pkg-config support (seriously?). *If you installed boost in a non-standard prefix*, you will need to pass its include path via `BOOST_I` and library path via `BOOST_L`, either as direct arguments to qmake (`qmake BOOST_I="/usr/include" ...`) or via environment variables. You can specify a library suffix (eg. "-mt") via `BOOST_LIB_SUFFIX` if needed.
By default, *OneShot* switches into the directory where its binary is contained and then starts reading the configuration and resolving relative paths. In case this is undesired (eg. when the binary is to be installed to a system global, read-only location), it can be turned off by adding `DEFINES+=WORKDIR_CURRENT` to qmake's arguments.
pkg-config will look for `ruby-2.3.pc`, but you can override the version with `MRIVERSION=2.5` ('2.5' being an example). This is the default binding, so no arguments to qmake needed (`BINDING=MRI` to be explicit).
### Building with Conan (Supported on Windows, in progress on macOS/Linux)
Preface: This currently only supports Visual Studio on Windows and Xcode on macOS. Linux should work with either GCC or clang.
*OneShot* used to employ the `qmake` build system, but is now migrating to `conan`, so you'll need to install that beforehand (via `pip install conan`). You'll also want to add the following remotes to `conan`:
With Python 3 and pip installed, install Conan via `pip3 install conan`. Afterwards, add the necessary package repositories by adding running the following commands:
```sh
conan remote add eliza "https://api.bintray.com/conan/eliza/conan"
conan remote add bincrafters "https://api.bintray.com/conan/bincrafters/public-conan"
```
On Windows, you may need to edit `C:\Users\[username]\.conan\profiles\default` and add the following line in `[settings]` ("v141" is the current toolset version at the time of this writing):
Prepare to build *OneShot* by installing the necessary dependencies with Conan.
```sh
compiler.toolset=v141
cd mkxp-oneshot
mkdir build
cd build
conan install .. --build=missing
```
Next, you can install all the required packages:
Hopefully, this should complete without error. It may take quite a while to build all of the dependencies.
On Ubuntu, make sure you install the necessary dependencies before building *OneShot* proper:
```sh
conan install . --build=missing
sudo apt install libgtk2.0-dev libxfconf-0-dev
```
Finally, you can build the project by running the following:
```sh
conan build .
conan build ..
```
On Ubuntu, you may now run `../make-appimage.sh .. . /path/to/game/files /some/path/OneShot.AppImage` to create an AppImage. Requires [linuxdeploy](https://github.com/linuxdeploy/linuxdeploy) and [AppImageTool](https://github.com/AppImage/AppImageKit) in your `PATH`.
### Supported image/audio formats
These depend on the SDL auxiliary libraries. *OneShot* only makes use of bmp/png for images and oggvorbis/wav for audio.

9
assets/oneshot.desktop Normal file
View file

@ -0,0 +1,9 @@
[Desktop Entry]
Type=Application
Name=OneShot
Exec=oneshot %F
Comment=A surreal puzzle adventure game with unique mechanics / capabilities.
Icon=oneshot
Categories=Game;
Terminal=false
X-AppImage-Arch=x86_64

BIN
assets/oneshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

39
make-appimage.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash -eu
LINUXDEPLOY=linuxdeploy-x86_64.AppImage
APPIMAGETOOL=appimagetool-x86_64.AppImage
if [ $# -lt 3 ]; then
echo "usage: linuxdeploy.sh SOURCE_PATH CONAN_INSTALL_PATH GAME_PATH APPIMAGE_FILE"
fi
source_path="$1"
conan_install_path="$2"
game_path="$3"
appimage_file="$4"
appdir="$(mktemp -d)"
function atexit {
[ -n "$appdir" ] && rm -rf "$appdir"
}
trap atexit EXIT
$LINUXDEPLOY -e "$conan_install_path/bin/oneshot" \
-l "$conan_install_path/lib/libruby.so.2.5.3" \
-i "$source_path/assets/oneshot.png" \
-d "$source_path/assets/oneshot.desktop" \
--appdir "$appdir"
# Populate remaining AppImage spec files
# ln -sf bin/oneshot "$appdir/AppRun"
# cp -f "$source_path/assets/oneshot.png" "$appdir/oneshot.png"
# Bundle game data
for dir in Audio Data Fonts Graphics Languages Wallpaper; do
cp -ra "$game_path/$dir" "$appdir/usr/bin/"
done
cp -a "$conan_install_path/bin/Data/xScripts.rxdata" "$appdir/usr/bin/Data/"
# Create AppImage
ARCH=x86_64 $APPIMAGETOOL "$appdir" "$appimage_file"

View file

@ -118,11 +118,11 @@ find_program(RUBY_EXE ruby
set(game_dir "${CMAKE_BINARY_DIR}/bin")
set(data_dir "${game_dir}/Data")
set(xscripts "${data_dir}/xScripts.rxdata")
add_custom_target(build-time-make-directory ALL
add_custom_target(data_dir ALL
COMMAND ${CMAKE_COMMAND} -E make_directory "${data_dir}")
add_custom_command(
OUTPUT "${xscripts}"
COMMAND "${RUBY_EXE}" "${CMAKE_SOURCE_DIR}/rpgscript.rb" "${CMAKE_CURRENT_LIST_DIR}" "${game_dir}"
DEPENDS _scripts.txt ${scripts}
DEPENDS _scripts.txt ${scripts} data_dir
COMMENT "Bundling xScripts.rxdata")
add_custom_target(xScripts ALL DEPENDS "${xscripts}")