summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a0814af9fb2722296b545a9a97f5dfcccf86d066 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# Maintainer: Oliver Harley <oliver.r.harley+aur <at > gmail.com>

_pkgbase=psi-exact-inference
pkgname=psi-exact-inference-git
pkgver=r1246.db0227c
pkgrel=1
arch=('any')
url="https://psisolver.org/"
pkgdesc="Exact inference for probabilistic programs"
license=('Boost-1.0')
# depends=('d-compiler')
makedepends=('git' 'd-compiler')
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
optdepends=(gnuplot)
source=("$_pkgbase::git+https://github.com/eth-sri/psi.git")
sha256sums=('SKIP')

# choose your preferred compiler, 'ldmd, ldmd2, dmd, gdc', else it will until finding one
DCOMP='ldmd2'

pkgver() {
  cd "$_pkgbase"
  ( set -o pipefail
    git describe --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  )
}

prepare() {
	cd "$_pkgbase"
}

d_compiler() {
    if  [ -x "$(command -v $DCOMP)" ]; then
        DCOMP=$DCOMP
    else
        # search in no particular order
        if [ -x "$(command -v gdc)" ]; then
            DCOMP="gdc"
        elif [ -x "$(command -v ldmd2)" ]; then
            DCOMP="ldmd2"
        elif [ -x "$(command -v dmd2)" ]; then
            DCOMP="dmd2"
        elif [ -x "$(command -v ldmd)" ]; then
            DCOMP="ldmd"
        elif [ -x "$(command -v dmd)" ]; then
            DCOMP="dmd"
        fi
    fi
    echo "Using d compiler: $DCOMP"
}


build() {
	cd "$_pkgbase"
    d_compiler
    $DCOMP -O -release -inline -boundscheck=off -J. -Jlibrary *.d -ofpsi -v
}

check() {
	cd "$_pkgbase"
    d_compiler
    echo "Building tests"
    $DCOMP test/runtests.d -oftest/runtests -v
    echo "Running tests"
    ./test/runtests
}

package() {
	cd "$_pkgbase"
    install -Dm755 psi $pkgdir/usr/bin/psi
    install -D LICENSE $pkgdir/usr/share/sicenses/psi-git/LICENSE
}