name: synfigstudio
title: 'Synfig Studio'
version: '1.4.2'
summary: Create and edit 2D animations and compositions
description: |
  Synfig Studio is a free and open-source 2D animation software, designed as
  powerful industrial-strength solution for creating film-quality animation
  using a vector and bitmap artwork. It eliminates the need to create
  animation frame-by frame, allowing you to produce 2D animation of a higher
  quality with fewer people and resources.

  Features:

  - Can manipulate vector and bitmap artwork
  - Automatic tweening (independent from FPS)
  - Multitude of layers of various types (geometry primitives, shapes,
  gradients, fractals)
  - Full-featured bone system
  - Filters and effects for compositing (blurs, distortions, color
  manipulation, masks)
  - All color operations use High Dynamic-Range Imaging (HDRI)
  - Pentablet-friendly tools
  - Sound support
  - Linking data on file- or parameter-level
  - Automatic animation using mathematical functions

base: core18
confinement: strict
license: GPL-3.0
grade: stable

architectures:
  - build-on: arm64
  - build-on: armhf
  - build-on: amd64

apps:
  synfigstudio: &app
    command: usr/bin/synfigstudio
    common-id: org.synfig.SynfigStudio
    desktop: usr/share/applications/org.synfig.SynfigStudio.desktop
    extensions: [gnome-3-34]
    plugs: &plugs [opengl, home, removable-media, gsettings, network]
    environment: &env
      __EGL_VENDOR_LIBRARY_DIRS: $SNAP/gnome-platform/usr/share/glvnd/egl_vendor.d:$SNAP/usr/share/glvnd/egl_vendor.d
      PYTHONPATH: $SNAP/usr/lib/python3/dist-packages:$PYTHONPATH

  synfig:
    command: usr/bin/synfig
    extensions: [gnome-3-34]
    plugs: *plugs
    environment: *env

layout:
  /usr/share/synfig:
    symlink: $SNAP/usr/share/synfig
  /usr/share/pixmaps/synfigstudio:
    symlink: $SNAP/usr/share/pixmaps/synfigstudio

parts:
  synfig-deps:
    plugin: nil
    build-packages:
      - g++
      - intltool
      - gettext
      - libmagickcore-dev
      - libmagick++-dev
      - libopenexr-dev
      - libsigc++-2.0-dev
      - libxml++2.6-dev
      - libfftw3-dev
      - libmlt-dev
      - libmlt++-dev
      - libmlt-data
      - libmng-dev
      - git
    stage-packages:
      - libilmbase12
      - libmagick++-6.q16-7
      - libmagic1
      - libmlt++3
      - libmlt6
      - libmng2
      - libopenexr22
      - libsigc++-2.0-0v5
      - libxml++2.6-2v5
      - libdv-bin # mod_dv
      - ffmpeg # mod_ffmpeg
      - libflite1 # ffmpeg required
      - imagemagick # mod_imagemagick
      - libglu1-mesa
      - freeglut3
      - python3-lxml # lottie exporter

  etl:
    after: [synfig-deps]
    plugin: autotools
    source: https://github.com/synfig/synfig/releases/download/v1.4.2/ETL-1.4.2.tar.gz
    source-checksum: sha256/e54192d284df16305ddfdfcc5bdfe93e139e6db5bc283dd4bab2413ebbead7c7
    configflags: &cfgflags
      - --prefix=/usr

  synfig-core:
    after: [etl]
    plugin: autotools
    source: https://github.com/synfig/synfig/releases/download/v1.4.2/synfig-1.4.2.tar.gz
    source-checksum: sha256/e66688b908ab2f05f87cc5a364f958a1351f101ccab3b3ade33a926453002f4e
    configflags: *cfgflags
    override-build: &build |
      set -xe
      autoreconf -if
      intltoolize --force
      snapcraftctl build

  synfig-studio:
    after: [synfig-core]
    plugin: autotools
    source: https://github.com/synfig/synfig/releases/download/v1.4.2/synfigstudio-1.4.2.tar.gz
    source-checksum: sha256/4e86d4d8def6675fc92855a411795cc4062a1669cda82535d18b48a68b4d5497
    configflags: *cfgflags
    override-build: *build
    override-stage: |
      set -xe
      snapcraftctl stage

      appdata_file="usr/share/appdata/org.synfig.SynfigStudio.appdata.xml"

      # fix the icon path and point it to a file inside the snap
      sed -i -E "s|^Icon=(.*)|Icon=\${SNAP}/usr/share/icons/hicolor/scalable/apps/\1.svg|g" \
        usr/share/applications/org.synfig.SynfigStudio.desktop

  cleanup:
    after: [synfig-studio]
    plugin: nil
    build-snaps: [core18, gnome-3-34-1804]
    override-prime: |
      set -eux
      for lib in "libharfbuzz" "libglibmm" "libgiomm" "libQt" "qt5"; do
        rm -rf "usr/lib/$SNAPCRAFT_ARCH_TRIPLET/$lib"*
      done
      for cruft in "bug" "lintian" "man" "icons/Humanity"; do
        rm -rf "$SNAPCRAFT_PRIME/usr/share/$cruft"
      done
      find $SNAPCRAFT_PRIME/usr/share/doc/ -type f -not -name 'copyright' -delete
      find $SNAPCRAFT_PRIME/usr/share -type d -empty -delete
      # Remove all files from snap that are already included in the base snap or in
      # any connected content snaps
      for snap in "core18" "gnome-3-34-1804"; do  # List all content-snaps and base snaps you're using here
        cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
      done
