name: sayonara
adopt-info: sayonara
grade: stable
confinement: strict
base: core20
compression: lzo

apps:
  sayonara:
    adapter: full
    command: usr/bin/sayonara
    common-id: com.sayonara-player.Sayonara
    desktop: usr/share/applications/com.sayonara-player.Sayonara.desktop
    extensions:
      - kde-neon
    plugs:
      - audio-playback
      - desktop
      - desktop-legacy
      - home
      - network
      - network-bind
      - network-manager-observe
      - opengl
      - optical-drive
      - removable-media
      - unity7
    slots:
      - mpris
    environment:
      QT_QPA_PLATFORMTHEME: xdgdesktopportal
      GIO_EXTRA_MODULES: $SNAP/kf5/usr/lib/x86_64-linux-gnu/gio/modules
      XDG_DATA_DIRS: $SNAP/usr/share/glib-2.0/schemas:$XDG_DATA_DIRS

layout:
  /usr/share/sayonara:
    bind: $SNAP/usr/share/sayonara

parts:
  sayonara:
    source-type: local
    source: .
    parse-info: [ usr/share/metainfo/com.sayonara-player.Sayonara.appdata.xml ]
    plugin: cmake
    cmake-parameters:
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DDISABLE_NATIVE_DIR_DIALOGS=1
      - -DCMAKE_CXX_COMPILER=clang++-10
      - -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=gold
      - -DGIT_REVISION=$CI_COMMIT_SHORT_SHA
    override-build: |
      snapcraftctl build
      sed -i 's|Icon=sayonara|Icon=${SNAP}/usr/share/icons/hicolor/256x256/apps/sayonara.png|g' $SNAPCRAFT_PART_INSTALL/usr/share/applications/com.sayonara-player.Sayonara.desktop
    build-packages:
      - binutils-gold
      - clang-10
      - cmake
      - git
      - libgstreamer-plugins-bad1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libgstreamer-plugins-good1.0-dev
      - libgstreamer1.0-dev
      - libtag1-dev
      - pkg-config
      - zlib1g-dev
    stage-packages:
      - libgpm2 # requred by gstreamer autoaudiosink
      - freeglut3
      - ffmpeg
      - glib-networking
      - gsettings-desktop-schemas
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-ugly
      - gstreamer1.0-libav
      - libgcc1
      - libglib2.0-0
      - libgstreamer1.0-0
      - libgstreamer-plugins-bad1.0-0
      - libgstreamer-plugins-base1.0-0
      - libgstreamer-plugins-good1.0-0
      - libstdc++6
      - zlib1g
      - libslang2
    override-prime: |
      snapcraftctl prime
      $SNAPCRAFT_PRIME/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/glib-2.0/glib-compile-schemas --targetdir $SNAPCRAFT_PRIME/usr/share/glib-2.0/schemas $SNAPCRAFT_PRIME/usr/share/glib-2.0/schemas

  cleanup:
    after:
      - sayonara
    plugin: nil
    build-snaps:
      - gtk-common-themes
    build-environment:
      - KDE_RUNTIME: kde-frameworks-5-99-qt-5-15-7-core20
    override-prime: |
      set -eux
      for snap in "gtk-common-themes" "$KDE_RUNTIME" ; do
          cd "/snap/$snap/current" && find . -type f,l -exec rm -rf "$SNAPCRAFT_PRIME/{}" \;
      done
