name: gpsbabel # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: "Convert, manipulate and transfer GPS data"
description: |
  Convert, manipulate and transfer data from GPS programs or GPS
  recievers.  Open source and supported on macOS, Windows and Linux.

license: GPL-2.0
title: GPSBabel
source-code: https://github.com/GPSBabel/gpsbabel.git
website: https://www.gpsbabel.org

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  gpsbabel:
    plugs:
      - home
      - raw-usb
      - removable-media
      - serial-port
    command: usr/bin/gpsbabel

# remap the ubuntu qt6 install directories to the snap.
layout:
  /usr/share/qt6:
    symlink: $SNAP/usr/share/qt6
  /usr/lib/qt6:
    symlink: $SNAP/usr/lib/qt6
  /usr/lib/x86_64-linux-gnu/qt6:
    symlink: $SNAP/usr/lib/x86_64-linux-gnu/qt6

adopt-info: gpsbabel
parts:
  gpsbabel:
    # See 'snapcraft plugins'
    plugin: cmake
    cmake-parameters:
      - -DCMAKE_BUILD_TYPE=Release
      - -DGPSBABEL_WITH_ZLIB=pkgconfig
      - -DGPSBABEL_WITH_SHAPELIB=pkgconfig
    cmake-generator: Ninja
    source: .
    override-pull: |
      craftctl default
      # add install command to CMakeLists.txt
      echo "install(TARGETS gpsbabel CONFIGURATIONS Release RUNTIME DESTINATION /usr/bin)" >> CMakeLists.txt
      # no gui
      sed -i -e's/add_subdirectory(gui)/#add_subdirectory(gui)/' CMakeLists.txt
      # jam repo sha into GITHUB_SHA
      sed -i -e"/GB.SHA/i set(ENV{GITHUB_SHA} \"$(git log -1 --format=%h)\")" gbversion.cmake
      # set snap version
      # ensure version has at most 32 characters
      craftctl set version=$(git log -1 --format='LinuxInstaller-%ad-%h' --date=format:%Y%m%d)

    build-packages:
      - git
      - vim
      - g++
      - ninja-build
      - zlib1g-dev
      - libshp-dev
      - libusb-1.0-0-dev
      - pkg-config
      - libudev-dev
      - qt6-base-dev
      - libqt6core5compat6-dev
    stage-packages:
      - zlib1g
      - libshp2
      - libusb-1.0-0
      - libqt6core6
      - libqt6core5compat6
