net-libs/grpc: version bump to 1.13.0
[gentoo.git] / net-libs / grpc / grpc-1.13.0.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_{4,5,6} )
7 DISTUTILS_OPTIONAL=1
8
9 inherit distutils-r1 flag-o-matic toolchain-funcs
10
11 # should match pinned git submodule version of third_party/protobuf
12 # look it up here https://github.com/grpc/grpc/tree/v"${PV}"/third_party
13 # also should ~depend on same version of dev-libs/protobuf below
14 PROTOBUF_VERSION="3.5.2"
15
16 DESCRIPTION="Modern open source high performance RPC framework"
17 HOMEPAGE="http://www.grpc.io"
18 SRC_URI="
19         https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
20         tools? ( https://github.com/google/protobuf/archive/v${PROTOBUF_VERSION}.tar.gz -> protobuf-${PROTOBUF_VERSION}.tar.gz )
21 "
22
23 LICENSE="Apache-2.0"
24 SLOT="0"
25 KEYWORDS="~amd64 ~x86"
26 IUSE="examples doc python systemtap static-libs tools"
27
28 REQUIRED_USE="
29         python? ( ${PYTHON_REQUIRED_USE} )
30         tools? ( python )
31 "
32
33 RDEPEND="
34         >=dev-libs/openssl-1.0.2:0=[-bindist]
35         ~dev-libs/protobuf-${PROTOBUF_VERSION}:=
36         dev-util/google-perftools
37         net-dns/c-ares:=
38         sys-libs/zlib:=
39         python? ( ${PYTHON_DEPS}
40                 dev-python/coverage[${PYTHON_USEDEP}]
41                 dev-python/cython[${PYTHON_USEDEP}]
42                 >=dev-python/protobuf-python-3.5.1:=[${PYTHON_USEDEP}]
43                 dev-python/six[${PYTHON_USEDEP}]
44                 dev-python/wheel[${PYTHON_USEDEP}]
45                 virtual/python-enum34[${PYTHON_USEDEP}]
46                 virtual/python-futures[${PYTHON_USEDEP}]
47         )
48         systemtap? ( dev-util/systemtap )
49 "
50
51 DEPEND="${RDEPEND}
52         virtual/pkgconfig
53         doc? (
54                 python? (
55                         dev-python/sphinx[${PYTHON_USEDEP}]
56                         dev-python/sphinx_rtd_theme[${PYTHON_USEDEP}]
57                 )
58         )
59 "
60
61 PATCHES=(
62         "${FILESDIR}/0001-grpc-1.13.0-fix-host-ar-handling.patch"
63         "${FILESDIR}/0002-grpc-1.3.0-Fix-unsecure-.pc-files.patch"
64         "${FILESDIR}/0003-grpc-1.3.0-Don-t-run-ldconfig.patch"
65         "${FILESDIR}/0004-grpc-1.11.0-fix-cpp-so-version.patch"
66         "${FILESDIR}/0005-grpc-1.11.0-pkgconfig-libdir.patch"
67         "${FILESDIR}/0009-grpc-1.12.1-gcc8-fixes.patch"
68 )
69
70 src_prepare() {
71         sed -i 's@$(prefix)/lib@$(prefix)/$(INSTALL_LIBDIR)@g' Makefile || die "fix libdir"
72         default
73         use python && distutils-r1_src_prepare
74 }
75
76 python_prepare() {
77         if use tools; then
78                 rm -r third_party/protobuf || die "removing empty protobuf dir failed"
79                 ln -s "${S}"/../protobuf-"${PROTOBUF_VERSION}" third_party/protobuf || die
80                 pushd tools/distrib/python/grpcio_tools >/dev/null || die
81                 # absolute symlinks will fail
82                 # ./src -> ${S}/src
83                 ln -s ../../../../src ./ || die
84                 # ./third_party -> ${S}/third_party
85                 ln -s ../../../../third_party ./ || die
86                 # ./grpc_root -> ${S}
87                 ln -s ../../../../ ./grpc_root || die
88                 popd >/dev/null || die
89         fi
90 }
91
92 src_compile() {
93         tc-export CC CXX PKG_CONFIG
94
95         emake \
96                 V=1 \
97                 prefix=/usr \
98                 INSTALL_LIBDIR="$(get_libdir)" \
99                 AR="$(tc-getAR)" \
100                 AROPTS="rcs" \
101                 CFLAGS="${CFLAGS}" \
102                 CXXFLAGS="${CXXFLAGS}" \
103                 LD="${CC}" \
104                 LDXX="${CXX}" \
105                 STRIP=/bin/true \
106                 HOST_CC="$(tc-getBUILD_CC)" \
107                 HOST_CXX="$(tc-getBUILD_CXX)" \
108                 HOST_LD="$(tc-getBUILD_CC)" \
109                 HOST_LDXX="$(tc-getBUILD_CXX)" \
110                 HOST_AR="$(tc-getBUILD_AR)" \
111                 HAS_SYSTEMTAP="$(usex systemtap true false)"
112
113         use python && distutils-r1_src_compile
114 }
115
116 python_compile() {
117         export GRPC_PYTHON_BUILD_SYSTEM_CARES=1
118         export GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1
119         export GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1
120         export GRPC_PYTHON_BUILD_WITH_CYTHON=1
121         distutils-r1_python_compile
122
123         if use tools; then
124                 pushd tools/distrib/python/grpcio_tools >/dev/null || die
125                 distutils-r1_python_compile
126                 popd >/dev/null || die
127         fi
128 }
129
130 python_compile_all() {
131         if use doc; then
132                 esetup.py doc
133                 mv doc/build doc/html || die
134         fi
135 }
136
137 src_install() {
138         emake \
139                 prefix="${D}"/usr \
140                 INSTALL_LIBDIR="$(get_libdir)" \
141                 STRIP=/bin/true \
142                 install
143
144         use static-libs || find "${ED}" -name '*.a' -delete
145
146         if use examples; then
147                 find examples -name '.gitignore' -delete || die
148                 dodoc -r examples
149                 docompress -x /usr/share/doc/${PF}/examples
150         fi
151
152         if use doc; then
153                 find doc -name '.gitignore' -delete || die
154                 local DOCS=( AUTHORS README.md doc/. )
155         fi
156
157         einstalldocs
158
159         use python && distutils-r1_src_install
160
161 }
162
163 python_install() {
164         distutils-r1_python_install
165
166         if use tools; then
167                 pushd tools/distrib/python/grpcio_tools >/dev/null || die
168                 distutils-r1_python_install
169                 popd >/dev/null || die
170         fi
171 }