analgesicproductions / Even-The-Ocean-Open-Source

99%-Open Source code of Even the Ocean, a 2016 PC game.
Other
106 stars 10 forks source link

Linux compilation with Docker #3

Open mbndr opened 1 year ago

mbndr commented 1 year ago

NO ISSUE BUT INSTALLATION INSTRUCTIONS

I don't know Distrobox (#2) but I compiled it with the help of Docker.

  1. Create a new folder and cd into it
  2. git clone https://github.com/analgesicproductions/Even-The-Ocean-Open-Source source (note the destination folder)
  3. Copy the code below into Dockerfile in the same directory
  4. Build image: docker build -t eto .
  5. Actually compile: docker run --rm -v "$PWD/export:/export" eto
  6. (Hopefully everything went well) then execute cd export && ./EventheOcean to run the game
  7. (Cleanup image docker image rm eto)
FROM haxe:3.4.7

COPY source /source

RUN bash "/source/Open Source Assets/installHaxeLibraries.bat"

# Install compiler
RUN apt-get update && \
    apt-get install -y g++ gcc-multilib g++-multilib

WORKDIR /source

# Fix missing libraries
RUN haxelib run lime rebuild hxcpp linux

# Copy custom flixel libraries
RUN cp -r /source/txt/flixel/* /haxelib/flixel/4,0,0 \
 && cp -r /source/txt/addons/* /haxelib/flixel-addons/2,0,0/flixel/addons/tile

# Actually installing
CMD haxelib run lime build "Project.xml" linux -release -Dfdb \
 && mv /source/export/linux64/cpp/bin/* /export

There are surely better structured ways for building it but this is the way I did it for now. I didn't playtest so long but the game booted and I started the first level in gauntlet mode.

@analgesicproductions Thank you so much for sharing your source code!

dyatlov77 commented 12 months ago

for info. Distrobox is based on docker/podman. I think docker build should be used to build docker image and not final source code. Check bellow example:

diff --git a/.gitignore b/.gitignore
index 69e98f1..b81fed1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ _noncrypt_assets/buf/1
 _noncrypt_assets/buf/2
 _noncrypt_assets/record
 txt/.npclock
+linux/haxe/
diff --git a/linux/Dockerfile b/linux/Dockerfile
new file mode 100644
index 0000000..6a862c1
--- /dev/null
+++ b/linux/Dockerfile
@@ -0,0 +1,16 @@
+FROM haxe:3.4.7
+
+# Install compiler
+RUN apt-get update && \
+    apt-get install -y build-essential gcc-multilib g++-multilib zip -y
+
+RUN useradd -ms /bin/bash eto
+
+USER eto
+
+WORKDIR /home/eto
+
+RUN haxelib setup $HOME/haxe
+
+RUN mkdir -p $HOME/source
+
diff --git a/linux/Makefile b/linux/Makefile
new file mode 100644
index 0000000..c430d48
--- /dev/null
+++ b/linux/Makefile
@@ -0,0 +1,26 @@
+
+.PHONY: all
+all:   prepare_haxe game artifacts
+
+
+clean: clean_haxe clean_game
+
+clean_haxe:
+   rm -rf linux/haxe/*
+clean_game:
+   rm -rf export
+   -rm EvenTheOceanLinux.zip
+
+prepare_haxe:
+   sh Open\ Source\ Assets/installHaxeLibraries.bat
+   haxelib run lime rebuild hxcpp linux
+
+game:
+   cp -r txt/flixel/* /home/eto/haxe/flixel/4,0,0
+   cp -r txt/addons/* /home/eto/haxe/flixel-addons/2,0,0/flixel/addons/tile
+   haxelib run lime build "Project.xml" linux -release -Dfdb
+
+artifacts:
+   cd export/linux64/cpp/bin && zip -r /home/eto/source/EvenTheOceanLinux.zip ./*
+
+
diff --git a/linux/indocker_linux.sh b/linux/indocker_linux.sh
new file mode 100644
index 0000000..3831756
--- /dev/null
+++ b/linux/indocker_linux.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
+
+DOCKER_IMAGE=event_the_ocean
+DOCKER_TAG=001
+
+COMMANDS="cd /home/eto/source"
+
+COMMANDS="$COMMANDS;make -f linux/Makefile $*"
+
+VOLUMES=""
+VOLUMES="$VOLUMES --volume $SCRIPT_DIR/../:/home/eto/source"
+VOLUMES="$VOLUMES --volume $SCRIPT_DIR/haxe:/home/eto/haxe"
+
+ARGS=""
+ARGS="$ARGS -it --rm"
+
+if ! docker image inspect $DOCKER_IMAGE:$DOCKER_TAG >/dev/null 2>&1; then
+  docker build --tag $DOCKER_IMAGE:$DOCKER_TAG --file $SCRIPT_DIR/Dockerfile $SCRIPT_DIR
+fi
+
+if [ ! -d $SCRIPT_DIR/haxe ]; then
+  mkdir -p $SCRIPT_DIR/haxe
+  chmod 755 $SCRIPT_DIR/haxe
+fi
+
+
+docker run $ARGS $VOLUMES $DOCKER_IMAGE:$DOCKER_TAG bash -c "$COMMANDS"
+

save patch in your code and run


patch -p1 < <patch_name>

to compile everything


sh linux/indocker_linux.sh

this should build docker image(only first time) and build the game.

other options:

sh linux/indocker_linux.sh clean   // clean all (haxe libs, game)

sh linux/indocker_linux.sh clean_game // clean game objects

sh linux/indocker_linux.sh game // build game, after clean_game