id: org.prismlauncher.PrismLauncher
runtime: org.kde.Platform
runtime-version: "5.15-22.08"
sdk: org.kde.Sdk
sdk-extensions:
  - org.freedesktop.Sdk.Extension.openjdk17
  - org.freedesktop.Sdk.Extension.openjdk8

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

cleanup:
  - /lib/libGLU*

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
      - -DLauncher_QT_VERSION_MAJOR=5
    build-options:
      env:
        JAVA_HOME: /usr/lib/sdk/openjdk17/jvm/openjdk-17
        JAVA_COMPILER: /usr/lib/sdk/openjdk17/jvm/openjdk-17/bin/javac
    sources:
      - type: dir
        path: ../

  - name: openjdk
    buildsystem: simple
    build-commands:
      - mkdir -p /app/jdk/
      - /usr/lib/sdk/openjdk17/install.sh
      - mv /app/jre /app/jdk/17
      - /usr/lib/sdk/openjdk8/install.sh
      - mv /app/jre /app/jdk/8
    cleanup:
      - /jre

  - name: glfw
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=RelWithDebInfo
      - -DBUILD_SHARED_LIBS:BOOL=ON
      - -DGLFW_USE_WAYLAND=ON
    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
        archive-type: tar-gzip
        url: https://api.github.com/repos/FeralInteractive/gamemode/tarball/1.7
        sha256: 57ce73ba605d1cf12f8d13725006a895182308d93eba0f69f285648449641803
        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