diff --git a/.github/workflows/build-appimage.yml b/.github/workflows/build-appimage.yml new file mode 100644 index 00000000..0d9a8358 --- /dev/null +++ b/.github/workflows/build-appimage.yml @@ -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 diff --git a/.gitignore b/.gitignore index 34c11b2e..fdfcd54a 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/AppImage/AppRun b/AppImage/AppRun new file mode 100755 index 00000000..49741637 --- /dev/null +++ b/AppImage/AppRun @@ -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" "$@" diff --git a/AppImage/Supermodel.desktop b/AppImage/Supermodel.desktop new file mode 100644 index 00000000..4007b4b0 --- /dev/null +++ b/AppImage/Supermodel.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=Supermodel +Exec=Supermodel +Icon=Supermodel +Type=Application +Categories=Game;Emulator; diff --git a/AppImage/Supermodel.png b/AppImage/Supermodel.png new file mode 100644 index 00000000..0cb2bb8d Binary files /dev/null and b/AppImage/Supermodel.png differ diff --git a/AppImage/build_app_image.sh b/AppImage/build_app_image.sh new file mode 100755 index 00000000..decbcc7a --- /dev/null +++ b/AppImage/build_app_image.sh @@ -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 diff --git a/Makefiles/Makefile.UNIX b/Makefiles/Makefile.UNIX index 2c4c3416..aa2c61f7 100644 --- a/Makefiles/Makefile.UNIX +++ b/Makefiles/Makefile.UNIX @@ -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) ############################################################################### diff --git a/Makefiles/Options.inc b/Makefiles/Options.inc index 6bd97203..07b8317f 100644 --- a/Makefiles/Options.inc +++ b/Makefiles/Options.inc @@ -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') # diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index 28f7a966..060659ac 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -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 SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "system"); +#endif // Begin initializing various subsystems... int exitCode = 0;