id: org.prismlauncher.PrismLauncher
runtime: org.kde.Platform
runtime-version: 6.7
sdk: org.kde.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.openjdk17

command: prismlauncher
finish-args:
  - --share=ipc
  - --socket=x11
  - --socket=wayland
  - --device=all
  - --share=network
  - --socket=pulseaudio
    # for Discord RPC mods
  - --filesystem=xdg-run/app/com.discordapp.Discord:create
    # Mod drag&drop
  - --filesystem=xdg-download:ro
    # FTBApp import
  - --filesystem=~/.ftba:ro

modules:
  # Might be needed by some Controller mods (see https://github.com/isXander/Controlify/issues/31)
  - shared-modules/libusb/libusb.json

  # Needed for proper Wayland support
  - libdecor.json

  - name: prismlauncher
    buildsystem: cmake-ninja
    builddir: true
    config-opts:
      - -DLauncher_BUILD_PLATFORM=flatpak
      - -DCMAKE_BUILD_TYPE=RelWithDebInfo
    build-options:
      env:
        JAVA_HOME: /usr/lib/sdk/openjdk17/jvm/openjdk-17
        JAVA_COMPILER: /usr/lib/sdk/openjdk17/jvm/openjdk-17/bin/javac
    run-tests: true
    sources:
      - type: dir
        path: ../

  - name: glfw
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=RelWithDebInfo
      - -DBUILD_SHARED_LIBS:BOOL=ON
      - -DGLFW_USE_WAYLAND:BOOL=ON
      - -DGLFW_BUILD_DOCS:BOOL=OFF
    sources:
      - type: git
        url: https://github.com/glfw/glfw.git
        commit: 3fa2360720eeba1964df3c0ecf4b5df8648a8e52
      - type: patch
        path: patches/0003-Don-t-crash-on-calls-to-focus-or-icon.patch
      - type: patch
        path: patches/0005-Add-warning-about-being-an-unofficial-patch.patch
      - type: patch
        path: patches/0007-Platform-Prefer-Wayland-over-X11.patch
    cleanup:
      - /include
      - /lib/cmake
      - /lib/pkgconfig

  - name: xrandr
    buildsystem: autotools
    sources:
      - type: archive
        url: https://xorg.freedesktop.org/archive/individual/app/xrandr-1.5.2.tar.xz
        sha256: c8bee4790d9058bacc4b6246456c58021db58a87ddda1a9d0139bf5f18f1f240
        x-checker-data:
          type: anitya
          project-id: 14957
          stable-only: true
          url-template: https://xorg.freedesktop.org/archive/individual/app/xrandr-$version.tar.xz
    cleanup:
      - /share/man
      - /bin/xkeystone

  - name: gamemode
    buildsystem: meson
    config-opts:
      - -Dwith-sd-bus-provider=no-daemon
      - -Dwith-examples=false
    post-install:
      # gamemoderun is installed for users who want to use wrapper commands
      # post-install is running inside the build dir, we need it from the source though
      - install -Dm755 ../data/gamemoderun -t /app/bin
    sources:
      - type: archive
        dest-filename: gamemode.tar.gz
        url: https://api.github.com/repos/FeralInteractive/gamemode/tarball/1.8.1
        sha256: 969cf85b5ca3944f3e315cd73a0ee9bea4f9c968cd7d485e9f4745bc1e679c4e
        x-checker-data:
          type: json
          url: https://api.github.com/repos/FeralInteractive/gamemode/releases/latest
          version-query: .tag_name
          url-query: .tarball_url
          timestamp-query: .published_at
    cleanup:
      - /include
      - /lib/pkgconfig
      - /lib/libgamemodeauto.a

  - name: glxinfo
    buildsystem: meson
    config-opts:
      - --bindir=/app/mesa-demos
      - -Degl=disabled
      - -Dglut=disabled
      - -Dosmesa=disabled
      - -Dvulkan=disabled
      - -Dwayland=disabled
    post-install:
      - mv -v /app/mesa-demos/glxinfo /app/bin
    sources:
      - type: archive
        url: https://archive.mesa3d.org/demos/mesa-demos-9.0.0.tar.xz
        sha256: 3046a3d26a7b051af7ebdd257a5f23bfeb160cad6ed952329cdff1e9f1ed496b
        x-checker-data:
          type: anitya
          project-id: 16781
          stable-only: true
          url-template: https://archive.mesa3d.org/demos/mesa-demos-$version.tar.xz
    cleanup:
      - /include
      - /mesa-demos
      - /share
    modules:
      - shared-modules/glu/glu-9.json

  - name: enhance
    buildsystem: simple
    build-commands:
      - install -Dm755 prime-run /app/bin/prime-run
      - mv /app/bin/prismlauncher /app/bin/prismrun
      - install -Dm755 prismlauncher /app/bin/prismlauncher
    sources:
      - type: file
        path: prime-run
      - type: file
        path: prismlauncher
