summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 24521e4b2b54b2da3115ea59c6e3a88d9e73f29b (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
# Maintainer:
# Contributor: xiretza <xiretza+aur@xiretza.xyz>

_pkgbase="prjxray"
pkgbase="$_pkgbase-git"
pkgname=("$_pkgbase-tools-git" "python-$_pkgbase-git")
pkgver=r3947.08353c97
pkgrel=1
pkgdesc="Documenting the Xilinx 7-series bit-stream format"
url="https://github.com/SymbiFlow/prjxray"
license=('ISC')
arch=('x86_64')

_pythondepends=(
  'python'
  'python-fasm'
  'python-intervaltree'
  'python-numpy'
  'python-pyjson5'
  'python-simplejson'
  'python-yaml'
)

depends=("${_pythondepends[@]}")
makedepends=(
  'cmake'
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-pytest')
optdepends=(
  'prjxray-db: The pre-built database'
)

_pkgsrc="$_pkgbase"
source=(
  "$_pkgsrc"::"git+$url.git"
  "git+https://github.com/arsenm/sanitizers-cmake"
  "git+https://github.com/google/googletest"
  "git+https://github.com/gflags/gflags"
  "git+https://github.com/google/cctz"
  "git+https://github.com/abseil/abseil-cpp"
  "git+https://github.com/jbeder/yaml-cpp"
)
sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
)

pkgver() {
  cd "$_pkgsrc"
  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

prepare() {
  cd "$_pkgsrc"

  # include fasm2frames in python package
  mv utils/fasm2frames.py prjxray/
  sed -E 's/(fasm2frames=)utils/\1prjxray/' -i setup.py

  local _mods=(sanitizers-cmake googletest gflags cctz abseil-cpp yaml-cpp)

  git submodule init
  for mod in "${_mods[@]}"; do
    git config "submodule.third_party/$mod.url" "$srcdir/$mod"
  done

  cd third_party
  git -c protocol.file.allow=always submodule update "${_mods[@]}"
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DCMAKE_POLICY_VERSION_MINIMUM=3.5
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build

  cd "$_pkgsrc"
  python -m build --wheel --no-isolation --skip-dependency-check
}

check() {
  cd "$_pkgsrc"
  env PYTHONPATH=. pytest tests/
}

package_prjxray-tools-git() {
  depends=('gcc-libs')
  provides=(
    "${pkgname%-git}"
    "prjxray"
  )
  conflicts=(
    "${pkgname%-git}"
    "prjxray"
  )

  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 "$_pkgsrc/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
}

package_python-prjxray-git() {
  arch=(any)
  depends=("${_pythondepends[@]}")
  provides=("${pkgname%-git}")
  conflicts=("${pkgname%-git}")

  cd "$_pkgsrc"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}