# SPDX-FileCopyrightText: 2024, 2025 Scarlett Moore <sgmoore@kde.org>
#
# SPDX-License-Identifier: CC0-1.0
---
name: marble
confinement: strict
grade: stable
base: core24
adopt-info: marble
apps:
  marble:
    extensions:
      - kde-neon-6
    common-id: org.kde.marble.desktop
    desktop: usr/share/applications/org.kde.marble.desktop
    command: usr/bin/marble
    plugs:
      - audio-record
      - browser-support
    environment:
      QT_PLUGIN_PATH: "$QT_PLUGIN_PATH:$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET/marble"
      QTWEBENGINE_DISABLE_SANDBOX: 1
layout:
  /usr/share/marble:
    symlink: $SNAP/usr/share/marble
  /usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/marble:
    symlink: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/marble
slots:
  session-dbus-interface:
    interface: dbus
    name: org.kde.marble
    bus: session
package-repositories:
  - type: apt
    components:
      - main
    suites:
      - noble
    key-id: 444DABCF3667D0283F894EDDE6D4736255751E5D
    url: http://origin.archive.neon.kde.org/user
    key-server: keyserver.ubuntu.com
parts:
  marble:
    parse-info:
      - usr/share/metainfo/org.kde.marble.appdata.xml
    plugin: cmake
    source: .
    source-type: local
    build-packages:
      - libpulse0
    stage-packages:
      - libpulse0
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DQT_MAJOR_VERSION=6
      - -DBUILD_WITH_QT6=ON
      - -DBUILD_TESTING=OFF
      - -DCMAKE_INSTALL_SYSCONFDIR=/etc
      - -DCMAKE_INSTALL_LOCALSTATEDIR=/var
      - -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
      - -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF
      - -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
      - -DCMAKE_INSTALL_RUNSTATEDIR=/run
      - -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON
      - -DCMAKE_VERBOSE_MAKEFILE=ON
      - -DCMAKE_INSTALL_LIBDIR=lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
      - --log-level=STATUS
      - -DCMAKE_LIBRARY_PATH=lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR
    build-environment: &buildenvironment
      - PATH: /snap/kde-qt6-core24-sdk/current/usr/bin${PATH:+:$PATH}
      - PKG_CONFIG_PATH: /snap/kde-qt6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
      - XDG_DATA_DIRS: $CRAFT_STAGE/usr/share:/snap/kde-qt6-core24-sdk/current/usr/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
      - XDG_CONFIG_HOME: $CRAFT_STAGE/etc/xdg:/snap/kde-qt6-core24-sdk/current/etc/xdg:/etc/xdg${XDG_CONFIG_HOME:+:$XDG_CONFIG_HOME}
      - LD_LIBRARY_PATH: "/snap/kde-qt6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:/snap/kde-qt6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libproxy:/snap/kde-qt6-core24-sdk/current/usr/lib:/snap/kf6-core24-sdk/current/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}:/snap/kf6-core24-sdk/current/usr/lib:$CRAFT_STAGE/usr/lib:$CRAFT_STAGE/lib/:$CRAFT_STAGE/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
      - PYTHONPATH: ${CRAFT_STAGE}/lib/python3.12/site-packages:${CRAFT_STAGE}/usr/lib/python3/dist-packages
    prime:
      - -usr/lib/*/cmake/*
      - -usr/include/*
      - -usr/share/ECM/*
      - -usr/share/man/*
      - -usr/bin/X11
      - -usr/lib/gcc/$CRAFT_ARCH_TRIPLET_BUILD_FOR/6.0.0
      - -usr/lib/aspell/*
      - -usr/share/lintian
  cleanup:
    after:
      - marble
    plugin: nil
    build-snaps:
      - core24
      - kf6-core24
    override-prime: |
      set -eux
      for snap in "core24" "kf6-core24"; do
          cd "/snap/$snap/current" && find . -type f,l -exec rm -rf "${CRAFT_PRIME}/{}" \;
      done

