name: lazfuck
title: LazFuck
version: '1.2.0'
summary: A simple BrainFuck IDE written in Lazarus/FPC.
description: |
  LazFuck is GUI application for writing, executing, compiling and debugging programs written in famous BrainFuck esoteric programming language. 
  
  Features:
  * Graphical code editor with color syntax highlighting
  * Optimizing compiler and interpreter
  * Cross-compilation to Delphi, Free Pascal, Python, Java, C, C#, PHP, and Javascript
  * Interpreter with debugger
confinement: strict
base: core20
grade: stable
icon: "Images/64x64/LazFuck.png"
license: NLPL

parts:
  lazfuck:
    plugin: nil
    source: .
    source-type: local
    build-packages:
    - fpc
    - lazarus
    - lcl
    - lcl-utils
    override-build: |
      snapcraftctl build
      lazbuild --build-mode=Release LazFuck.lpi
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/bin
      install -s -m 755 LazFuck $SNAPCRAFT_PART_INSTALL/usr/bin/LazFuck
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/LazFuck/Languages
      install -m 644 Languages/LazFuck.pot $SNAPCRAFT_PART_INSTALL/usr/share/LazFuck/Languages
      install -m 644 Languages/LazFuck.cs.po $SNAPCRAFT_PART_INSTALL/usr/share/LazFuck/Languages
      install -m 644 Languages/UFormAbout.pot $SNAPCRAFT_PART_INSTALL/usr/share/LazFuck/Languages
      install -m 644 Languages/UFormAbout.cs.po $SNAPCRAFT_PART_INSTALL/usr/share/LazFuck/Languages
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/applications
      install -m 755 Install/snap/local/LazFuck.desktop $SNAPCRAFT_PART_INSTALL/usr/share/applications
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps
      install -m 644 Images/64x64/LazFuck.png $SNAPCRAFT_PART_INSTALL/usr/share/pixmaps
      install -d -m 755 $SNAPCRAFT_PART_INSTALL/usr/share/mime/packages
      install -m 644 Install/snap/local/LazFuck.xml $SNAPCRAFT_PART_INSTALL/usr/share/mime/packages
      cp -r Examples $SNAPCRAFT_PART_INSTALL/usr/share/LazFuck
    after:
    - desktop-gtk2
    stage:
    - etc
    - usr
    - usr/bin
    - usr/share/LazFuck
    - usr/share/applications/LazFuck.desktop
    - usr/share/pixmaps
    - usr/share/mime
    stage-packages:
    - libatk1.0-0
    - libcairo2
    - libdatrie1
    - libfontconfig1
    - libfreetype6
    - libfribidi0
    - libgdk-pixbuf2.0-0
    - libgraphite2-3
    - libgtk2.0-0
    - libharfbuzz0b
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpixman-1-0
    - libpng16-16
    - libthai0
    - libx11-6
    - libxau6
    - libxcb-render0
    - libxcb-shm0
    - libxcb1
    - libxcomposite1
    - libxcursor1
    - libxdamage1
    - libxdmcp6
    - libxext6
    - libxfixes3
    - libxi6
    - libxinerama1
    - libxrandr2
    - libxrender1

  desktop-gtk2:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: gtk
    plugin: make
    make-parameters: ["FLAVOR=gtk2"]
    build-packages:
    - build-essential
    - libgtk2.0-dev
    stage-packages:
    - libxkbcommon0  # XKB_CONFIG_ROOT
    - ttf-ubuntu-font-family
    - dmz-cursor-theme
    - light-themes
    - adwaita-icon-theme
    - gnome-themes-standard
    - shared-mime-info
    - libgtk2.0-0
    - libgdk-pixbuf2.0-0
    - libglib2.0-bin
    - libgtk2.0-bin
    - unity-gtk2-module
    - locales-all
    - libappindicator1
    - xdg-user-dirs
    - ibus-gtk
    - libibus-1.0-5

# Additional plugs to pick up the GTK theme and icons from the system
plugs: 
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes
  gtk-2-engines:
    interface: content
    target: $SNAP/lib/gtk-2.0
    default-provider: gtk2-common-themes:gtk-2-engines
  gtk-2-themes:
    interface: content
    target: $SNAP/usr/share/themes
    default-provider: gtk2-common-themes:gtk-2-themes

environment:
  XDG_DATA_DIRS: $SNAP/usr/share:$XDG_DATA_DIRS
  GTK_PATH: $SNAP/lib/gtk-2.0

apps:
  lazfuck:
    command: usr/bin/LazFuck
    command-chain:
    - bin/desktop-launch
    desktop: usr/share/applications/LazFuck.desktop
    plugs:
    - desktop
    - x11
    - home

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