# Maintainer(AUR): Graham Edgecombe <gpe@grahamedgecombe.com>
# parabola changes and rationale:
# - Add armv7h support
# - Modified to use a fixed git revision
pkgname=nextpnr-git
pkgver=r3206.f0e30abf
_commit=f0e30abf624ebf9984170b4b81e06e15e31ee4de
pkgrel=1
pkgdesc='Portable FPGA place and route tool'
arch=('armv7h' 'i686' 'x86_64')
url='https://github.com/YosysHQ/nextpnr'
license=('custom:ISC')
depends=('boost-libs' 'python' 'qt5-base')
makedepends=('boost' 'cmake' 'eigen' 'git' 'icestorm' 'prjtrellis'
             'prjtrellis-db')
provides=('nextpnr')
conflicts=('nextpnr')
source=("nextpnr::git+https://github.com/YosysHQ/nextpnr.git#commit=${_commit}")
sha256sums=('SKIP')

pkgver() {
  cd "$srcdir/nextpnr"
  printf 'r%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
  cd "$srcdir/nextpnr"

  mkdir -p build
  cd build

  cmake \
    -DARCH=generic\;ice40\;ecp5 \
    -DICEBOX_ROOT=/usr/share/icebox \
    -DTRELLIS_INSTALL_PREFIX=/usr \
    -DBUILD_TESTS=ON \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DUSE_OPENMP=ON \
    -DBUILD_GUI=ON \
    ..
  make
}

check() {
  cd "$srcdir/nextpnr/build"
  make test
}

package() {
  cd "$srcdir/nextpnr/build"
  make DESTDIR="$pkgdir" install
  install -Dm644 ../COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
}
