# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

source "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/kde-frameworks5
_realname=breeze
pkgbase=mingw-w64-${_realname}-qt5
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}-qt5")
pkgver=6.4.5
pkgrel=1
arch=('any')
mingw_arch=('ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: breeze5'
)
pkgdesc='Artwork, styles and assets for the Breeze visual style for the Plasma Desktop (mingw-w64)'
url='https://kde.org/plasma-desktop/'
license=('spdx:GPL-3.0-or-later')
makedepends=("${MINGW_PACKAGE_PREFIX}-7zip"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-extra-cmake-modules"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-python")
depends=("${MINGW_PACKAGE_PREFIX}-hicolor-icon-theme"
         "${MINGW_PACKAGE_PREFIX}-breeze"
         "${MINGW_PACKAGE_PREFIX}-breeze-icons"
         "${MINGW_PACKAGE_PREFIX}-kconfig-qt5"
         "${MINGW_PACKAGE_PREFIX}-kconfigwidgets-qt5"
         "${MINGW_PACKAGE_PREFIX}-kguiaddons-qt5"
         "${MINGW_PACKAGE_PREFIX}-kiconthemes-qt5"
         "${MINGW_PACKAGE_PREFIX}-kirigami2-qt5"
         "${MINGW_PACKAGE_PREFIX}-kwindowsystem-qt5"
         "${MINGW_PACKAGE_PREFIX}-qt5-base"
         "${MINGW_PACKAGE_PREFIX}-qt5-declarative")
groups=("${MINGW_PACKAGE_PREFIX}-plasma")
source=("https://download.kde.org/stable/plasma/${pkgver}/${_realname}-${pkgver}.tar.xz"{,.sig})
noextract=("${_realname}-${pkgver}.tar.xz")
sha256sums=('dcb8433d399511546958f4c8c1a8fae5ed22f2a698f053968d410ee75bd6d8b4'
            'SKIP')
validpgpkeys=(
  'D07BD8662C56CB291B316EB2F5675605C74E02CF' # David Edmundson (David at KDE) <davidedmundson@kde.org>
  'E0A3EB202F8E57528E13E72FD7574483BB57B18D' # Jonathan Esk-Riddell <jr@jriddell.org>
  '0AAC775BB6437A8D9AF7A3ACFE0784117FBCE11D' # Bhushan Shah (mykolab address) <bshah@mykolab.com>
)

prepare() {
  7z x -bso0 -bsp0 "${_realname}-${pkgver}.tar.xz"
  7z x -bso0 -bsp0 -snld20 -ttar "${_realname}-${pkgver}.tar"
  python "$(dirname ${BASH_SOURCE[0]})"/../mingw-w64-PKGBUILD-common/replace-symlinks.py "${_realname}-${pkgver}"
}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  declare -a _extra_config
  if check_option "debug" "n"; then
    _extra_config+=("-DCMAKE_BUILD_TYPE=Release")
  else
    _extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
  fi

  _kde_f5_build_env
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G "Ninja" \
    "${_kde_f5_KDE_INSTALL_DIRS[@]}" \
    -DBUILD_TESTING=OFF \
    -DECM_DIR=${MINGW_PREFIX}/share/ECM \
    -DCMAKE_DISABLE_FIND_PACKAGE_KF5FrameworkIntegration=ON \
    -DWITH_DECORATIONS=OFF \
    -DBUILD_QT6=OFF \
    "${_extra_config[@]}" \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/cmake.exe --build ./
}

package() {
  cd build-${MSYSTEM}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake.exe --install ./

  # Remove file conflict with breeze kf6
  rm -r "${pkgdir}${MINGW_PREFIX}"/bin/data
}
