# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-bopomofo
pkgver=0.0.0.20250729
_commit=1859af68a927ba3cd5afb8c47feedcecf874dab2
pkgrel=1
pkgdesc="Bopomofo input for rime"
arch=('x86_64')
url="https://github.com/rime/rime-bopomofo"
license=('LGPL')
# Rime will regenerate yaml&prism bin, which makes terra-pinyin required on runtime (for translator)
# rime-cangjie is dependency for reverse lookup
depends=('rime-cangjie' 'rime-terra-pinyin')
makedepends=('git' 'librime' 'rime-prelude' 'rime-essay')
source=("git+https://github.com/rime/rime-bopomofo.git#commit=$_commit")
sha512sums=('c5c4ef45318e8b025df163f2931d0e251e8eaa1b68dcd119240652c832def98238221dc9264b0c36bd8157049e9e70a1948fdeacad125cf5474c56c0a1861698')

prepare() {
  cd $pkgname
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay rime-terra-pinyin | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname
  find . -type l -delete
  rm build/terra_pinyin.*
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
