git repos / blockattack-game

commit 195987de

branches: v2.1.X

sago007 · 2017-09-02 12:26
195987ded3e55c6344ea82492174a57707265ad5 patch · browse files
parent 5c031404db5038eb8405fef8663dd97bd131bde5

Can now build a Linux standalone package

Changed files

M CMakeLists.txt before
A source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone
A source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone32
A source/misc/standalone/README.txt
A source/misc/standalone/blockattack_standalone_launcher
A source/misc/standalone/build_standalone.sh
A source/misc/standalone/compile_requirements.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt index ea0efe3..fc2a238 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -35,7 +35,7 @@ SET(GUI_TYPE WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=i686")
endif()
-if (NOT WIN32)
+if (NOT WIN32 AND NOT STANDALONE)
#The path to the data dir must be compiled into the binary
add_definitions(-DSHAREDIR=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_DATA_DIR}\")
add_definitions(-DLOCALEDIR=\"${CMAKE_INSTALL_PREFIX}/${INSTALL_LOCALE_DIR}\")
diff --git a/source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone b/source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone new file mode 100644 index 0000000..2d84d4a --- /dev/null +++ b/source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone
@@ -0,0 +1,14 @@
+FROM ubuntu:14.04
+
+RUN apt-get update && apt-get install -y build-essential libboost-dev cmake pkg-config libboost-program-options-dev libfreetype6-dev libvorbis-dev libgl1-mesa-dev libpulse-dev libutfcpp-dev zip gettext
+
+COPY source/misc/standalone/compile_requirements.sh /
+RUN /compile_requirements.sh
+
+COPY . /staging/blockattack-game
+
+ENV BLOCKATTACK_VERSION 2.1.2
+
+RUN cd /staging/blockattack-game && \
+./packdata.sh && \
+cmake -D Boost_USE_STATIC_LIBS=ON -D INSTALL_DATA_DIR=. -D CMAKE_INSTALL_PREFIX=. -D STANDALONE=1 . && make
diff --git a/source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone32 b/source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone32 new file mode 100644 index 0000000..10c24bb --- /dev/null +++ b/source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone32
@@ -0,0 +1,14 @@
+FROM ioft/i386-ubuntu:14.04
+
+RUN apt-get update && apt-get install -y build-essential libboost-dev cmake pkg-config libboost-program-options-dev libfreetype6-dev libvorbis-dev libgl1-mesa-dev libpulse-dev libutfcpp-dev zip gettext
+
+COPY source/misc/standalone/compile_requirements.sh /
+RUN /compile_requirements.sh
+
+COPY . /staging/blockattack-game
+
+ENV BLOCKATTACK_VERSION 2.1.2
+
+RUN cd /staging/blockattack-game && \
+./packdata.sh && \
+cmake -D Boost_USE_STATIC_LIBS=ON -D INSTALL_DATA_DIR=. -D CMAKE_INSTALL_PREFIX=. -D STANDALONE=1 . && make
diff --git a/source/misc/standalone/README.txt b/source/misc/standalone/README.txt new file mode 100644 index 0000000..22528ba --- /dev/null +++ b/source/misc/standalone/README.txt
@@ -0,0 +1,10 @@
+Block Attack - Rise of the Blocks - Linux build
+
+This is the standalone version. It is precompiled and includes the necessary libraries to run.
+
+Both a 32 bit and 64 bit version is provided.
+It has been tested on Ubuntu 14.04 and Fedora 22
+Some systems might require the game to be launched from the command line.
+PulseAudio is required for sound.
+
+Check www.blockattack.net for more info.
diff --git a/source/misc/standalone/blockattack_standalone_launcher b/source/misc/standalone/blockattack_standalone_launcher new file mode 100644 index 0000000..c741844 --- /dev/null +++ b/source/misc/standalone/blockattack_standalone_launcher
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# This file is based on the guide from https://itch.io/docs/itch/integrating/platforms/linux.html
+
+# Move to script's directory
+cd "`dirname "$0"`"
+
+# Get the kernel/architecture information
+ARCH=`uname -m`
+
+# Set the libpath and pick the proper binary
+if [ "$ARCH" == "x86_64" ]; then
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./x86_64/
+ ./x86_64/blockattack "$@"
+else
+ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./x86/
+ ./x86/blockattack "$@"
+fi
diff --git a/source/misc/standalone/build_standalone.sh b/source/misc/standalone/build_standalone.sh new file mode 100755 index 0000000..0f23e47 --- /dev/null +++ b/source/misc/standalone/build_standalone.sh
@@ -0,0 +1,54 @@
+#! /bin/bash
+set -e
+
+if [ "$#" -ne 1 ]; then
+ echo "Must be called with $0 <archivename>"
+ exit 1
+fi
+
+ARCHIVENAME=$1
+
+rm -rf staging
+mkdir -p staging/$ARCHIVENAME/x86_64
+mkdir -p staging/$ARCHIVENAME/x86
+mkdir -p staging/$ARCHIVENAME/docs
+cp blockattack_standalone_launcher staging/$ARCHIVENAME/blockattack
+cp README.txt staging/$ARCHIVENAME/README
+chmod +x staging/$ARCHIVENAME/blockattack
+
+cd ../../..
+
+docker build -f source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone . -t blockattack_test
+
+echo Copying to: $(pwd)/source/misc/standalone/staging/$ARCHIVENAME
+
+docker run -it --rm -v $(pwd)/source/misc/standalone/staging/$ARCHIVENAME/:/output blockattack_test /bin/bash -c "cp /staging/blockattack-game/Game/blockattack /output/x86_64/ && \
+cp /usr/local/lib/libSDL2-2.0.so.0 /output/x86_64/ && \
+cp /usr/local/lib/libphysfs.so.1 /output/x86_64/ && \
+cp /usr/local/lib/libSDL2_mixer-2.0.so.0 /output/x86_64/ && \
+cp /usr/local/lib/libSDL2_ttf-2.0.so.0 /output/x86_64/ && \
+cp /usr/lib/x86_64-linux-gnu/libfreetype.so.6 /output/x86_64/ && \
+cp /lib/x86_64-linux-gnu/libpng12.so.0 /output/x86_64/ && \
+cp /usr/local/lib/libSDL2_image-2.0.so.0 /output/x86_64/"
+
+docker run -it --rm -v $(pwd)/source/misc/standalone/staging/$ARCHIVENAME/:/output blockattack_test /bin/bash -c "cp -r /staging/blockattack-game/source/misc/translation/locale /output/ && \
+cp /staging/blockattack-game/Game/blockattack.data /output/ && \
+cp -r /staging/blockattack-game/source/misc/icons /output/ && \
+cp /staging/blockattack-game/COPYING /output/ && \
+cp /staging/blockattack-game/man/blockattack.man /output/docs/ && \
+cp /staging/blockattack-game/README.md /output/docs/README_ORG.md && \
+chown -R 1000 /output"
+
+docker build -f source/misc/docker/Dockerfile.Ubuntu14.04build_Standalone32 . -t blockattack_test
+
+docker run -it --rm -v $(pwd)/source/misc/standalone/staging/$ARCHIVENAME/:/output blockattack_test /bin/bash -c "cp /staging/blockattack-game/Game/blockattack /output/x86/ && \
+cp /usr/local/lib/libSDL2-2.0.so.0 /output/x86/ && \
+cp /usr/local/lib/libphysfs.so.1 /output/x86/ && \
+cp /usr/local/lib/libSDL2_mixer-2.0.so.0 /output/x86/ && \
+cp /usr/local/lib/libSDL2_ttf-2.0.so.0 /output/x86/ && \
+cp /usr/lib/i386-linux-gnu/libfreetype.so.6 /output/x86/ && \
+cp /lib/i386-linux-gnu/libpng12.so.0 /output/x86/ && \
+cp /usr/local/lib/libSDL2_image-2.0.so.0 /output/x86/"
+
+cd source/misc/standalone/staging/
+tar -cvjSf "$ARCHIVENAME.tar.bz2" "$ARCHIVENAME"
diff --git a/source/misc/standalone/compile_requirements.sh b/source/misc/standalone/compile_requirements.sh new file mode 100755 index 0000000..21a0344 --- /dev/null +++ b/source/misc/standalone/compile_requirements.sh
@@ -0,0 +1,22 @@
+#! /bin/bash
+set -e
+set -x
+
+mkdir -p /staging/deps && cd /staging/deps && curl https://libsdl.org/release/SDL2-2.0.5.tar.gz | tar -zx && cd SDL2-2.0.5 && ls -lrt
+cd /staging/deps/SDL2-2.0.5 && ./configure --enable-shared --enable-static && make && make install
+
+#https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz
+mkdir -p /staging/deps && cd /staging/deps && curl https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.1.tar.gz | tar -zx && cd SDL2_image-2.0.1 && ls -lrt
+cd /staging/deps/SDL2_image-2.0.1 && ./configure --enable-shared --enable-static && make && make install
+
+#https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.tar.gz
+mkdir -p /staging/deps && cd /staging/deps && curl https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.1.tar.gz | tar -zx && cd SDL2_mixer-2.0.1 && ls -lrt
+cd /staging/deps/SDL2_mixer-2.0.1 && ./configure --enable-shared --enable-static && make && make install
+
+#https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz
+mkdir -p /staging/deps && cd /staging/deps && curl https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz | tar -zx && cd SDL2_ttf-2.0.14 && ls -lrt
+cd /staging/deps/SDL2_ttf-2.0.14 && ./configure --enable-shared --enable-static && make && make install
+mkdir -p /staging/blockattack-game
+
+mkdir -p /staging/deps && cd /staging/deps && curl http://icculus.org/physfs/downloads/physfs-2.0.3.tar.bz2 | tar -jx && cd physfs-2.0.3 && ls -lrt
+cd /staging/deps/physfs-2.0.3 && cmake . && make && make install