From 90d0029c34829a9d8f84a01c035b0465e0c1e61a Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 30 Sep 2023 12:38:21 +1000 Subject: [PATCH] Build: Unify Flatpak manifests --- CMakeLists.txt | 2 - scripts/flatpak/.gitignore | 2 +- scripts/flatpak/flathub.json | 69 ------------------ ....json => org.duckstation.DuckStation.json} | 9 +-- scripts/flatpak/update-flathub.sh | 42 ++++------- scripts/generate-metainfo.sh | 12 +-- scripts/make-appimage.sh | 9 +-- ...op => org.duckstation.DuckStation.desktop} | 2 +- ...g.duckstation.DuckStation.metainfo.xml.in} | 10 +-- ...qt.png => org.duckstation.DuckStation.png} | Bin src/scmversion/CMakeLists.txt | 18 ++--- 11 files changed, 45 insertions(+), 130 deletions(-) delete mode 100644 scripts/flatpak/flathub.json rename scripts/flatpak/{org.duckstation.duckstation.json => org.duckstation.DuckStation.json} (72%) rename scripts/{duckstation-qt.desktop => org.duckstation.DuckStation.desktop} (85%) rename scripts/{org.duckstation.duckstation.metainfo.xml.in => org.duckstation.DuckStation.metainfo.xml.in} (91%) rename scripts/{duckstation-qt.png => org.duckstation.DuckStation.png} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59a1739c4..83c499f89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,8 +24,6 @@ option(ENABLE_OPENGL "Build with OpenGL renderer" ON) option(ENABLE_VULKAN "Build with Vulkan renderer" ON) # Global options. -option(DISABLE_GEN_SCM_VERSION "Disable generation of SCM version, must manually populate" OFF) -mark_as_advanced(DISABLE_GEN_SCM_VERSION) if(NOT ANDROID) option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF) option(BUILD_QT_FRONTEND "Build the Qt frontend" ON) diff --git a/scripts/flatpak/.gitignore b/scripts/flatpak/.gitignore index 006124b0c..7e3ee0589 100644 --- a/scripts/flatpak/.gitignore +++ b/scripts/flatpak/.gitignore @@ -1,5 +1,5 @@ .flatpak-builder/ build/ repo/ -org.duckstation.duckstation.metainfo.xml +org.duckstation.DuckStation.metainfo.xml *.flatpak diff --git a/scripts/flatpak/flathub.json b/scripts/flatpak/flathub.json deleted file mode 100644 index fc3ec0938..000000000 --- a/scripts/flatpak/flathub.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "app-id": "org.duckstation.duckstation", - "runtime": "org.kde.Platform", - "runtime-version": "6.5", - "sdk": "org.kde.Sdk", - "sdk-extensions": [ - "org.freedesktop.Sdk.Extension.llvm16" - ], - "command": "duckstation-qt", - "finish-args": [ - "--device=all", - "--allow=bluetooth", - "--share=network", - "--share=ipc", - "--socket=fallback-x11", - "--socket=wayland", - "--socket=pulseaudio", - "--talk-name=org.freedesktop.ScreenSaver" - ], - "modules": [ - "modules/20-sdl2.json", - "modules/21-libbacktrace.json", - { - "name": "duckstation", - "buildsystem": "cmake", - "build-options": { - "strip": false, - "no-debuginfo": true, - "config-opts": [ - "-DCMAKE_BUILD_TYPE=Release", - "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON", - "-DBUILD_NOGUI_FRONTEND=OFF", - "-DBUILD_QT_FRONTEND=ON", - "-DBUILD_TESTS=OFF", - "-DCMAKE_C_COMPILER=/usr/lib/sdk/llvm16/bin/clang", - "-DCMAKE_CXX_COMPILER=/usr/lib/sdk/llvm16/bin/clang++", - "-DCMAKE_EXE_LINKER_FLAGS_INIT=-fuse-ld=lld", - "-DCMAKE_MODULE_LINKER_FLAGS_INIT=-fuse-ld=lld", - "-DCMAKE_SHARED_LINKER_FLAGS_INIT=-fuse-ld=lld", - "-DDISABLE_GEN_SCM_VERSION=ON" - ] - }, - "sources": [ - { - "type": "git", - "url": "https://github.com/stenzek/duckstation.git", - "branch": "master", - "commit": "@GIT_HASH@" - }, - { - "type": "file", - "path": "org.duckstation.duckstation.metainfo.xml" - }, - { - "type": "file", - "path": "scmversion.cpp", - "dest": "src/scmversion" - } - ], - "post-install": [ - "cp -a \"${FLATPAK_BUILDER_BUILDDIR}/bin\" ${FLATPAK_DEST}", - "install -Dm644 scripts/duckstation-qt.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.duckstation.png", - "install -Dm644 scripts/duckstation-qt.desktop ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop", - "desktop-file-edit --set-key=Icon --set-value=org.duckstation.duckstation ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop", - "install -Dm644 org.duckstation.duckstation.metainfo.xml ${FLATPAK_DEST}/share/metainfo/org.duckstation.duckstation.metainfo.xml" - ] - } - ] -} diff --git a/scripts/flatpak/org.duckstation.duckstation.json b/scripts/flatpak/org.duckstation.DuckStation.json similarity index 72% rename from scripts/flatpak/org.duckstation.duckstation.json rename to scripts/flatpak/org.duckstation.DuckStation.json index 816ba234a..c8c0ad085 100644 --- a/scripts/flatpak/org.duckstation.duckstation.json +++ b/scripts/flatpak/org.duckstation.DuckStation.json @@ -1,5 +1,5 @@ { - "app-id": "org.duckstation.duckstation", + "app-id": "org.duckstation.DuckStation", "runtime": "org.kde.Platform", "runtime-version": "6.5", "sdk": "org.kde.Sdk", @@ -47,10 +47,9 @@ ], "post-install": [ "cp -a \"${FLATPAK_BUILDER_BUILDDIR}/bin\" ${FLATPAK_DEST}", - "install -Dm644 scripts/duckstation-qt.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.duckstation.png", - "install -Dm644 scripts/duckstation-qt.desktop ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop", - "desktop-file-edit --set-key=Icon --set-value=org.duckstation.duckstation ${FLATPAK_DEST}/share/applications/org.duckstation.duckstation.desktop", - "install -Dm644 scripts/flatpak/org.duckstation.duckstation.metainfo.xml ${FLATPAK_DEST}/share/metainfo/org.duckstation.duckstation.metainfo.xml" + "install -Dm644 scripts/org.duckstation.DuckStation.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.DuckStation.png", + "install -Dm644 scripts/org.duckstation.DuckStation.desktop ${FLATPAK_DEST}/share/applications/org.duckstation.DuckStation.desktop", + "install -Dm644 scripts/flatpak/org.duckstation.DuckStation.metainfo.xml ${FLATPAK_DEST}/share/metainfo/org.duckstation.DuckStation.metainfo.xml" ] } ] diff --git a/scripts/flatpak/update-flathub.sh b/scripts/flatpak/update-flathub.sh index 6c2d1443f..7369ae074 100755 --- a/scripts/flatpak/update-flathub.sh +++ b/scripts/flatpak/update-flathub.sh @@ -9,34 +9,24 @@ if [[ $# -lt 1 ]]; then fi OUTDIR=$(realpath "$1") +OUTMANIFEST="${OUTDIR}/${APPID}.json" +echo -n "Get revision: " +pushd "${SCRIPTDIR}" >/dev/null +GIT_HASH=$(git rev-parse HEAD) +popd >/dev/null +echo "${GIT_HASH}" + +echo "Updating files in ${OUTDIR}..." +mkdir -p "${OUTDIR}" rm -fr "${OUTDIR}/modules" cp -a "${SCRIPTDIR}/modules" "${OUTDIR}/modules" -cp "${SCRIPTDIR}/flathub.json" "${OUTDIR}/${APPID}.json" -pushd "${SCRIPTDIR}" -GIT_DATE=$(git log -1 --pretty=%cd --date=short) -GIT_VERSION=$(git tag --points-at HEAD) -GIT_HASH=$(git rev-parse HEAD) +echo "Generate AppStream XML..." +"${SCRIPTDIR}/../../scripts/generate-metainfo.sh" "${OUTDIR}" -if [[ "${GIT_VERSION}" == "" ]]; then - GIT_VERSION=$(git describe --tags --dirty --exclude latest --exclude preview --exclude legacy --exclude previous-latest | tr -d '\r\n') - if [[ "${GIT_VERSION}" == "" ]]; then - GIT_VERSION=$(git rev-parse HEAD) - fi -fi -"${SCRIPTDIR}/../../scripts/generate-metainfo.sh" "${OUTDIR}/${APPID}.metainfo.xml" -popd - -# Change App ID, because flathub uses the wrong name. -sed -i -e "s/org.duckstation.duckstation/org.duckstation.DuckStation/g" "${OUTDIR}/${APPID}.json" "${OUTDIR}/${APPID}.metainfo.xml" - -# Fill in version details. -sed -i -e "s/@GIT_VERSION@/${GIT_VERSION}/" "${OUTDIR}/${APPID}.json" -sed -i -e "s/@GIT_DATE@/${GIT_DATE}/" "${OUTDIR}/${APPID}.json" -sed -i -e "s/@GIT_HASH@/${GIT_HASH}/" "${OUTDIR}/${APPID}.json" - -# Apparently we don't have git history. -pushd "${OUTDIR}" -"${SCRIPTDIR}/../../src/scmversion/gen_scmversion.sh" -popd +echo "Patching Manifest Sources..." +jq ".modules[2].sources = ["\ +"{\"type\": \"git\", \"url\": \"https://github.com/stenzek/duckstation.git\", \"commit\": \"${GIT_HASH}\", \"disable-shallow-clone\": true},"\ +"{\"type\": \"file\", \"path\": \"org.duckstation.DuckStation.metainfo.xml\", \"dest\": \"scripts/flatpak\"}]" \ +"${SCRIPTDIR}/${APPID}.json" > "${OUTMANIFEST}" diff --git a/scripts/generate-metainfo.sh b/scripts/generate-metainfo.sh index 31f8f251f..57bd847f5 100755 --- a/scripts/generate-metainfo.sh +++ b/scripts/generate-metainfo.sh @@ -3,13 +3,15 @@ SCRIPTDIR=$(realpath $(dirname "${BASH_SOURCE[0]}")) if [[ $# -lt 1 ]]; then - echo "Output file must be provided as a parameter" + echo "Output directory must be provided as a parameter" exit 1 fi -OUTFILE="$1" +APPID="org.duckstation.DuckStation" +OUTDIR=$(realpath "$1") +OUTFILE="${OUTDIR}/${APPID}.metainfo.xml" -pushd "${SCRIPTDIR}" +pushd "${SCRIPTDIR}" >/dev/null GIT_DATE=$(git log -1 --pretty=%cd --date=short) GIT_VERSION=$(git tag --points-at HEAD) GIT_HASH=$(git rev-parse HEAD) @@ -20,13 +22,13 @@ if [[ "${GIT_VERSION}" == "" ]]; then GIT_VERSION=$(git rev-parse HEAD) fi fi -popd +popd >/dev/null echo "GIT_DATE: ${GIT_DATE}" echo "GIT_VERSION: ${GIT_VERSION}" echo "GIT_HASH: ${GIT_HASH}" -cp "${SCRIPTDIR}"/org.duckstation.duckstation.metainfo.xml.in "${OUTFILE}" +cp "${SCRIPTDIR}/${APPID}.metainfo.xml.in" "${OUTFILE}" sed -i -e "s/@GIT_VERSION@/${GIT_VERSION}/" "${OUTFILE}" sed -i -e "s/@GIT_DATE@/${GIT_DATE}/" "${OUTFILE}" diff --git a/scripts/make-appimage.sh b/scripts/make-appimage.sh index ca029b480..23ff6bcca 100755 --- a/scripts/make-appimage.sh +++ b/scripts/make-appimage.sh @@ -107,17 +107,14 @@ for i in $(find "$DEPSDIR" -iname '*.so'); do strip "$i" done -echo "Copying desktop file..." -cp "$ROOTDIR/scripts/duckstation-qt.desktop" "org.duckstation.duckstation.desktop" -cp "$ROOTDIR/scripts/duckstation-qt.png" "duckstation-qt.png" - echo "Running linuxdeploy to create AppDir..." EXTRA_QT_PLUGINS="core;gui;network;svg;waylandclient;widgets;xcbqpa" \ EXTRA_PLATFORM_PLUGINS="libqwayland-egl.so;libqwayland-generic.so" \ QMAKE="$DEPSDIR/bin/qmake" \ NO_STRIP="1" \ $LINUXDEPLOY --plugin qt --appdir="$OUTDIR" --executable="$BUILDDIR/bin/duckstation-qt" \ ---desktop-file="org.duckstation.duckstation.desktop" --icon-file="duckstation-qt.png" +--desktop-file="$ROOTDIR/scripts/org.duckstation.DuckStation.desktop" \ +--icon-file="$ROOTDIR/scripts/org.duckstation.DuckStation.png" echo "Copying resources into AppDir..." cp -a "$BUILDDIR/bin/resources" "$OUTDIR/usr/bin" @@ -162,7 +159,7 @@ cp -a "$BUILDDIR/bin/translations" "$OUTDIR/usr/bin" # Generate AppStream meta-info. echo "Generating AppStream metainfo..." mkdir -p "$OUTDIR/usr/share/metainfo" -"$SCRIPTDIR/generate-metainfo.sh" "$OUTDIR/usr/share/metainfo/org.duckstation.duckstation.appdata.xml" +"$SCRIPTDIR/generate-metainfo.sh" "$OUTDIR/usr/share/metainfo" echo "Generating AppImage..." rm -f "$NAME.AppImage" diff --git a/scripts/duckstation-qt.desktop b/scripts/org.duckstation.DuckStation.desktop similarity index 85% rename from scripts/duckstation-qt.desktop rename to scripts/org.duckstation.DuckStation.desktop index d6adb9f6c..bcda52c1d 100644 --- a/scripts/duckstation-qt.desktop +++ b/scripts/org.duckstation.DuckStation.desktop @@ -3,7 +3,7 @@ Type=Application Name=DuckStation GenericName=PlayStation 1 Emulator Comment=Fast PlayStation 1 emulator -Icon=duckstation-qt +Icon=org.duckstation.DuckStation TryExec=duckstation-qt Exec=duckstation-qt %f Categories=Game;Emulator;Qt; diff --git a/scripts/org.duckstation.duckstation.metainfo.xml.in b/scripts/org.duckstation.DuckStation.metainfo.xml.in similarity index 91% rename from scripts/org.duckstation.duckstation.metainfo.xml.in rename to scripts/org.duckstation.DuckStation.metainfo.xml.in index 5c6121679..0d5ea193e 100644 --- a/scripts/org.duckstation.duckstation.metainfo.xml.in +++ b/scripts/org.duckstation.DuckStation.metainfo.xml.in @@ -1,17 +1,19 @@ - org.duckstation.duckstation - org.duckstation.duckstation.desktop + org.duckstation.DuckStation + org.duckstation.DuckStation.desktop CC0-1.0 GPL-3.0 DuckStation - DuckStation + Stenzek PlayStation Emulator

DuckStation is an simulator/emulator of the Sony PlayStation(TM) console, focusing on playability, speed, and long-term maintainability. The goal is to be as accurate as possible while maintaining performance suitable for low-end devices.

"Hack" options are discouraged, the default configuration should support all playable games with only some of the enhancements having compatibility issues.

"PlayStation" and "PSX" are registered trademarks of Sony Interactive Entertainment Europe Limited. This project is not affiliated in any way with Sony Interactive Entertainment.

+ + stenzek_AT_gmail.com https://www.duckstation.org/ https://github.com/stenzek/duckstation https://github.com/stenzek/duckstation @@ -23,8 +25,6 @@ https://raw.githubusercontent.com/stenzek/duckstation/md-images/bigduck.png - - stenzek_AT_gmail.com diff --git a/scripts/duckstation-qt.png b/scripts/org.duckstation.DuckStation.png similarity index 100% rename from scripts/duckstation-qt.png rename to scripts/org.duckstation.DuckStation.png diff --git a/src/scmversion/CMakeLists.txt b/src/scmversion/CMakeLists.txt index 903ecdfdc..7a5129298 100644 --- a/src/scmversion/CMakeLists.txt +++ b/src/scmversion/CMakeLists.txt @@ -1,13 +1,11 @@ -if(NOT DISABLE_GEN_SCM_VERSION) - if(WIN32) - # _scmversion.cpp is a dummy file that will never be created, so the command will always be run - add_custom_command(OUTPUT scmversion.cpp _scmversion.cpp - COMMAND cmd /k "${CMAKE_CURRENT_SOURCE_DIR}/gen_scmversion.bat" - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") - else() - add_custom_command(OUTPUT scmversion.cpp PRE_BUILD - COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/gen_scmversion.sh") - endif() +# _scmversion.cpp is a dummy file that will never be created, so the command will always be run +if(WIN32) + add_custom_command(OUTPUT scmversion.cpp _scmversion.cpp + COMMAND cmd /k "${CMAKE_CURRENT_SOURCE_DIR}/gen_scmversion.bat" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +else() + add_custom_command(OUTPUT scmversion.cpp PRE_BUILD + COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/gen_scmversion.sh") endif() add_library(scmversion