Skip to content

Commit

Permalink
build steam bin (kazzmir#100)
Browse files Browse the repository at this point in the history
Co-authored-by: juvinious <[email protected]>
  • Loading branch information
juvinious and juvinious authored Mar 8, 2024
1 parent 53fe8b4 commit 5f35b13
Show file tree
Hide file tree
Showing 16 changed files with 1,168 additions and 1 deletion.
45 changes: 45 additions & 0 deletions .github/workflows/compile-steam.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: steam cross compile build (sniper)

on:
push

jobs:
build:
name: Compile
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Run build
run: |
./easy-compile-docker-steam --no-install
- name: Run Release
if: startsWith(github.ref, 'refs/tags/')
run: ./release/release-steam

- name: Archive Folder
uses: actions/upload-artifact@v4
with:
name: artifact
path: ${{github.workspace}}/*.zip

publish-release:
needs: build
runs-on: ubuntu-latest

steps:
- name: Download Artifact
if: startsWith(github.ref, 'refs/tags/')
uses: actions/download-artifact@v4
with:
name: artifact
path: ${{github.workspace}}

- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ github.workspace }}/*.zip
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Paintown is a 2-d fighting game that is similar in style to Streets of Rage. Pai
![Mac Arm Build](https://github.com/kazzmir/paintown/actions/workflows/compile-mac-arm.yml/badge.svg)
![Mingw Cross-Compile Build](https://github.com/kazzmir/paintown/actions/workflows/mingw-cross.yml/badge.svg)
![Devkitpro Cross-Compile Build](https://github.com/kazzmir/paintown/actions/workflows/compile-dkp.yml/badge.svg)
![Steam Cross-Compile Build](https://github.com/kazzmir/paintown/actions/workflows/compile-steam.yml/badge.svg)

## Releases

Expand Down
59 changes: 59 additions & 0 deletions docker/Dockerfile.steam
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Build: docker build -t paintown-steam-build -f docker/Dockerfile.steam .
# Access shell: docker run --rm -it --entrypoint /bin/bash paintown-steam-build
# Use sniper build (https://github.com/ValveSoftware/steam-runtime?tab=readme-ov-file#installation)
FROM registry.gitlab.steamos.cloud/steamrt/sniper/sdk:latest

RUN apt update && \
apt install -y sudo wget git ninja-build make python3-pip && \
apt remove -y meson

# Get latest meson
RUN pip install meson && \
ln -s /usr/local/bin/meson /usr/bin/meson

# Build dirs
RUN mkdir -p /build/cross/include/SDL2

COPY src /build/src
COPY meson.build /build
COPY misc/steam/steam.txt /build/steam.txt
COPY meson.options /build

# Create makefile for native build
RUN echo ".PHONY: all clean\n\
\n\
steam: build-steam\n\
\t(cd build-steam; meson configure -Dbuild_tests=false)\n\
\tmeson compile -C build-steam\n\
\n\
build-steam:\n\
\tmkdir build-steam\n\
\tmeson setup --native-file steam.txt build-steam\n\
\n\
clean:\n\
\trm -fr build-steam" > /build/Makefile

# Temp directory
RUN mkdir -p /build/.tmp

# SDL_gfx is not installed by default, we may need to statically link it if it doesn't work on steam deck or with steam natively
RUN git clone https://github.com/ferzkopp/SDL2_gfx.git -- /build/.tmp/SDL_gfx
RUN echo "sources = [\n\
'SDL2_framerate.c',\n\
'SDL2_gfxPrimitives.c',\n\
'SDL2_imageFilter.c',\n\
'SDL2_rotozoom.c',\n\
]\n\
\n\
includes = include_directories('.', '../../src')\n\
\n\
sdl_graphics_library = static_library('SDL2_gfx', sources,\n\
include_directories: [includes],\n\
dependencies: [sdl_dependency, zlib_dependency],\n\
)\n" > /build/.tmp/SDL_gfx/meson.build
RUN cp /build/.tmp/SDL_gfx/*.h /build/cross/include/SDL2

RUN cd /build && make

CMD [ "/bin/bash" ]

89 changes: 89 additions & 0 deletions easy-compile-docker-steam
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash -e

docker build -t paintown-steam-build -f docker/Dockerfile.steam .
mkdir -p ${PWD}/steam-bin
docker run --rm -iv${PWD}:/paintown-bin paintown-steam-build sh -s <<EOF
chown $(id -u):$(id -g) /build/build-steam/paintown
cp -a /build/build-steam/paintown /paintown-bin/steam-bin
EOF

if [ "$1" != "--no-install" ]; then
function Install {
PROMPT=$1
DEFAULT=$2
if [ "$DEFAULT" = true ]; then
OPTIONS="[Y/n]"
DEFAULT="y"
else
OPTIONS="[y/N]"
DEFAULT="n"
fi
read -p "$PROMPT $OPTIONS " -n 1 -s -r INPUT
INPUT=${INPUT:-${DEFAUT}}
echo ${INPUT}
if [[ "$INPUT" =~ ^[yY]$ ]]; then
INSTALL_ANSWER=true
else
INSTALL_ANSWER=false
fi
}

Install "Would you like to install to steam?" false

if [ "$INSTALL_ANSWER" = true ]; then
echo "Attempting to installing paintown to steam..."
ROOT_DIR=$PWD
STL=steamtinkerlaunch
STEAM_APP_LOCATION=$HOME/.steam/steam/steamapps/common
STEAM_SNIPER_LOCATION=$HOME/.steam/root/ubuntu12_64/steam-runtime-sniper
INSTALL_LOCATION=$HOME/.paintown/Paintown

# check if steam app directory exists
if [ -d "$HOME/.steam" ] && [ ! -d "$STEAM_SNIPER_LOCATION" ]; then
echo "Cannot find sniper runtime. Are you sure steam is installed?"
exit -1
fi

echo "Checking dependencies"
if ! type "xdotool" &> /dev/null; then
echo "xdotool not found, please install before continuing"
exit
fi

if [ ! -d $INSTALL_LOCATION ]; then
mkdir -p $INSTALL_LOCATION
fi

mkdir -p $ROOT_DIR/steam-bin/installation
cd $ROOT_DIR/steam-bin/installation
wget -qO- https://github.com/sonic2kk/steamtinkerlaunch/archive/refs/tags/v12.12.tar.gz -O ${STL}.tar.gz
tar xzf ${STL}.tar.gz --strip=1

chmod +x $STL

# Create the installation directory and copy relevant files
mkdir -p $INSTALL_LOCATION/controller_config
cp $ROOT_DIR/steam-bin/paintown $INSTALL_LOCATION
cp $ROOT_DIR/misc/steam/steam-run.sh $INSTALL_LOCATION
chmod +x $INSTALL_LOCATION/steam-run.sh
cp $ROOT_DIR/misc/steam/'paintown keyboard layout_0.vdf' $INSTALL_LOCATION/controller_config
#cp $ROOT_DIR/misc/steam/*.png $INSTALL_LOCATION

# set english and yad to ai appimage
./${STL} yad ai lang=lang/english.txt
./${STL} ansg \
--appname="Paintown" \
--exepath="$INSTALL_LOCATION/steam-run.sh" \
--startdir="$INSTALL_LOCATION" \
--iconpath="$ROOT_DIR/misc/icon.png" \
--compatibilitytool="default" \
--hero="$ROOT_DIR/misc/steam/library_hero.png" \
--logo="$ROOT_DIR/misc/steam/library_logo_transparent.png" \
--boxart="$ROOT_DIR/misc/steam/library_capsule.png" \
--tenfoot="$ROOT_DIR/misc/steam/tenfoot.png" \
--copy

# Done
echo "Done. Paintown installed to $INSTALL_LOCATION. Restart steam to view the changes."
fi
fi
7 changes: 6 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ if not meson.is_cross_build()
add_global_arguments('-DDATA_PATH="data"', language: 'cpp')

is_static = false
sdl_graphics_dependency = dependency('SDL2_gfx', required: true, static: is_static)
if not meson.has_external_property('steam_build')
sdl_graphics_dependency = dependency('SDL2_gfx', required: true, static: is_static)
endif
sdl_image_dependency = dependency('SDL2_image', required: true, static: is_static)
yaml_cpp_dependency = dependency('yaml-cpp', required: false, static: is_static)

Expand Down Expand Up @@ -106,6 +108,9 @@ subdir('src/r-tech1')
subdir('src/mugen')
subdir('src/paintown-engine')
subdir('src/openbor')
if meson.has_external_property('steam_build')
subdir('.tmp/SDL_gfx')
endif

test_dependencies = other_dependencies + [yaml_cpp_dependency, sdl_dependency, sdl_image_dependency, sdl_ttf_dependency, sdl_mixer_dependency, sdl_graphics_dependency, zlib_dependency, vorbis_dependency, vorbis_file_dependency, ogg_dependency, mpg123_dependency]
test_linkages = [yaml_cpp_library, sdl_image_library, sdl_graphics_library, rtech1_library, mugen_library, paintown_library, openbor_library]
Expand Down
Binary file added misc/steam/library_capsule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/steam/library_capsule.xcf
Binary file not shown.
Binary file added misc/steam/library_hero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/steam/library_hero.xcf
Binary file not shown.
Binary file added misc/steam/library_logo_transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added misc/steam/library_logo_transparent.xcf
Binary file not shown.
Loading

0 comments on commit 5f35b13

Please sign in to comment.