summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9d97789edc9a0b1de6b6f734d68995dbf1c72b1e (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Maintainer: Stefan Biereigel <stefan@biereigel.de>

## options
: ${_build_python:=false}

_pkgtype="-git"

# basic info
_pkgname="csxcad"
pkgbase="$_pkgname${_pkgtype:-}"
pkgver=0.6.3.r21.g303390a
pkgrel=1
pkgdesc="A C++ library to describe geometrical objects and their properties"
url="https://github.com/thliebig/CSXCAD"
license=('LGPL-3.0-or-later')
arch=('i686' 'x86_64')

_depends_csxcad=(
  'fmt'
  'fparser' # AUR
  'hdf5'
  'tinyxml'
  'verdict'
  'vtk'
)
_depends_python=(
  'python'
  'python-matplotlib'
  'python-numpy'
)
_makedeps_python=(
  'cython'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)

depends=(
  ${_depends_csxcad[@]}
)
makedepends=(
  'cgal'
  'cmake'
  'fast_float'
  'git'
  'ninja'
  'nlohmann-json'
)

if [[ "${_build_python::1}" == "t" ]]; then
  depends+=(${_depends_python[@]})
  makedepends+=(${_makedeps_python[@]})
fi

_pkgsrc="$_pkgname"
source=("$_pkgsrc"::"git+https://github.com/thliebig/CSXCAD")
sha256sums=('SKIP')

pkgver() {
  cd "$_pkgsrc"
  git describe --long --tags --abbrev=7 \
    | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
}

_build_csxcad() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -G Ninja
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX=/usr
    -DENABLE_RPATH=OFF
    -DBUILD_TESTING=OFF
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build
  DESTDIR="$srcdir/fakeinstall" cmake --install build
}

_build_python-csxcad() (
  [ "${_build_python::1}" != "t" ] && return

  cd "$_pkgsrc/python"

  export CFLAGS CXXFLAGS LDFLAGS
  CFLAGS="${CFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"
  CXXFLAGS="${CXXFLAGS/_FORTIFY_SOURCE=3/_FORTIFY_SOURCE=2}"

  CFLAGS+=" -I'$srcdir/fakeinstall/usr/include'"
  LDFLAGS+=" -L'$srcdir/fakeinstall/usr/lib'"

  python -m build --no-isolation --wheel --skip-dependency-check
)

build() {
  _build_csxcad
  _build_python-csxcad
}

_package_csxcad() {
  provides=('csxcad')
  conflicts=('csxcad')

  depends=(
    ${_depends_csxcad[@]}
  )

  mv "$srcdir"/fakeinstall/* "$pkgdir/"
  chmod -R u+rwX,go+rX,go-w "$pkgdir/"
}

_package_python-csxcad() {
  pkgdesc+=" - python module"

  depends=(
    ${_depends_python_csxcad[@]}
    'csxcad'
  )

  provides=('python-csxcad')
  conflicts=('python-csxcad')

  cd "$_pkgsrc/python"
  python -m installer --destdir="$pkgdir" dist/*.whl
}

pkgname=("$_pkgname${_pkgtype:-}")
[[ "${_build_python::1}" == "t" ]] && pkgname+=("python-$_pkgname${_pkgtype:-}")


for _p in "${pkgname[@]}"; do
  _q="${_p%${_pkgtype:-}}"
  eval "package_$_p() {
    $(declare -f _package_$_q)
    _package_$_q
  }"
done