Build: Unify Flatpak manifests

This commit is contained in:
Stenzek 2023-09-30 12:38:21 +10:00
parent 28c13c0ac4
commit 90d0029c34
11 changed files with 45 additions and 130 deletions

View File

@ -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)

View File

@ -1,5 +1,5 @@
.flatpak-builder/
build/
repo/
org.duckstation.duckstation.metainfo.xml
org.duckstation.DuckStation.metainfo.xml
*.flatpak

View File

@ -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"
]
}
]
}

View File

@ -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"
]
}
]

View File

@ -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}"

View File

@ -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}"

View File

@ -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"

View File

@ -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;

View File

@ -1,17 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.duckstation.duckstation</id>
<launchable type="desktop-id">org.duckstation.duckstation.desktop</launchable>
<id>org.duckstation.DuckStation</id>
<launchable type="desktop-id">org.duckstation.DuckStation.desktop</launchable>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0</project_license>
<name>DuckStation</name>
<developer_name>DuckStation</developer_name>
<developer_name>Stenzek</developer_name>
<summary>PlayStation Emulator</summary>
<description>
<p>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.</p>
<p>"Hack" options are discouraged, the default configuration should support all playable games with only some of the enhancements having compatibility issues.</p>
<p>"PlayStation" and "PSX" are registered trademarks of Sony Interactive Entertainment Europe Limited. This project is not affiliated in any way with Sony Interactive Entertainment.</p>
</description>
<content_rating type="oars-1.1"/>
<update_contact>stenzek_AT_gmail.com</update_contact>
<url type="homepage">https://www.duckstation.org/</url>
<url type="help">https://github.com/stenzek/duckstation</url>
<url type="vcs-browser">https://github.com/stenzek/duckstation</url>
@ -23,8 +25,6 @@
<image>https://raw.githubusercontent.com/stenzek/duckstation/md-images/bigduck.png</image>
</screenshot>
</screenshots>
<content_rating type="oars-1.1"/>
<update_contact>stenzek_AT_gmail.com</update_contact>
<releases>
<release version="@GIT_VERSION@" date="@GIT_DATE@" />
</releases>

View File

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -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