# Maintainer: Sammay Sarkar <(my-name-without-vowels)@gmail.com>
# Co-Maintainer: Ahmad Hasan Mubashshir <ahmubashshir@gmail.com>
# from: github
# what: OpenBangla/OpenBangla-keyboard

pkgname="openbangla-keyboard"
pkgver="2.0.0"
pkgrel=10
pkgdesc="An OpenSource, Unicode compliant Bengali Input Method"
arch=('x86_64')
url="http://openbangla.github.io"
license=('GPL-3.0-or-later')
depends=('ibus' 'qt5-base')
makedepends=('cmake' 'rust' 'git')
optdepends=('ttf-indic-otf: fonts for Bangla and other Indic scripts'
  'ttf-freebanglafont: miscellaneous fonts for Bangla script')
install="$pkgname.install"
source=(
  "$pkgname::git+https://github.com/OpenBangla/OpenBangla-keyboard.git#tag=$pkgver"
  "corrosion-rs.patch" # https://github.com/OpenBangla/OpenBangla-Keyboard/pull/465.patch
  "riti::git+https://github.com/OpenBangla/riti"
  "corrosion-rs::git+https://github.com/corrosion-rs/corrosion"
)
sha256sums=('7d590d3336cdfe40ea72772ceb2f51feb69ca6d97762e065e9c16070a26067a0'
  '2825599fb6af0b99cdc58f996769a6556dfb0af1aa613bee7f94d325e206cfa9'
  'SKIP'
  'SKIP')

pkgver() {
  cd ${pkgname}
  git describe --tags | sed 's/-/+/g'
}

prepare() {
  cd "$pkgname"
  git submodule init
  git apply -3 < ../corrosion-rs.patch
  git config submodule."src/engine/riti".url "$srcdir/riti"
  git config submodule."corrosion-rs".url "$srcdir/corrosion-rs"
  git -c protocol.file.allow=always submodule update
}

build() {
  if [[ -d build ]]; then rm -rf build; fi
  cmake -B build -S "$pkgname" \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_SKIP_INSTALL_RPATH=YES \
    -DCMAKE_SKIP_RPATH=YES \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5
  #	-DBIN_DIR:PATH=/usr/bin \
  #	-DLIBEXECDIR:PATH="/usr/lib/$pkgname"
  make -C build
}
package() {
  make -C build DESTDIR="$pkgdir" install
}
