# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Evangelos Foutras <evangelos@foutrelis.com>

pkgname=gn
pkgver=0.2165.f284b6b4
_commit=f284b6b47039a2d7edfcbfc51f52664f82b5a789
pkgrel=1
pkgdesc="Meta-build system that generates build files for Ninja"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
url="https://gn.googlesource.com/gn/"
license=('BSD')
depends=('gcc-libs')
makedepends=('clang' 'ninja' 'python' 'git')
source=(git+https://gn.googlesource.com/gn#commit=$_commit)
sha256sums=('SKIP')

pkgver() {
  cd $pkgname
  echo 0.$(git rev-list --count initial-commit..).$(git rev-parse --short=8 HEAD)
}

build() {
  cd $pkgname
  ./build/gen.py
  ninja -C out
}

check() {
  cd $pkgname
  ./out/gn_unittests
}

package() {
  cd $pkgname
  install -D out/gn "$pkgdir/usr/bin/gn"
  install -Dm644 -t "$pkgdir/usr/share/doc/$pkgname" docs/*
  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE

  mkdir -p "$pkgdir/usr/share/vim/vimfiles"
  cp -r misc/vim/{autoload,ftdetect,ftplugin,syntax} \
    "$pkgdir/usr/share/vim/vimfiles/"
  install -Dm644 -t "$pkgdir/usr/share/emacs/site-lisp" misc/emacs/gn-mode.el
}

# vim:set ts=2 sw=2 et:
