#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=meson
pkgver=0.64.1
pkgrel=01
pkgdesc='High productivity build system'
url='https://mesonbuild.com/'
arch=('any')
depends=('python-setuptools' 'ninja')
checkdepends=('gcc-objc' 'vala' 'rust' 'gcc-fortran' 'mono' 'boost' 'qt5-base' 'git' 'cython'
              'gtkmm3' 'gtest' 'gmock' 'protobuf' 'wxgtk3' 'python-gobject' 'gobject-introspection'
              'itstool' 'gtk3' 'java-environment=8' 'gtk-doc' 'llvm' 'clang' 'sdl2' 'graphviz'
              'doxygen' 'vulkan-validation-layers' 'openssh' 'mercurial' 'gtk-sharp-2' 'qt5-tools'
              'libwmf' 'valgrind' 'cmake' 'netcdf-fortran' 'openmpi' 'nasm' 'gnustep-base' 'libelf'
              'python-pytest-xdist' 'ldc' 'rust-bindgen' 'cuda' 'hotdoc')
source=(https://github.com/mesonbuild/meson/releases/download/${pkgver}/meson-${pkgver}.tar.gz{,.asc}
        0001-Skip-broken-tests.patch
        arch-meson
        jobo-meson)

prepare() {
  cd ${pkgname}-${pkgver}

  ## Arch: Our containers do not allow sanitizers to run
  patch -Np1 -i ../0001-Skip-broken-tests.patch

}

build() {
  cd ${pkgname}-${pkgver}
  python setup.py build
}

#check() (
#  cd ${pkgname}-${pkgver}
#  export LC_CTYPE=en_US.UTF-8 CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS=
#   ./run_tests.py --failfast
#)
#
#
#
#1/2 testsetups:buggy / Test buggy FAIL              0.09s   exit status 1
#>>> TEST_ENV=1 MALLOC_PERTURB_=165 /usr/bin/valgrind --error-exitcode=1 --leak-check=full /src/pkg/jobextra/meson/src/meson-0.63.3/tmpvv_zk5ul/buggy
#
#2/2 testsetups / test-env         FAIL              0.08s   exit status 1
#>>> MALLOC_PERTURB_=113 TEST_ENV=1 /usr/bin/valgrind --error-exitcode=1 --leak-check=full '/src/pkg/jobextra/meson/src/meson-0.63.3/test cases/unit/2 testsetups/envcheck.py'
#========================================== short test summary info =========================================== 
#FAILED run_unittests.py::AllPlatformTests::test_testsetups - AssertionError: 'TEST_ENV is set' not found in... 
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
#!!!!!!!!!!!!!!!!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!! 
#====================== 1 failed, 133 passed, 21 skipped, 9 warnings in 68.42s (0:01:08) ======================
#

package() {
  cd ${pkgname}-${pkgver}
  python setup.py install --root="${pkgdir}" --optimize=1 --skip-build

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

  install -Dt "${pkgdir}/usr/share/bash-completion/completions" -m644 data/shell-completions/bash/*
#  install -Dt "${pkgdir}/usr/share/emacs/site-lisp" -m644 data/syntax-highlighting/emacs/*
  install -Dt "${pkgdir}/usr/share/zsh/site-functions" -m644 data/shell-completions/zsh/*

  # Arch packaging helper
  install -D ../arch-meson -t "${pkgdir}/usr/bin"

  # joborun-pkg packaging helper
  install -D ../jobo-meson -t "${pkgdir}/usr/bin"

}

#---- license gpg-key sha256sums ----

license=('Apache')

validpgpkeys=('19E2D6D9B46D8DAA6288F877C24E631BABB1FE70') # Jussi Pakkanen <jpakkane@gmail.com>

sha256sums=(3a8e030c2334f782085f81627062cc6d4a6771edf31e055ffe374f9e6b089ab9  # meson-0.64.1.tar.gz
	cf4fad17a8f04afa394ed76d1a0bd98e80c653813092ed25da3e6031fa04bcfd  # meson-0.64.1.tar.gz.asc
	6aefe15d08a25826ba2578d18e02a59520065e52e8475c1919f258365d92731d  # 0001-Skip-broken-tests.patch
	ac3387ed5759cc512b1f2a4e5b3dd940274b02f943a7e5d644792ee714e6b95e  # arch-meson
	b2aeae2787cf8f3ffb8778ee7f1a434895b1512bc0bdb33528c4cb2aeb067904) # jobo-meson


