{
  "app-id": "net.pcsx2.PCSX2",
  "runtime": "org.kde.Platform",
  "runtime-version": "6.10",
  "sdk": "org.kde.Sdk",
  "sdk-extensions": [
    "org.freedesktop.Sdk.Extension.llvm20"
  ],
  "add-extensions": {
    "org.freedesktop.Platform.ffmpeg-full": {
      "directory": "lib/ffmpeg",
      "version": "25.08",
      "add-ld-path": ".",
      "autodownload": true
    }
  },
  "command": "pcsx2-qt",
  "finish-args": [
    "--device=all",
    "--share=network",
    "--share=ipc",
    "--socket=wayland",
    "--socket=fallback-x11",
    "--socket=pulseaudio",
    "--talk-name=org.freedesktop.ScreenSaver",
    "--filesystem=xdg-run/gamescope-0:ro"
  ],
  "modules": [
    "modules/10-libpcap.json",
    "modules/20-sdl3.json",
    "modules/21-libbacktrace.json",
    "modules/22-shaderc.json",
    "modules/23-kddockwidgets.json",
    "modules/24-plutovg.json",
    "modules/25-plutosvg.json",
    "modules/26-libpng.json",
    "modules/27-qtapng.json",
    "modules/28-rapidyaml.json",
    {
      "name": "pcsx2",
      "buildsystem": "cmake-ninja",
      "builddir": true,
      "no-make-install": true,
      "build-options": {
        "strip": false,
        "no-debuginfo": true,
        "cflags": "",
        "cflags-override": true,
        "cxxflags": "",
        "cxxflags-override": true,
        "config-opts": [
          "-DCMAKE_PREFIX_PATH=\"${FLATPAK_DEST}\"",
          "-DCMAKE_BUILD_TYPE=Release",
          "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON",
          "-DCMAKE_C_COMPILER=/usr/lib/sdk/llvm20/bin/clang",
          "-DCMAKE_CXX_COMPILER=/usr/lib/sdk/llvm20/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",
          "-DUSE_LINKED_FFMPEG=ON",
          "-DDISABLE_ADVANCE_SIMD=TRUE"
        ]
      },
      "sources": [
        {
          "type": "dir",
          "path": "../../../../.."
        }
      ],
      "post-install": [
        "cp -a bin \"${FLATPAK_DEST}\"",
        "install -Dm644 \"${FLATPAK_BUILDER_BUILDDIR}/bin/resources/icons/AppIconLarge.png\" \"${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/net.pcsx2.PCSX2.png\"",
        "install -Dm644 \"${FLATPAK_BUILDER_BUILDDIR}/.github/workflows/scripts/linux/pcsx2-qt.desktop\" \"${FLATPAK_DEST}/share/applications/net.pcsx2.PCSX2.desktop\"",
        "desktop-file-edit --set-key=Icon --set-value=net.pcsx2.PCSX2 \"${FLATPAK_DEST}/share/applications/net.pcsx2.PCSX2.desktop\"",
        "${FLATPAK_BUILDER_BUILDDIR}/.github/workflows/scripts/linux/generate-metainfo.sh \"${FLATPAK_BUILDER_BUILDDIR}/net.pcsx2.PCSX2.metainfo.xml\"",
        "cat \"${FLATPAK_BUILDER_BUILDDIR}/net.pcsx2.PCSX2.metainfo.xml\"",
        "install -Dm644 \"${FLATPAK_BUILDER_BUILDDIR}/net.pcsx2.PCSX2.metainfo.xml\" \"${FLATPAK_DEST}/share/metainfo/net.pcsx2.PCSX2.metainfo.xml\"",
        "mkdir -p \"${FLATPAK_DEST}/lib/ffmpeg\""
      ]
    }
  ]
}
