Build: Add Flatpak manifest and scripts

This commit is contained in:
Stenzek 2023-09-02 16:54:51 +10:00
parent d6577b7279
commit 59b70b6adb
10 changed files with 281 additions and 7 deletions

View file

@ -26,6 +26,7 @@ endif()
option(BUILD_NOGUI_FRONTEND "Build the NoGUI frontend" OFF)
option(BUILD_QT_FRONTEND "Build the Qt frontend" ON)
option(BUILD_REGTEST "Build regression test runner" OFF)
option(BUILD_TESTS "Build unit tests" OFF)
option(ENABLE_CUBEB "Build with Cubeb audio output" ON)
option(ENABLE_OPENGL "Build with OpenGL renderer" ON)
option(ENABLE_VULKAN "Build with Vulkan renderer" ON)
@ -77,7 +78,7 @@ if(NOT WIN32 AND NOT ANDROID)
find_package(CURL REQUIRED)
endif()
if(BUILD_QT_FRONTEND)
find_package(Qt6 6.5.2 COMPONENTS Core Gui Widgets Network LinguistTools REQUIRED)
find_package(Qt6 6.5.1 COMPONENTS Core Gui Widgets Network LinguistTools REQUIRED)
endif()
@ -221,9 +222,11 @@ if((LINUX OR FREEBSD) AND (${CPU_ARCH} STREQUAL "x86" OR ${CPU_ARCH} STREQUAL "a
add_definitions("-D_FILE_OFFSET_BITS=64")
endif()
if(BUILD_TESTS)
enable_testing()
endif()
# Recursively include the source tree.
enable_testing()
add_subdirectory(dep)
add_subdirectory(src)

5
scripts/flatpak/.gitignore vendored Normal file
View file

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

View file

@ -0,0 +1,9 @@
[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;

View file

@ -0,0 +1,31 @@
#!/usr/bin/env bash
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
if [[ $# -lt 1 ]]; then
echo "Output file must be provided as a parameter"
exit 1
fi
OUTFILE=$1
GIT_DATE=$(git log -1 --pretty=%cd --date=short)
GIT_VERSION=$(git tag --points-at HEAD)
GIT_HASH=$(git rev-parse HEAD)
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
echo "GIT_DATE: ${GIT_DATE}"
echo "GIT_VERSION: ${GIT_VERSION}"
echo "GIT_HASH: ${GIT_HASH}"
cp "${SCRIPTDIR}"/org.duckstation.duckstation.metainfo.xml.in "${OUTFILE}"
sed -i -e "s/@GIT_VERSION@/${GIT_VERSION}/" "${OUTFILE}"
sed -i -e "s/@GIT_DATE@/${GIT_DATE}/" "${OUTFILE}"
sed -i -e "s/@GIT_HASH@/${GIT_HASH}/" "${OUTFILE}"

View file

@ -0,0 +1,67 @@
#!/bin/bash
set -e
SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}")
function retry_command {
# Package servers tend to be unreliable at times..
# Retry a bunch of times.
local RETRIES=10
for i in $(seq 1 "$RETRIES"); do
"$@" && break
if [ "$i" == "$RETRIES" ]; then
echo "Command \"$@\" failed after ${RETRIES} retries."
exit 1
fi
done
}
ARCH=x86_64
KDE_BRANCH=6.5
BRANCH=22.08
FLAT_MANAGER_CLIENT_DIR="$HOME/.local/bin"
# Build packages. Mostly needed for flat-manager-client.
declare -a BUILD_PACKAGES=(
"flatpak"
"flatpak-builder"
"appstream-util"
"python3-aiohttp"
"python3-tenacity"
"python3-gi"
"gobject-introspection"
"libappstream-glib8"
"libappstream-glib-dev"
"libappstream-dev"
"gir1.2-ostree-1.0"
)
# Flatpak runtimes and SDKs.
declare -a FLATPAK_PACKAGES=(
"org.kde.Platform/${ARCH}/${KDE_BRANCH}"
"org.kde.Sdk/${ARCH}/${KDE_BRANCH}"
"org.freedesktop.Sdk.Extension.llvm16/${ARCH}/${BRANCH}"
"org.freedesktop.appstream-glib/${ARCH}/stable"
)
retry_command sudo apt-get -qq update
# Install packages needed for building
echo "Will install the following packages for building - ${BUILD_PACKAGES[*]}"
retry_command sudo apt-get -y install "${BUILD_PACKAGES[@]}"
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
# Install packages needed for building
echo "Will install the following packages for building - ${FLATPAK_PACKAGES[*]}"
retry_command sudo flatpak -y install "${FLATPAK_PACKAGES[@]}"
echo "Downloading flat-manager-client"
mkdir -p "$FLAT_MANAGER_CLIENT_DIR"
pushd "$FLAT_MANAGER_CLIENT_DIR"
aria2c -Z "https://raw.githubusercontent.com/flatpak/flat-manager/9401efbdc0d6bd489507d8401c567ba219d735d5/flat-manager-client"
chmod +x flat-manager-client
echo "$FLAT_MANAGER_CLIENT_DIR" >> $GITHUB_PATH
popd

View file

@ -0,0 +1,45 @@
{
"name": "sdl2",
"buildsystem": "autotools",
"no-autogen": true,
"config-opts": [
"--disable-dbus",
"--without-x",
"--disable-video-opengl",
"--disable-video-opengles",
"--disable-video-vulkan",
"--disable-wayland-shared",
"--disable-ime",
"--disable-oss",
"--disable-alsa",
"--disable-jack",
"--disable-esd",
"--disable-pipewire",
"--disable-pulseaudio",
"--disable-arts",
"--disable-nas",
"--disable-sndio",
"--disable-fusionsound",
"--disable-diskaudio"
],
"build-options": {
"strip": true
},
"sources": [
{
"type": "archive",
"url": "https://libsdl.org/release/SDL2-2.28.2.tar.gz",
"sha256": "64b1102fa22093515b02ef33dd8739dee1ba57e9dbba6a092942b8bbed1a1c5e"
}
],
"cleanup": [
"/bin",
"/include",
"/lib/*.a",
"/lib/*.la",
"/lib/cmake",
"/lib/pkgconfig",
"/share/aclocal"
]
}

View file

@ -0,0 +1,22 @@
{
"name": "libbacktrace",
"buildsystem": "autotools",
"no-autogen": true,
"build-options": {
"strip": false,
"no-debuginfo": true
},
"sources": [
{
"type": "git",
"url": "https://github.com/ianlancetaylor/libbacktrace.git",
"commit": "ad106d5fdd5d960bd33fae1c48a351af567fd075"
}
],
"cleanup": [
"/include",
"/lib/*.a",
"/lib/*.la"
]
}

View file

@ -0,0 +1,57 @@
{
"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",
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
"--socket=wayland",
"--socket=pulseaudio",
"--filesystem=host:ro",
"--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"
]
},
"sources": [
{
"type": "dir",
"path": "../.."
}
],
"post-install": [
"cp -a \"${FLATPAK_BUILDER_BUILDDIR}/bin\" ${FLATPAK_DEST}",
"install -Dm644 data/resources/images/duck.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/org.duckstation.duckstation.png",
"install -Dm644 scripts/flatpak/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"
]
}
]
}

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<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>
<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>
<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>
<screenshots>
<screenshot type="default">
<image>https://raw.githubusercontent.com/stenzek/duckstation/md-images/main-qt.png</image>
</screenshot>
<screenshot>
<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>
<custom>
<value key="flathub::manifest">https://raw.githubusercontent.com/stenzek/duckstation/@GIT_HASH@/scripts/flatpak/org.duckstation.duckstation.json</value>
</custom>
</component>

View file

@ -3,11 +3,8 @@ add_subdirectory(util)
add_subdirectory(core)
add_subdirectory(scmversion)
if(NOT ANDROID)
add_subdirectory(common-tests)
if(WIN32)
add_subdirectory(updater)
endif()
if(WIN32)
add_subdirectory(updater)
endif()
if(BUILD_NOGUI_FRONTEND)
@ -21,3 +18,7 @@ endif()
if(BUILD_REGTEST)
add_subdirectory(duckstation-regtest)
endif()
if(BUILD_TESTS)
add_subdirectory(common-tests)
endif()