Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appimage #221

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/build-appimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and Package AppImage

on:
push:
branches:
- main
- master
- appimage
pull_request:
branches:
- main
- master
- appimage

jobs:
build-appimage:
runs-on: ubuntu-22.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Set up dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake libgl1-mesa-dev libglu1-mesa-dev \
libsdl2-dev libsdl2-net-dev zlib1g-dev

# Build Supermodel
- name: Build Supermodel
run: |
cd ./AppImage
./build_app_image.sh

- name: Delete Existing latest Release
run: |
gh release delete latest -y || true
gh api -X DELETE /repos/${{ github.repository }}/git/refs/tags/latest || true

- name: Check AppImage File
run: ls -lah ./AppImage/

# Create release as the "latest" tag
- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: latest
release_name: "Supermodel Release latest"
draft: false
prerelease: false

- name: Upload AppImage
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
# upload_url: ${{ github.event.release.upload_url }}
asset_path: ./AppImage/Supermodel-x86_64.AppImage
asset_name: Supermodel-x86_64.AppImage
asset_content_type: application/octet-stream
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ nvram/
roms/
saves/





# ignore app_image related generated files/directories
/AppImage/appimagetool-x86_64.AppImage
/AppImage/Supermodel.AppDir
/AppImage/Supermodel-x86_64.AppImage
/AppImage/squashfs-root/
/AppImage/appimagetool
10 changes: 10 additions & 0 deletions AppImage/AppRun
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
#HERE="$(dirname "$(readlink -f "$0")")"
SELF=$(readlink -f "$0")
HERE=${SELF%/*}
#export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export PATH="${HERE}/usr/bin/:${HERE}/usr/sbin/:${HERE}/usr/games/:${HERE}/bin/:${HERE}/sbin/${PATH:+:$PATH}"
export LD_LIBRARY_PATH="${HERE}/usr/lib/:${HERE}/usr/lib/i386-linux-gnu/:${HERE}/usr/lib/x86_64-linux-gnu/:${HERE}/usr/lib32/:${HERE}/usr/lib64/:${HERE}/lib/:${HERE}/lib/i386-linux-gnu/:${HERE}/lib/x86_64-linux-gnu/:${HERE}/lib32/:${HERE}/lib64/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
echo "Starting Supermodel"
cd "$HERE/usr"
exec "./bin/Supermodel" "$@"
6 changes: 6 additions & 0 deletions AppImage/Supermodel.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Name=Supermodel
Exec=Supermodel
Icon=Supermodel
Type=Application
Categories=Game;Emulator;
Binary file added AppImage/Supermodel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions AppImage/build_app_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# Script ran on "22.04.1-Ubuntu"

# Globals
APP_DIR=Supermodel.AppDir

# Build Supermodel (NOTE: only seems to work if we enable NET_BOARD)
cd ..
make -f Makefiles/Makefile.UNIX NET_BOARD=1 APP_IMAGE=1

# Move back to the AppImage folder
cd ./AppImage
mkdir -p ./${APP_DIR}

# Copy binary into folder
mkdir -p ./${APP_DIR}/usr/bin
cp ../bin/supermodel ./${APP_DIR}/usr/bin/Supermodel

# Copy AppImage assets into the folder
cp ./AppRun ./${APP_DIR}/AppRun
cp ./Supermodel.desktop ./${APP_DIR}/Supermodel.desktop
cp ./Supermodel.png ./${APP_DIR}/Supermodel.png

# Copy Supermodel assets
mkdir -p ./${APP_DIR}/usr/Assets
cp ../Assets/* ./${APP_DIR}/usr/Assets/

# Copy Config
mkdir -p ./${APP_DIR}/usr/Config
cp ../Config/* ./${APP_DIR}/usr/Config/

# Copy required libraries
# NOTE: There may be some unnecessary libraries in here
mkdir -p ./${APP_DIR}/usr/lib
cp /lib/x86_64-linux-gnu/libbsd.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libdrm.so.2 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libffi.so.8 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libFLAC.so.8 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libGLX.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/liblz4.so.1 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/liblzma.so.5 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libmd.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libogg.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libopus.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libSDL2-2.0.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libSDL2_net-2.0.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libvorbisenc.so.2 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libvorbis.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libxcb-randr.so.0 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libxcb.so.1 ./${APP_DIR}/usr/lib/
cp /lib/x86_64-linux-gnu/libxkbcommon.so.0 ./${APP_DIR}/usr/lib/

echo "Building appimage"
# Download appimagetool (for creating the image)
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -c
chmod +x appimagetool-x86_64.AppImage
# ./appimagetool-x86_64.AppImage Supermodel.AppDir

# Extract out the contents
# NOTE: We do it this way so it can work without FUSE and also work via a github action
./appimagetool-x86_64.AppImage --appimage-extract
./squashfs-root/AppRun ./Supermodel.AppDir
8 changes: 7 additions & 1 deletion Makefiles/Makefile.UNIX
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ ifeq ($(strip $(NET_BOARD)),1)
SDL2_LIBS += -lSDL2_net
endif

# APP_IMAGE flags
APP_IMAGE_FLAGS = ``
ifeq ($(strip $(APP_IMAGE)),1)
APP_IMAGE_FLAGS += `-Wl,-rpath,'$$ORIGIN/../lib'`
endif

#
# UNIX-specific
#

PLATFORM_CXXFLAGS = $(SDL2_CFLAGS) -O3
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGL -lGLU -lz -lm -lstdc++ -lpthread
PLATFORM_LDFLAGS = $(SDL2_LIBS) -lGL -lGLU -lz -lm -lstdc++ -lpthread $(APP_IMAGE_FLAGS)


###############################################################################
Expand Down
8 changes: 8 additions & 0 deletions Makefiles/Options.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ ifneq ($(filter $(strip $(NET_BOARD)),0 1),$(strip $(NET_BOARD)))
override NET_BOARD =
endif

#
# Enable AppImage compiling
#
APP_IMAGE =
ifneq ($(filter $(strip $(APP_IMAGE)),0 1),$(strip $(APP_IMAGE)))
override APP_IMAGE =
endif

#
# Include console-based debugger in emulator ('yes' or 'no')
#
Expand Down
2 changes: 2 additions & 0 deletions Src/OSD/SDL/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,9 @@ int main(int argc, char **argv)
}

// Flag as DPI-aware, otherwise the window content might be scaled by some graphics drivers
#ifdef SDL_HINT_WINDOWS_DPI_AWARENESS
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add this or it wouldn't compile on linux

SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "system");
#endif

// Begin initializing various subsystems...
int exitCode = 0;
Expand Down