# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Anatol Pomozov <anatol dot pomozov at gmail>

pkgname=meson
pkgver=1.7.0
pkgrel=1
pkgdesc="High productivity build system"
url="https://mesonbuild.com/"
arch=(any)
license=(Apache-2.0)
depends=(
  bash
  ninja
  python
  python-tqdm
)
makedepends=(
  git
  python-aiohttp
  python-build
  python-installer
  python-setuptools
  python-strictyaml
  python-wheel
)
checkdepends=(
  boost
  clang
  cmake
  cuda
  cython
  doxygen
  gcc-fortran
  gcc-objc
  git
  glib2-devel
  glibc-locales
  gmock
  gnustep-base
  gobject-introspection
  graphviz
  gtest
  gtk-doc
  gtk-sharp-2
  gtk3
  gtkmm3
  hotdoc
  itstool
  java-environment=8
  ldc
  libelf
  libpcap
  libwmf
  llvm
  mercurial
  mono
  nasm
  netcdf-fortran
  openmpi
  openssh
  protobuf
  python-gobject
  python-pytest-xdist
  qt5-base
  qt5-tools
  qt6-base
  qt6-declarative
  qt6-tools
  rust
  rust-bindgen
  sdl2
  vala
  valgrind
  vulkan-validation-layers
  wayland-protocols
  wxgtk3
)
source=(
  "git+https://github.com/mesonbuild/meson?signed#tag=$pkgver"
  arch-meson
  cross-lib32
  native-clang
  0001-Skip-broken-tests.patch
)
b2sums=('2969a68dced75e7536686e6c13acb19afaf802d8b42a32de28f25d62213b05c1c6b01c843795f71ea3a48ba010b1152db8dd6c69837617da65ebbb7f6df30bc7'
        '70f042a7603d1139f6cef33aec028da087cacabe278fd47375e1b2315befbfde1c0501ad1ecc63d04d31b232a04f08c735d61ce59d7244521f3d270e417fb5af'
        '9b16477aa77a706492e26fb3ad42e90674b8f0dfe657dd3bd9ba044f921be12ceabeb0050a50a15caee4d999e1ec33ed857bd3bed9e4444d73bb4a4f06381081'
        '7d88929d5a3b49d91c5c9969f19d9b47f3151706526b889515acaeda0141257d5115875ac84832e9ea46f83a7700d673adcc5db84b331cd798c70ae6e90eac1e'
        '076f1650bf889b79a390da82e2e0a3d3b14e3383cdf4cd81ee06d7b776e070bb3d681295926828af123c16f950ab5cca127236f3030124fa9e8c7787a2c98297')
validpgpkeys=(
  19E2D6D9B46D8DAA6288F877C24E631BABB1FE70  # Jussi Pakkanen <jpakkane@gmail.com>
)

prepare() {
  cd meson

  # Pass tests
  patch -Np1 -i ../0001-Skip-broken-tests.patch
}

build() {
  cd meson
  python -m build --wheel --no-isolation
  ./meson.py setup docs docs.build --prefix /usr -D html=false
  ./meson.py compile -C docs.build
}

check() (
  cd meson
  export LC_CTYPE=en_US.UTF-8 CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS=
  ./run_tests.py --failfast
)

package() {
  cd meson
  python -m installer --destdir="$pkgdir" dist/*.whl

  ./meson.py install -C docs.build --destdir "$pkgdir"
  install -Dm644 docs.build/reference_manual.json -t "$pkgdir/usr/share/doc/$pkgname"

  install -d "$pkgdir/usr/share/vim/vimfiles"
  cp -rt "$pkgdir/usr/share/vim/vimfiles" data/syntax-highlighting/vim/*/

  install -Dm644 data/shell-completions/bash/* -t "$pkgdir/usr/share/bash-completion/completions"
  install -Dm644 data/shell-completions/zsh/*  -t "$pkgdir/usr/share/zsh/site-functions"

  install -D ../arch-meson -t "$pkgdir/usr/bin"

  case "${CARCH}" in
    x86_64)
      install -Dm644 ../cross-lib32 "$pkgdir/usr/share/meson/cross/lib32"
    ;;
  esac
  install -Dm644 ../native-clang "$pkgdir/usr/share/meson/native/clang"
}

# vim:set sw=2 sts=-1 et:
