aboutsummaryrefslogtreecommitdiffstats
path: root/main/protobuf/APKBUILD
blob: 68481674805e84eaa5ec4876db810963a08f1ccd (plain) (blame)
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Contributor: Sheila Aman <sheila@vulpine.house>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=protobuf
_gemname=google-protobuf
pkgver=3.18.1
_tstver=5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081
pkgrel=1
pkgdesc="Library for extensible, efficient structure packing"
url="https://github.com/google/protobuf"
# Test protobuf-test fails on 32 bit arches.
# See https://gitlab.alpinelinux.org/alpine/aports/-/issues/12584
arch="all"
license="BSD-3-Clause"
depends="protoc=$pkgver-r$pkgrel libprotoc=$pkgver-r$pkgrel
	libprotobuf=$pkgver-r$pkgrel libprotobuf-lite=$pkgver-r$pkgrel"
depends_dev="zlib-dev"
makedepends="$depends_dev autoconf automake libtool ruby ruby-dev ruby-rake"
subpackages="
	ruby-$_gemname:_ruby
	$pkgname-dev
	$pkgname-vim::noarch
	protoc
	libprotoc
	libprotobuf
	libprotobuf-lite
	"
# googletest 1.8 is not enought for protobuf
# https://github.com/google/googletest/issues/2267
source="$pkgname-$pkgver.tar.gz::https://github.com/google/protobuf/archive/v$pkgver.tar.gz
	googletest-$_tstver.tar.gz::https://github.com/google/googletest/archive/$_tstver.tar.gz
	trim-rakefile.patch
	ruby-fix-cflags.patch
	skip-failing-tests.patch
	"

prepare() {
	default_prepare

	./autogen.sh

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

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

	CXXFLAGS="$CXXFLAGS -fno-delete-null-pointer-checks -Wno-error" \
		./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() {
	make check
}

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

_ruby() {
	depends=""
	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
}

libprotoc() {
	depends=""
	pkgdesc="Runtime library for Protocol Buffer compiler"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libprotoc*.so.* "$subpkgdir"/usr/lib
}

protoc() {
	depends=""
	pkgdesc="Protocol buffer compiler binary and library"

	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/protoc "$subpkgdir"/usr/bin
}

libprotobuf() {
	depends=""
	pkgdesc="Runtime library for C++ users of protocol buffers"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libprotobuf.so.* "$subpkgdir"/usr/lib
}

lite() {
	depends=""
	pkgdesc="Runtime library for C++ users with 'lite runtime' setting of protocol buffers"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libprotobuf-lite.so.* "$subpkgdir"/usr/lib
}

dev() {
	depends_dev="$depends_dev protoc=$pkgver-r$pkgrel"
	default_dev
}

sha512sums="
d8ee0ae70ca4920787fca0e7d3053281754123a54280ce678d6ccaf294949959719a882c9e07300ab94e666ceb800967bcd549fa603d89b73f91e9368bd8f119  protobuf-3.18.1.tar.gz
623b077b3334958fafcbc34aa85891883277994af33be530efd903f47738a3e3562001cbf3b6da1a5e7d03803c5bd51bcc1fab81490db85d5a4f2b15e7de1495  googletest-5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081.tar.gz
c09e0cb3caed6c1070efc1944ab64f0b823473ab80c6550ca9ebaa0d2140aa060321812ba3edcb4e0339ddeb339e29333bdf27f94e7fb888dfb4abd90c1ee2f0  trim-rakefile.patch
d5f482acdb0b4f48e88b70a14cb343bea177875f2125065c760d02c89a7658e55a82c531b5a5a0cc5270ae186cd01ccd17110d2d22dbc48a2f1240b3148ff3cb  ruby-fix-cflags.patch
e7f9d25dad609418c224141ace1f863464bbc8ff6a7524e936949c7c63c632bcdbed7cc05c5ea55b24212921e838168694f2fa19cccae684d9c54f2f8222cc8b  skip-failing-tests.patch
"