aboutsummaryrefslogtreecommitdiffstats
path: root/main/protobuf/APKBUILD
blob: 62fc04e9844d980dbd3af78ab7a0ab01f809a1be (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
# Contributor: Kiyoshi Aman <kiyoshi.aman@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=protobuf
_gemname=google-protobuf
pkgver=3.6.1
_tstver=1.8.0
pkgrel=1
pkgdesc="Library for extensible, efficient structure packing"
url="https://github.com/google/protobuf"
arch="all"
license="BSD-3-Clause"
depends_dev="zlib-dev"
makedepends="$depends_dev autoconf automake libtool ruby ruby-dev ruby-rake"
subpackages="ruby-$_gemname:_ruby $pkgname-dev $pkgname-vim::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/$pkgname/archive/v$pkgver.tar.gz
	googletest-$_tstver.tar.gz::https://github.com/google/googletest/archive/release-$_tstver.tar.gz
	musl-fix.patch
	trim-rakefile.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare

	cd "$builddir"
	./autogen.sh

	# symlink tests to the test directory
	rm -rf third_party/*
	ln -sf "$srcdir"/googletest-release-$_tstver \
		"$builddir"/third_party/googletest
}

build() {
	cd "$builddir"

	case "$CARCH" in mips|mipsel) export LIBS="$LIBS -latomic";; esac

	CXXFLAGS="$CXXFLAGS -fno-delete-null-pointer-checks" \
		./configure --prefix=/usr \
			--sysconfdir=/etc \
			--mandir=/usr/share/man \
			--infodir=/usr/share/info \
			--localstatedir=/var
	make

	cd "$builddir"/ruby

	# Generate proto files for built-in protocols.
	rake genproto

	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# build test-suite
	local test; for test in googletest googlemock; do
		cd "$builddir/third_party/googletest/$test"
		autoreconf -vfi
		./configure
		make
	done
}

# TODO: Run tests for ruby gem.
check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

_ruby() {
	pkgdesc="Ruby bindings to Google's data interchange format"

	local gemdir="$subpkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/ruby/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove duplicated .so libs (should be only in extensions directory).
	find "$gemdir"/gems/ -name "*.so" -delete

	# Remove unnecessary files.
	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ tests/
}

vim() {
	pkgdesc="Vim syntax for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel vim"

	install -Dm644 "$builddir"/editors/proto.vim \
		"$subpkgdir"/usr/share/vim/vimfiles/syntax/proto.vim
}

sha512sums="1bc175d24b49de1b1e41eaf39598194e583afffb924c86c8d2e569d935af21874be76b2cbd4d9655a1d38bac3d4cd811de88bc2c72d81bad79115e69e5b0d839  protobuf-3.6.1.tar.gz
1dbece324473e53a83a60601b02c92c089f5d314761351974e097b2cf4d24af4296f9eb8653b6b03b1e363d9c5f793897acae1f0c7ac40149216035c4d395d9d  googletest-1.8.0.tar.gz
875592bc5dc5efe9087ea1b340673f54c984ecd5aa3b110a2da136bdc28009af7ce1a9c57f4747ff809fc02eb6c39a0209c277177172af467a54172d9700188a  musl-fix.patch
d1d11fe76d2a1ae92f47f9eb1e0d94c67b7192a9dc4a382b6c0835f4fe4dbc2f98ca1b3c5095ad5b4e368581072330f943209c0decea02ebb47938588543fdb1  trim-rakefile.patch"