# Template file for 'grpc'
pkgname=grpc
version=1.61.1
revision=1
build_style=cmake
configure_args="-DBUILD_SHARED_LIBS=ON
 -DgRPC_CARES_PROVIDER=package -DgRPC_PROTOBUF_PROVIDER=package
 -DgRPC_SSL_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package
 -DgRPC_ABSL_PROVIDER=package -DgRPC_RE2_PROVIDER=package"
hostmakedepends="protobuf pkg-config"
_devel_depends="c-ares-devel re2-devel zlib-devel openssl-devel abseil-cpp-devel
 protobuf-devel"
makedepends="libprotoc-devel gperftools-devel ${_devel_depends}"
short_desc="High performance, open source, general RPC framework"
maintainer="Orphaned <orphan@voidlinux.org>"
license="Apache-2.0"
homepage="https://github.com/grpc/grpc"
_opencensus=0.3.0
_xds=e9ce68804cb4e64cab5a52e3c8baf840d4ff87b7
distfiles="https://github.com/grpc/grpc/archive/v${version}/${pkgname}-${version}.tar.gz
 https://storage.googleapis.com/grpc-bazel-mirror/github.com/census-instrumentation/opencensus-proto/archive/v${_opencensus}.tar.gz>opencensus-proto-v${_opencensus}.tar.gz
 https://storage.googleapis.com/grpc-bazel-mirror/github.com/cncf/xds/archive/${_xds}.tar.gz>xds-${_xds}.tar.gz
 "
checksum="6dadc0420ad2d4b8ac49f516830f72feae3764bf83decc8d7c3a871eca1a0843
 b7e13f0b4259e80c3070b583c2f39e53153085a6918718b1c710caf7037572b0
 0d33b83f8c6368954e72e7785539f0d272a8aba2f6e2e336ed15fd1514bc9899"

skip_extraction="
 opencensus-proto-v${_opencensus}.tar.gz
 xds-${_xds}.tar.gz"

if [ "$CROSS_BUILD" ]; then
	# need host grpc_cpp_plugin
	hostmakedepends+=" grpc"
	configure_args+=" -DProtobuf_PROTOC_EXECUTABLE=/usr/bin/protoc"
fi

post_extract() {
	vsrcextract -C third_party/opencensus-proto \
		"opencensus-proto-v${_opencensus}.tar.gz"
	vsrcextract -C third_party/xds "xds-${_xds}.tar.gz"
}

libgrpc_package() {
	short_desc+=" - libraries"
	pkg_install() {
		vmove "usr/lib/*.so.*"
		vmove usr/share
	}
}

grpc-devel_package() {
	short_desc+=" - development files"
	depends="${sourcepkg}>=${version}_${revision} ${_devel_depends}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/*.so
		vmove usr/lib/cmake
		vmove usr/lib/pkgconfig
	}
}
