Skip to content

Commit

Permalink
Merge pull request elizagamedev#1 from rkevin-arch/master
Browse files Browse the repository at this point in the history
Linux build instructions
  • Loading branch information
melody-rs authored Jun 25, 2020
2 parents 868b874 + c186cf8 commit ff32124
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 1 deletion.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# gcc10 doesn't like me, and it seems the official appimage is build using gcc 5.4.0-6ubuntu1~16.04.12
FROM conanio/gcc5
RUN conan remote add eliza "https://api.bintray.com/conan/eliza/conan" && \
conan remote add bincrafters "https://api.bintray.com/conan/bincrafters/public-conan"

RUN sudo apt update && DEBIAN_FRONTEND=noninteractive sudo apt install -y xorg-dev libx11-xcb-dev libxcb-render0-dev libxcb-render-util0-dev libgtk2.0-dev libxfconf-0-dev vim libwmf0.2-7-gtk librsvg2-common rsync
RUN sudo python -m pip install mako pyqt5 pyinstaller

RUN conan install boost/1.73.0@_/_ --build=missing -o boost:without_test=True
RUN conan install openal/1.18.2@bincrafters/stable --build=missing
RUN conan install physfs/3.0.1@bincrafters/stable --build=missing
RUN conan install pixman/0.34.0@bincrafters/stable --build=missing
RUN conan install ruby/2.5.3@eliza/testing --build=missing
RUN conan install sdl2/2.0.9@bincrafters/stable --build=missing
RUN conan install sdl2_image/2.0.5@bincrafters/stable --build=missing
RUN conan install sdl2_ttf/2.0.15@bincrafters/stable --build=missing
RUN conan install sdl_sound-mkxp/1.0.1@eliza/stable --build=missing
RUN conan install sigc++/2.10.0@bincrafters/stable --build=missing

ADD https://github.com/AppImage/AppImageKit/releases/download/12/appimagetool-x86_64.AppImage /tmp
# can't find a stable release for linuxdeploy, oh well
ADD https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage /tmp
# avoid having to run appimages by itself
# we don't want to force CAP_SYS_ADMIN into the container if possible, but running appimages require FUSE
# instead, we extract it and pray it works (it actually does!)
RUN cd /tmp && sudo chmod 755 appimagetool-x86_64.AppImage linuxdeploy-x86_64.AppImage && \
./appimagetool-x86_64.AppImage --appimage-extract && sudo mv squashfs-root /usr/local/bin/appimagetool && \
./linuxdeploy-x86_64.AppImage --appimage-extract && sudo mv squashfs-root /usr/local/bin/linuxdeploy && \
sudo ln -s /usr/local/bin/appimagetool/AppRun /usr/local/bin/appimagetool-x86_64.AppImage && \
sudo ln -s /usr/local/bin/linuxdeploy/AppRun /usr/local/bin/linuxdeploy-x86_64.AppImage

COPY build-entrypoint-linux.sh /
ENTRYPOINT ["/build-entrypoint-linux.sh"]

# build this docker image as follows:
# docker build -t oneshot-build-linux .

# run this docker image as follows:
# docker run -i -v /path/to/modshot-core:/work/src -v /path/to/gamefiles:/work/data -v /path/to/distrubution/folder:/work/dist oneshot-build-linux
# example that worked for me:
# docker run -i -v ~/o/Modshot-Core:/work/src -v ~/o/OneShotBkup:/work/data -v ~/o/conanbuildtest:/work/dist oneshot-build-linux
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,71 @@ 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.

## Building using Docker on Linux

A `Dockerfile` is attached that handles all the dependencies and allows you to build ModShot for Linux. You should already have Docker installed using your favorite package manager on Linux or [here](https://docs.docker.com/docker-for-windows/install/) on Windows.

### Building the image

To pull the image, run the following command in bash or Powershell:

```sh
docker pull rkevin/build-oneshot-linux
```

If you want to build the image manually instead, use the following (no need to do this if you pulled my image from Docker Hub):

```sh
docker build -t build-oneshot-linux .
```

### Running the image

You should have 3 directories ready, and write down their paths:
1. Source directory: This is the path to this repo (Modshot-Core or mkxp-oneshot)
2. Data directory: This is a folder that contains the `Audio`, `Data`, `Fonts`, `Graphics`, `Languages`, and `Wallpaper` directories from the game / your mod.
3. Distribution directory: This is the output folder where you want `OneShot.AppImage` to be placed after the build. On Linux, make sure that UID 1000 can write to this folder (easiest way is to `chmod 777` it, or you can ask the Docker container to run with your permissions)

Keep in mind those paths must be absolute, so `/home/user/blah` on Linux or `C:\Users\user\blah` on Windows. No relative paths allowed.

Afterwards, just run this command to build on Linux:

```sh
docker run -i -v /path/to/source:/work/src -v /path/to/data:/work/data -v /path/to/dist:/work/dist build-oneshot-linux
```

Or similarly on Windows:

```powershell
docker run -i -v C:\path\to\source:/work/src -v C:\path\to\data:/work/data -v C:\path\to\dist:/work/dist build-oneshot-linux
```

Done! Enjoy your built-from-source OneShot.

### Partial compilation

If you want to speed up compilation, you can ask the container to keep the build folder by mounting a directory to it, like `-v /path/to/build:/work/build`. This is optional.

Also note that if the journal file (`_______`) exists in the build directory, it won't be rebuilt even if you changed the source of the journal. Please delete the file manually if you want a journal rebuild.

### Unix only content

If you have game files that you only want in the Linux build of OneShot and not the Windows build, you may place them in a folder that you mount to `/work/extra_unix_content`. For example, if you want a `Map123.rxdata` that's for Unix only, put it in a folder like `unixonlyfolder/Data/Map123.rxdata`, then mount it using `-v /path/to/unixonlyfolder:/work/extra_unix_content`. This has the same structure as the regular data folder and will take precedence over any files in the regular data folder. You shouldn't need to use this, but it's an option just in case.

### Note on xScripts

For some reason, `make-appimage.sh` seems to use a `xScripts.rxdata` built by conan as the script bundled in the AppImage. Since I still don't know why this is necessary and it seems modders can just modify `Scripts.rxdata`, copy it to `xScripts.rxdata` and make it work, I have disabled this behavior.

Now the default behavior is:
1. If you already had a xScripts.rxdata in your Data folder, that will be used.
2. If that file doesn't exist, `Scripts.rxdata` in your Data folder will be copied over automatically to `xScripts.rxdata`. This means you don't have to rename the file constantly if you're making a mod.

If you want the old behavior back, add `--keep-xscripts-behavior` to the END of the `docker run` command. This also means any script you edit will have to be reflected in the `scripts` directory in this repo (source directory), which will get built into `xScripts.rxdata`.

## Building using Docker on Windows

Work in progress. Keep nagging @rkevin-arch until he figures it out, or follow the instructions below to do it on bare-metal (beware dependency hell).

## Building (Supported on Windows, Ubuntu Linux, in progress on macOS)

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.
Expand Down
9 changes: 8 additions & 1 deletion make-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ find "$appdir/usr/bin" -type d \( \
-exec rm -rf {} +
# International fonts are now taking up space
find "$appdir/usr/bin/Fonts" -type f \! -iname 'TerminusTTF-Bold.ttf' -delete
cp -af "$conan_install_path/bin/Data/xScripts.rxdata" "$appdir/usr/bin/Data/"
# read readme to find out why this is changed
if [ -n "${KEEP_XSCRIPTS_BEHAVIOR:-}" ]; then
cp -af "$conan_install_path/bin/Data/xScripts.rxdata" "$appdir/usr/bin/Data/"
else
if [ ! -f "$appdir/usr/bin/Data/xScripts.rxdata" ]; then
cp -af "$appdir/usr/bin/Data/Scripts.rxdata" "$appdir/usr/bin/Data/xScripts.rxdata"
fi
fi

# Create AppImage
ARCH=x86_64 $APPIMAGETOOL "$appdir" "$appimage_file"

0 comments on commit ff32124

Please sign in to comment.