#
# Flatpak manifest
#
# For building the flatpak, first ensure flathub repo is added for installing the KDE runtime.
#
#    flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
#
# To build and install the Flatpak (requires flatpak and flatpak-builder programs):
#
#    flatpak-builder --user --install --install-deps-from=flathub --force-clean --state-dir=flatpak-state flatpak-build mm3d-flatpak.yaml
#
# After it's installed you can remove "flatpak-state" and "flatpak-build" directories.
#
#    rm -r flatpak-state flatpak-build
#
# To uninstall the Flatpak use:
#
#    flatpak uninstall --user moe.clover.mm3d
#
#
# Releases are built labeled as "stable" branch using the following:
#
#    flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
#    flatpak-builder --default-branch=stable --user --install-deps-from=flathub --force-clean --repo=flatpak-repo --state-dir=flatpak-state flatpak-build mm3d-flatpak.yaml
#    flatpak build-bundle flatpak-repo moe.clover.mm3d-$(git describe|sed 's/^v\([0-9]\)/\1/').flatpak moe.clover.mm3d stable
#
# The release can be installed using:
#
#    flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
#    flatpak install --user flathub org.kde.Platform/x86_64/5.15-23.08
#    flatpak install --user -y moe.clover.mm3d-*.flatpak
#
#

app-id: moe.clover.mm3d
runtime: org.kde.Platform
runtime-version: '5.15-23.08'
sdk: org.kde.Sdk
command: mm3d
finish-args:
  # Qt has issues on Wayland in 5.15-23.08 SDK (only tested on Gnome)
  # * The main window content size and/or position flickers.
  # * Model viewport flickers between old frame sometimes.
  # * Opening, closing, and reopening Materials -> Texture Coordinates...
  #   causes the texture to be transparent after clicking it until
  #   interacting with some other part of the window.
  - --socket=x11
  # OpenGL access
  - --device=dri
  # Wayland access
  #- --socket=wayland
  # X11 + XShm access
  - --share=ipc
  #- --socket=fallback-x11
  # File access
  - --filesystem=host
modules:
  # glu from flathub/shared-modules
  - name: glu
    buildsystem: meson
    sources:
    - type: archive
      url: https://archive.mesa3d.org/glu/glu-9.0.3.tar.xz
      sha256: bd43fe12f374b1192eb15fe20e45ff456b9bc26ab57f0eee919f96ca0f8a330f
    cleanup:
      - "/include"
      - "/lib/*.a"
      - "/lib/*.la"
      - "/lib/pkgconfig"
  - name: mm3d
    config-opts:
      # specify where GLU was just installed to
      # NOTE: "-L/app/lib" is set in LDFLAGS by flatpak-builder but mm3d configure doesn't use it for testing GL LIBS.
      - "--with-GL-cflags=-L/app/lib"
    sources:
      - type: dir
        path: .
