diff --git a/.github/workflows/rolling-release.yml b/.github/workflows/rolling-release.yml index 7d51a5162..b7edcac00 100644 --- a/.github/workflows/rolling-release.yml +++ b/.github/workflows/rolling-release.yml @@ -161,95 +161,95 @@ jobs: path: "duckstation-windows-arm64-release.zip" - windows-uwp-build: - runs-on: windows-2022 - steps: - - uses: actions/checkout@v2.3.1 - with: - fetch-depth: 0 - submodules: false - - - name: Tag as preview build - if: github.ref == 'refs/heads/master' - shell: cmd - run: | - echo #pragma once > src/scmversion/tag.h - echo #define SCM_RELEASE_ASSET "duckstation-windows-x64-release.zip" >> src/scmversion/tag.h - echo #define SCM_RELEASE_TAGS {"latest", "preview"} >> src/scmversion/tag.h - echo #define SCM_RELEASE_TAG "preview" >> src/scmversion/tag.h - - - - name: Tag as dev build - if: github.ref == 'refs/heads/dev' - shell: cmd - run: | - echo #pragma once > src/scmversion/tag.h - echo #define SCM_RELEASE_ASSET "duckstation-windows-x64-release.zip" >> src/scmversion/tag.h - echo #define SCM_RELEASE_TAGS {"latest", "preview"} >> src/scmversion/tag.h - echo #define SCM_RELEASE_TAG "latest" >> src/scmversion/tag.h - - - name: Write signing key - id: write_signing_key - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' - uses: timheuer/base64-to-file@v1 - with: - fileName: 'duckstation-uwp.pfx' - encodedString: ${{ secrets.UWP_PFX_KEY }} - - - name: Copy signing key - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' - shell: cmd - run: | - copy ${{ steps.write_signing_key.outputs.filePath }} src\duckstation-uwp\duckstation-uwp.pfx - - - name: Disable AppX signing - if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev' - shell: powershell - run: | - (gc .\src\duckstation-uwp\duckstation-uwp.vcxproj) -replace 'True', 'False' | Out-File -encoding ASCII .\src\duckstation-uwp\duckstation-uwp.vcxproj - - - name: Restore nuget packages - shell: cmd - run: | - nuget restore duckstation-uwp.sln - - - name: Compile x64 release build without bundle - if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev' - shell: cmd - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - msbuild duckstation-uwp.sln /p:Configuration="ReleaseUWP" /p:Platform="x64" /t:Build - - - name: Compile x64 release build with bundle - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' - shell: cmd - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 - msbuild duckstation-uwp.sln /p:AppxBundle=Always /p:AppxPackageIsForStore=true /p:BuildAppxUploadPackageForUap=true /p:AppxBundlePlatforms="x64" /p:Configuration="ReleaseUWP" /p:Platform="x64" /t:Build - - - name: Grab AppX package - shell: cmd - run: | - copy build\ReleaseUWP-x64\duckstation-uwp\duckstation-uwp_1.0.0.0_Bundle\duckstation-uwp_1.0.0.0_x64_ReleaseUWP.appx duckstation-uwp.appx - - - name: Export certificate - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' - shell: powershell - run: | - Get-PfxCertificate -FilePath .\src\duckstation-uwp\duckstation-uwp.pfx | Export-Certificate -FilePath duckstation-uwp.der -Type CERT - - - name: Upload AppX package - uses: actions/upload-artifact@v1 - with: - name: "windows-uwp" - path: "duckstation-uwp.appx" - - - name: Upload certificate - if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' - uses: actions/upload-artifact@v1 - with: - name: "windows-uwp" - path: "duckstation-uwp.der" +# windows-uwp-build: +# runs-on: windows-2022 +# steps: +# - uses: actions/checkout@v2.3.1 +# with: +# fetch-depth: 0 +# submodules: false +# +# - name: Tag as preview build +# if: github.ref == 'refs/heads/master' +# shell: cmd +# run: | +# echo #pragma once > src/scmversion/tag.h +# echo #define SCM_RELEASE_ASSET "duckstation-windows-x64-release.zip" >> src/scmversion/tag.h +# echo #define SCM_RELEASE_TAGS {"latest", "preview"} >> src/scmversion/tag.h +# echo #define SCM_RELEASE_TAG "preview" >> src/scmversion/tag.h +# +# +# - name: Tag as dev build +# if: github.ref == 'refs/heads/dev' +# shell: cmd +# run: | +# echo #pragma once > src/scmversion/tag.h +# echo #define SCM_RELEASE_ASSET "duckstation-windows-x64-release.zip" >> src/scmversion/tag.h +# echo #define SCM_RELEASE_TAGS {"latest", "preview"} >> src/scmversion/tag.h +# echo #define SCM_RELEASE_TAG "latest" >> src/scmversion/tag.h +# +# - name: Write signing key +# id: write_signing_key +# if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' +# uses: timheuer/base64-to-file@v1 +# with: +# fileName: 'duckstation-uwp.pfx' +# encodedString: ${{ secrets.UWP_PFX_KEY }} +# +# - name: Copy signing key +# if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' +# shell: cmd +# run: | +# copy ${{ steps.write_signing_key.outputs.filePath }} src\duckstation-uwp\duckstation-uwp.pfx +# +# - name: Disable AppX signing +# if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev' +# shell: powershell +# run: | +# (gc .\src\duckstation-uwp\duckstation-uwp.vcxproj) -replace 'True', 'False' | Out-File -encoding ASCII .\src\duckstation-uwp\duckstation-uwp.vcxproj +# +# - name: Restore nuget packages +# shell: cmd +# run: | +# nuget restore duckstation-uwp.sln +# +# - name: Compile x64 release build without bundle +# if: github.ref != 'refs/heads/master' && github.ref != 'refs/heads/dev' +# shell: cmd +# run: | +# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 +# msbuild duckstation-uwp.sln /p:Configuration="ReleaseUWP" /p:Platform="x64" /t:Build +# +# - name: Compile x64 release build with bundle +# if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' +# shell: cmd +# run: | +# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 +# msbuild duckstation-uwp.sln /p:AppxBundle=Always /p:AppxPackageIsForStore=true /p:BuildAppxUploadPackageForUap=true /p:AppxBundlePlatforms="x64" /p:Configuration="ReleaseUWP" /p:Platform="x64" /t:Build +# +# - name: Grab AppX package +# shell: cmd +# run: | +# copy build\ReleaseUWP-x64\duckstation-uwp\duckstation-uwp_1.0.0.0_Bundle\duckstation-uwp_1.0.0.0_x64_ReleaseUWP.appx duckstation-uwp.appx +# +# - name: Export certificate +# if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' +# shell: powershell +# run: | +# Get-PfxCertificate -FilePath .\src\duckstation-uwp\duckstation-uwp.pfx | Export-Certificate -FilePath duckstation-uwp.der -Type CERT +# +# - name: Upload AppX package +# uses: actions/upload-artifact@v1 +# with: +# name: "windows-uwp" +# path: "duckstation-uwp.appx" +# +# - name: Upload certificate +# if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' +# uses: actions/upload-artifact@v1 +# with: +# name: "windows-uwp" +# path: "duckstation-uwp.der" linux-build: @@ -263,79 +263,93 @@ jobs: shell: bash run: | sudo apt-get update - sudo apt-get -y install cmake ninja-build ccache libsdl2-dev libgtk-3-dev qtbase5-dev qtbase5-dev-tools qtbase5-private-dev qt5-default qttools5-dev qtwayland5 libegl1-mesa-dev libevdev-dev libgbm-dev libdrm-dev libqt5waylandclient5-dev libqt5waylandcompositor5-dev libwayland-dev libwayland-egl-backend-dev extra-cmake-modules libcurl4-gnutls-dev libxrandr-dev + sudo apt-get -y install cmake ninja-build ccache libsdl2-dev libgtk-3-dev libegl1-mesa-dev libevdev-dev libgbm-dev libdrm-dev libwayland-dev libwayland-egl-backend-dev extra-cmake-modules libcurl4-gnutls-dev libxrandr-dev llvm-12 lld-12 clang-12 + + - name: Cache Dependencies + id: cache-deps + uses: actions/cache@v3 + with: + path: ~/deps + key: deps ${{ hashFiles('scripts/build-dependencies.sh') }} + + - name: Build Dependencies + if: steps.cache-deps.outputs.cache-hit != 'true' + run: scripts/build-dependencies.sh - name: Compile build shell: bash run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=ON -DBUILD_QT_FRONTEND=ON -DUSE_DRMKMS=ON -DUSE_EGL=ON -DUSE_SDL2=ON -DUSE_WAYLAND=ON -DUSE_X11=ON -G Ninja .. + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_DRMKMS=ON -DUSE_EGL=ON -DUSE_SDL2=ON -DUSE_WAYLAND=ON -DUSE_X11=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_PREFIX_PATH=$HOME/deps -DCMAKE_TOOLCHAIN_FILE=../scripts/clang-toolchain.cmake .. cmake --build . --parallel - ../scripts/generate_appimages.sh $(pwd) + cd .. + scripts/make-appimage.sh $(realpath ./build) $(realpath .) $HOME/deps DuckStation-x64 - - name: Upload NoGUI AppImage - uses: actions/upload-artifact@v1 - with: - name: "linux-x64-appimage-nogui" - path: "build/duckstation-nogui-x64.AppImage" - - - name: Upload NoGUI AppImage zsync - uses: actions/upload-artifact@v1 - with: - name: "linux-x64-appimage-nogui-zsync" - path: "build/duckstation-nogui-x64.AppImage.zsync" +# - name: Upload NoGUI AppImage +# uses: actions/upload-artifact@v1 +# with: +# name: "linux-x64-appimage-nogui" +# path: "build/duckstation-nogui-x64.AppImage" +# +# - name: Upload NoGUI AppImage zsync +# uses: actions/upload-artifact@v1 +# with: +# name: "linux-x64-appimage-nogui-zsync" +# path: "build/duckstation-nogui-x64.AppImage.zsync" - name: Upload Qt AppImage uses: actions/upload-artifact@v1 with: name: "linux-x64-appimage-qt" - path: "build/duckstation-qt-x64.AppImage" + path: "DuckStation-x64.AppImage" - - name: Upload Qt AppImage zsync - uses: actions/upload-artifact@v1 - with: - name: "linux-x64-appimage-qt-zsync" - path: "build/duckstation-qt-x64.AppImage.zsync" +# - name: Upload Qt AppImage zsync +# uses: actions/upload-artifact@v1 +# with: +# name: "linux-x64-appimage-qt-zsync" +# path: "build/duckstation-qt-x64.AppImage.zsync" - - macos-build: - runs-on: macos-10.15 - steps: - - uses: actions/checkout@v2.3.1 - with: - fetch-depth: 0 - - - name: Install packages - shell: bash - run: | - brew install qt5 sdl2 curl ninja - - - name: Clone mac externals - shell: bash - run: | - git clone https://github.com/stenzek/duckstation-ext-mac.git dep/mac - - - name: Compile and zip .app - shell: bash - run: | - mkdir build - cd build - export MACOSX_DEPLOYMENT_TARGET=10.14 - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DQt5_DIR=/usr/local/opt/qt@5/lib/cmake/Qt5 -G Ninja .. - cmake --build . --parallel - cd bin - zip -r duckstation-mac-release.zip DuckStation.app/ - - - name: Upload macOS .app - uses: actions/upload-artifact@v1 - with: - name: "macos-x64" - path: "build/bin/duckstation-mac-release.zip" +# Disabled until we switch to macdeployqt +# macos-build: +# runs-on: macos-11 +# steps: +# - uses: actions/checkout@v2.3.1 +# with: +# fetch-depth: 0 +# +# - name: Install packages +# shell: bash +# run: | +# brew install qt6 sdl2 curl ninja +# +# - name: Clone mac externals +# shell: bash +# run: | +# git clone https://github.com/stenzek/duckstation-ext-mac.git dep/mac +# +# - name: Compile and zip .app +# shell: bash +# run: | +# mkdir build +# cd build +# ls -lh /usr/local/opt +# export MACOSX_DEPLOYMENT_TARGET=10.14 +# cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_NOGUI_FRONTEND=OFF -DBUILD_QT_FRONTEND=ON -DUSE_SDL2=ON -DQt6_DIR=/usr/local/opt/qt@6/lib/cmake/Qt6 -G Ninja .. +# cmake --build . --parallel +# cd bin +# zip -r duckstation-mac-release.zip DuckStation.app/ +# +# - name: Upload macOS .app +# uses: actions/upload-artifact@v1 +# with: +# name: "macos-x64" +# path: "build/bin/duckstation-mac-release.zip" create-release: - needs: [windows-build, windows-arm64-build, linux-build, windows-uwp-build] + #needs: [windows-build, windows-arm64-build, linux-build, windows-uwp-build] + needs: [windows-build, windows-arm64-build, linux-build] runs-on: "ubuntu-20.04" if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' steps: @@ -349,30 +363,30 @@ jobs: with: name: "windows-arm64" - - name: Download Windows UWP Artifact - uses: actions/download-artifact@v1 - with: - name: "windows-uwp" - - - name: Download NoGUI AppImage Artifact - uses: actions/download-artifact@v1 - with: - name: "linux-x64-appimage-nogui" - - - name: Download NoGUI AppImage zsync Artifact - uses: actions/download-artifact@v1 - with: - name: "linux-x64-appimage-nogui-zsync" +# - name: Download Windows UWP Artifact +# uses: actions/download-artifact@v1 +# with: +# name: "windows-uwp" +# +# - name: Download NoGUI AppImage Artifact +# uses: actions/download-artifact@v1 +# with: +# name: "linux-x64-appimage-nogui" +# +# - name: Download NoGUI AppImage zsync Artifact +# uses: actions/download-artifact@v1 +# with: +# name: "linux-x64-appimage-nogui-zsync" - name: Download Qt AppImage Artifact uses: actions/download-artifact@v1 with: name: "linux-x64-appimage-qt" - - name: Download Qt AppImage zsync Artifact - uses: actions/download-artifact@v1 - with: - name: "linux-x64-appimage-qt-zsync" +# - name: Download Qt AppImage zsync Artifact +# uses: actions/download-artifact@v1 +# with: +# name: "linux-x64-appimage-qt-zsync" - name: Create preview release if: github.ref == 'refs/heads/master' @@ -387,12 +401,13 @@ jobs: windows/duckstation-windows-x64-release-symbols.zip windows-arm64/duckstation-windows-arm64-release.zip windows-arm64/duckstation-windows-arm64-release-symbols.zip - windows-uwp/duckstation-uwp.appx - windows-uwp/duckstation-uwp.der - linux-x64-appimage-nogui/duckstation-nogui-x64.AppImage - linux-x64-appimage-nogui-zsync/duckstation-nogui-x64.AppImage.zsync - linux-x64-appimage-qt/duckstation-qt-x64.AppImage - linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync + linux-x64-appimage-qt/DuckStation-x64 +# linux-x64-appimage-qt/duckstation-qt-x64.AppImage +# linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync +# windows-uwp/duckstation-uwp.appx +# windows-uwp/duckstation-uwp.der +# linux-x64-appimage-nogui/duckstation-nogui-x64.AppImage +# linux-x64-appimage-nogui-zsync/duckstation-nogui-x64.AppImage.zsync - name: Create dev release if: github.ref == 'refs/heads/dev' @@ -407,9 +422,10 @@ jobs: windows/duckstation-windows-x64-release-symbols.zip windows-arm64/duckstation-windows-arm64-release.zip windows-arm64/duckstation-windows-arm64-release-symbols.zip - windows-uwp/duckstation-uwp.appx - windows-uwp/duckstation-uwp.der - linux-x64-appimage-nogui/duckstation-nogui-x64.AppImage - linux-x64-appimage-nogui-zsync/duckstation-nogui-x64.AppImage.zsync - linux-x64-appimage-qt/duckstation-qt-x64.AppImage - linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync + linux-x64-appimage-qt/DuckStation-x64 +# linux-x64-appimage-qt/duckstation-qt-x64.AppImage +# linux-x64-appimage-qt-zsync/duckstation-qt-x64.AppImage.zsync +# windows-uwp/duckstation-uwp.appx +# windows-uwp/duckstation-uwp.der +# linux-x64-appimage-nogui/duckstation-nogui-x64.AppImage +# linux-x64-appimage-nogui-zsync/duckstation-nogui-x64.AppImage.zsync diff --git a/scripts/build-dependencies.sh b/scripts/build-dependencies.sh new file mode 100755 index 000000000..4d737ec95 --- /dev/null +++ b/scripts/build-dependencies.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash + +set -e + +sudo apt-get install -y build-essential git cmake ccache ninja-build libclang-dev libclang-11-dev libclang-12-dev patchelf \ + libglib2.0-dev libfontconfig1-dev libharfbuzz-dev libjpeg-dev libpng-dev libfreetype-dev libinput-dev libxcb-*-dev \ + libxkbcommon-dev libxkbcommon-x11-dev libxrender-dev libwayland-dev libgl1-mesa-dev libegl-dev libegl1-mesa-dev \ + libgl1-mesa-dev libssl-dev + +INSTALLDIR="$HOME/deps" +NPROCS="$(getconf _NPROCESSORS_ONLN)" +SDL=SDL2-2.0.22 +QT=6.3.1 + +mkdir -p deps-build +cd deps-build + +cat > SHASUMS < + +if [ "$#" -ne 4 ]; then + echo "Syntax: $0 " + exit 1 +fi + +BUILDDIR=$1 +ROOTDIR=$2 +DEPSDIR=$3 +NAME=$4 + +BINDIR="$DSDIR/bin" + +BINARY=duckstation-qt +APPDIRNAME=DuckStation.AppDir +STRIP=llvm-strip-12 + +declare -a SYSLIBS=( + "libz.so.1" + "libuuid.so.1" + "libapparmor.so.1" + "libblkid.so.1" + "libbsd.so.0" + "libdbus-1.so.3" + "libgcrypt.so.20" + "liblzma.so.5" + "libmount.so.1" + "libnsl.so.1" + "libpcre.so.3" + "libselinux.so.1" + "libsystemd.so.0" + "libudev.so.1" + "libwrap.so.0" + "libharfbuzz.so.0" + "libFLAC.so.8" + "libXau.so.6" + "libXcomposite.so.1" + "libXcursor.so.1" + "libXdamage.so.1" + "libXdmcp.so.6" + "libXext.so.6" + "libXfixes.so.3" + "libXi.so.6" + "libXinerama.so.1" + "libXrandr.so.2" + "libXrender.so.1" + "libXxf86vm.so.1" + "libasyncns.so.0" + "libcrypto.so.1.1" + "liblz4.so.1" + "libpulse.so.0" + "libxcb.so.1" + "libxcb-render.so.0" + "libxcb-shm.so.0" + "libxkbcommon.so.0" + "libxkbcommon-x11.so.0" + "pulseaudio/libpulsecommon-13.99.so" + "libfreetype.so.6" + "libpcre2-16.so.0" + "libexpat.so.1" + "libffi.so.7" + "libgraphite2.so.3" + "libresolv.so.2" + "libgpg-error.so.0" + "libpcre2-16.so.0" + "libxcb-icccm.so.4" + "libxcb-image.so.0" + "libxcb-keysyms.so.1" + "libxcb-randr.so.0" + "libxcb-render.so.0" + "libxcb-render-util.so.0" + "libxcb-shape.so.0" + "libxcb-sync.so.1" + "libxcb-util.so.1" + "libxcb-xfixes.so.0" + "libxcb-xkb.so.1" + "libevdev.so.2" + "libgudev-1.0.so.0" + "libinput.so.10" + "libjpeg.so.8" + "libmtdev.so.1" + "libpng16.so.16" + "libuuid.so.1" +) + +declare -a DEPLIBS=( + "libSDL2-2.0.so.0" +) + +declare -a QTLIBS=( + "libQt6Core.so.6" + "libQt6Gui.so.6" + "libQt6Network.so.6" + "libQt6OpenGL.so.6" + "libQt6Svg.so.6" + "libQt6WaylandClient.so.6" + "libQt6WaylandCompositor.so.6" + "libQt6WaylandEglClientHwIntegration.so.6" + "libQt6WaylandEglCompositorHwIntegration.so.6" + "libQt6Widgets.so.6" + "libQt6XcbQpa.so.6" +) + +declare -a QTPLUGINS=( + "plugins/iconengines" + "plugins/imageformats" + "plugins/platforms" + #"plugins/platformthemes" # Enable this if we want to ship GTK+ themes at any point. + "plugins/wayland-decoration-client" + "plugins/wayland-graphics-integration-client" + "plugins/wayland-graphics-integration-server" + "plugins/wayland-shell-integration" + "plugins/xcbglintegrations" +) + +set -e + +if [ ! -f appimagetool-x86_64.AppImage ]; then + wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage + chmod +x appimagetool-x86_64.AppImage +fi + +OUTDIR=$(realpath "./$APPDIRNAME") +SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") +rm -fr "$OUTDIR" +mkdir "$OUTDIR" + +mkdir -p "$OUTDIR/usr/bin" "$OUTDIR/usr/lib" "$OUTDIR/usr/lib/pulseaudio" + +echo "Copying binary and resources..." +cp -a "$BUILDDIR/bin"/* "$OUTDIR/usr/bin" + +# We don't need tests +rm -f "$OUTDIR/usr/bin/*-tests" + +# Patch RPATH so the binary goes hunting for shared libraries in the AppDir instead of system. +echo "Patching RPATH in ${BINARY}..." +patchelf --set-rpath '$ORIGIN/../lib' "$OUTDIR/usr/bin/$BINARY" + +# Currently we leave the main binary unstripped, uncomment if this is not desired. +#$STRIP "$OUTDIR/usr/bin/$BINARY" + +# Libraries we pull in from the system. +echo "Copying system libraries..." +for lib in "${SYSLIBS[@]}"; do + blib=$(basename "$lib") + if [ -f "/lib/x86_64-linux-gnu/$lib" ]; then + cp "/lib/x86_64-linux-gnu/$lib" "$OUTDIR/usr/lib/$blib" + elif [ -f "$CHROOT/usr/lib/x86_64-linux-gnu/$lib" ]; then + cp "$CHROOT/usr/lib/x86_64-linux-gnu/$lib" "$OUTDIR/usr/lib/$blib" + elif [ -f "$CHROOT/lib/$lib" ]; then + cp "$CHROOT/lib/$lib" "$OUTDIR/usr/lib/$blib" + elif [ -f "$CHROOT/usr/lib/$lib" ]; then + cp "$CHROOT/usr/lib/$lib" "$OUTDIR/usr/lib/$blib" + else + echo "*** Failed to find '$blib'" + exit 1 + fi + + $STRIP "$OUTDIR/usr/lib/$blib" +done + +# Dependencies we built, at this point it's just SDL. +echo "Copying dependency libraries..." +for lib in "${DEPLIBS[@]}"; do + blib=$(basename "$lib") + if [ -f "$DEPSDIR/lib/$lib" ]; then + cp "$DEPSDIR/lib/$lib" "$OUTDIR/usr/lib/$blib" + else + echo "*** Failed to find '$blib'" + exit 1 + fi + + $STRIP "$OUTDIR/usr/lib/$blib" +done + +echo "Copying Qt libraries..." +for lib in "${QTLIBS[@]}"; do + cp -aL "$DEPSDIR/lib/$lib" "$OUTDIR/usr/lib" + $STRIP "$OUTDIR/usr/lib/$lib" +done + +echo "Copying Qt plugins..." +mkdir -p "$OUTDIR/usr/lib/plugins" +for plugin in "${QTPLUGINS[@]}"; do + mkdir -p "$OUTDIR/usr/lib/$plugin" + cp -aL "$DEPSDIR/$plugin"/*.so "$OUTDIR/usr/lib/$plugin/" +done + +for so in $(find "$OUTDIR/usr/lib/plugins" -iname '*.so'); do + # This is ../../ because it's usually plugins/group/name.so + echo "Patching RPATH in ${so}..." + patchelf --set-rpath '$ORIGIN/../..' "$so" + $STRIP "$so" +done + +for so in $(find "$OUTDIR/usr/lib" -maxdepth 1); do + if [ -f "$so" ]; then + echo "Patching RPATH in ${so}" + patchelf --set-rpath '$ORIGIN' "$so" + fi +done + +echo "Creating qt.conf..." +cat > "$OUTDIR/usr/bin/qt.conf" << EOF +[Paths] +Plugins = ../lib/plugins +EOF + +echo "Creating desktop..." +cat > "$OUTDIR/duckstation-qt.desktop" << EOF +[Desktop Entry] +Type=Application +Name=DuckStation +GenericName=PlayStation 1 Emulator +Comment=Fast PlayStation 1 emulator +Icon=duckstation-qt +TryExec=duckstation-qt +Exec=duckstation-qt %f +Categories=Game;Emulator;Qt; +EOF +cp "$ROOTDIR/extras/icons/icon-256px.png" "$OUTDIR/duckstation-qt.png" + +echo "Creating AppRun..." +cat > "$OUTDIR/AppRun" << EOF +#!/bin/sh + +cd "\$(dirname "\$0")" +exec ./usr/bin/$BINARY "\$@" +EOF +chmod +x "$OUTDIR/AppRun" + +echo "Generate AppImage" +./appimagetool-x86_64.AppImage -v "$OUTDIR" "$NAME.AppImage"