summaryrefslogtreecommitdiff
path: root/user/protobuf/APKBUILD
blob: c1c3b49af265dd49c4dcc6c548201684e68f3b30 (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
# Contributor: Sheila Aman <sheila@vulpine.house>
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Dan Theisen <djt@hxx.in>
pkgname=protobuf
_gemname=google-protobuf
pkgver=3.20.1
_tstver=8d51dc50eb7e7698427fed81b85edad0e032112e
pkgrel=0
pkgdesc="Library for extensible, efficient structure packing"
url="https://github.com/google/protobuf"
arch="all"
options="!check"  # Broken everywhere.
license="BSD-3-Clause"
depends_dev="zlib-dev"
makedepends="$depends_dev autoconf automake libtool ruby ruby-dev ruby-rake
	ruby-rake-compiler ruby-io-console ruby-irb ruby-power_assert 
	ruby-rake-compiler ruby-test-unit ruby-reline ruby-rubygems-tasks
 	python3 python3-dev cmake"
checkdepends="ruby-json ruby-test-unit"
subpackages="ruby-$_gemname:_ruby py3-$pkgname:_python $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/$_tstver.tar.gz"

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

build() {
	# Build Protobuf
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
		-DCMAKE_C_FLAGS="$CFLAGS" \
		${CMAKE_CROSSOPTS} cmake
	make -j1

	# Build for Ruby
	cd "$builddir"/ruby
	# Generate proto files for built-in protocols.
	export LD_LIBRARY_PATH=${builddir}
	export CPPFLAGS="-L${builddir}"
	export PATH="${builddir}:$PATH"
	rake
	gem build $_gemname.gemspec
	gem install --local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname

	# Build for Python 3
	cd "$builddir"/python
	python3 setup.py build --cpp_implementation

	# Build test-suite
	cd "$builddir"/third_party/googletest/
	cmake .
	make
}

check() {
	make check
	cd "$builddir"/ruby
	rake test
	cd "$builddir"/python
	python3 setup.py test --cpp_implementation
}

package() {
	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/
}

_python() {
	pkgdesc="Python bindings to Google's data interchange format"

	cd "$builddir"/python
	python3 setup.py install --prefix=/usr --root="$subpkgdir" \
		--cpp_implementation
}

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="fde3eb9f13946887ddfd87df428c5615ad09aaf191e4478b24e98e5e13231feeff4e70b4ca6a2ff7d9b9b2e2c60bc1d5479526edeafa78f9a8ed3bef2e0bacb0  protobuf-3.20.1.tar.gz
f7f804abf68af5e4e6cd767151773394fb8297d7d7fc878532ebb22b8c41d13554f68fa38a27470d458b590259a939e93cee7e5f5f6de8f1726c7ce85a606099  googletest-8d51dc50eb7e7698427fed81b85edad0e032112e.tar.gz"