# Contributor: Lars Boettcher <lars@newyew.de>
# Maintainer: Aaron Ali <t0nedef@causal.ca>

pkgname=klayout
pkgver=0.27.3
pkgrel=1
pkgdesc="High Performance Layout Viewer And Editor. Support of GDS and OASIS files."
arch=('x86_64')
url="https://www.klayout.de"
license=('GPL')
depends=('qt5-base' 'qt5-tools' 'qt5-multimedia' 'qt5-xmlpatterns' 'qt5-svg' 'ruby2.7' 'python')
source=(http://www.klayout.org/downloads/source/klayout-$pkgver.tar.bz2
        klayoutEditor.desktop klayoutViewer.desktop)
sha512sums=('56294829eddf0b3984acb8b37d934a11561bedd5f48ad4236cd4463bf67b7259174b71371d29f80621bbbb064790587a5e37b0dc46048b48bb24e089c3d00717'
            'bc6c7621e5cda754509a86664fb3e7ecd15f577dec712f4b0c52c9a7455ba692043a67145f5bf143d8fdc502b84e4212303906d62107537eefb4bebe57b2ffe1'
            '37a3bbb06ab155c1c22e3990cf160383570e8ea945dbf4964bc94b6fd4e6321627d31071a29d3dbeafc9e2fc406b6905761e299bfccdfe0a35663f2021624f4f')

build() {
  cd klayout-$pkgver
  ./build.sh -ruby /usr/bin/ruby-2.7
}

package() {
  install -D -m 644 klayoutEditor.desktop "$pkgdir"/usr/share/applications/klayoutEditor.desktop
  install -D -m 644 klayoutViewer.desktop "$pkgdir"/usr/share/applications/klayoutViewer.desktop
  cd klayout-$pkgver
  install -D -m 644 etc/logo.png "$pkgdir"/usr/share/icons/hicolor/32x32/apps/klayout.png
  install -D -m 755 build-release/klayout "$pkgdir"/usr/bin/klayout
  cd bin-release
  for lib in `find . -type f | grep so`; do
    install -D -m 755 $lib "$pkgdir"/usr/lib/$lib
  done
  for lib in `find . -type l | grep so`; do
    cp -a $lib "$pkgdir"/usr/lib/$lib
  done
}
