summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0cd8efd960be770bc97295dd973d4749134d805b (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
# Maintainer: Chocobo1 <chocobo1 AT archlinux DOT net>

pkgbase=protobuf-git
pkgname=('protobuf-git' 'python-protobuf-git')
pkgver=27.1.r305.g54d8f0397
pkgrel=1
pkgdesc="Google's data interchange format"
arch=('i686' 'x86_64')
url="https://developers.google.com/protocol-buffers/"
license=('BSD-3-Clause')
makedepends=('git' 'cmake' 'gtest' 'python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest' 'python-numpy')
source=("git+https://github.com/protocolbuffers/protobuf.git")
sha256sums=('SKIP')


prepare() {
  cd "protobuf"

  git submodule update --init --recursive
}

pkgver() {
  cd "protobuf"

  _tag=$(git tag -l --sort -v:refname | sed '/rc[0-9]*/d' | head -n1)
  _rev=$(git rev-list --count $_tag..HEAD)
  _hash=$(git rev-parse --short HEAD)
  printf "%s.r%s.g%s" "$_tag" "$_rev" "$_hash" | sed 's/^v//'
}

build() {
  cd "protobuf"

  CFLAGS="$CFLAGS -ffat-lto-objects" \
  CXXFLAGS="$CXXFLAGS -ffat-lto-objects" \
  cmake \
    -B "_build" \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="/usr" \
    -DBUILD_SHARED_LIBS=ON \
    -Dprotobuf_ABSL_PROVIDER=package \
    -Dprotobuf_BUILD_TESTS=OFF \
    -Dprotobuf_USE_EXTERNAL_GTEST=ON \
    ./
  make -C "_build"

  cd "python"
  ln -sf "dist/setup.py"
  python \
    -m build \
    --wheel \
    --no-isolation \
    --config-setting="--cpp_implementation"
}

check() {
  cd "protobuf"

  #make -C "_build" check

  #cd "python"
  #python "setup.py" test
}

package_protobuf-git() {
  depends=('gcc-libs' 'abseil-cpp' 'zlib')
  provides=("protobuf=$pkgver" 'libprotoc.so' 'libprotobuf.so' 'libprotobuf-lite.so')
  conflicts=('protobuf')

  cd "protobuf"

  make -C "_build" DESTDIR="$pkgdir" install
  install -Dm644 "LICENSE" -t "$pkgdir/usr/share/licenses/protobuf"
  install -Dm644 "editors/protobuf-mode.el" -t "$pkgdir/usr/share/emacs/site-lisp"
  install -Dm644 "editors/proto.vim" -t "$pkgdir/usr/share/vim/vimfiles/syntax"
}

package_python-protobuf-git() {
  pkgdesc="Python 3 bindings for Google Protocol Buffers"
  depends=("protobuf-git=$pkgver" 'python')
  provides=("python-protobuf=$pkgver")
  conflicts=('python-protobuf')

  cd "protobuf"

  install -Dm644 "LICENSE" -t "$pkgdir/usr/share/licenses/python-protobuf"

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