# Template file for 'grpc'
pkgname=grpc
version=1.83.0
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_rev=4aa53e15cbf1a47bc9087e6cfdca214c1eea4e89
_xds_rev=ee656c7534f5d7dc23d44dd611689568f72017a6
distfiles="https://github.com/grpc/grpc/archive/v${version}/grpc-${version}.tar.gz
 https://github.com/census-instrumentation/opencensus-proto/archive/${_opencensus_rev}.tar.gz>opencensus-proto-v${_opencensus_rev}.tar.gz
 https://storage.googleapis.com/grpc-bazel-mirror/github.com/cncf/xds/archive/${_xds_rev}.tar.gz>xds-${_xds_rev}.tar.gz"
checksum="90d453393a9d41215df546103b10b33b9566df79cdf6f49dc67f6c4d044d090d
 27b7982d3ab3a0a66e09d997bbb373e1c83a48abad6da09bbc866428f443a727
 49535f3c3370004309da50194c09bbfc528d4702424dd46e7d56a278a3dfc15d"

skip_extraction="
 opencensus-proto-v${_opencensus_rev}.tar.gz
 xds-${_xds_rev}.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_rev}.tar.gz"
	vsrcextract -C third_party/xds "xds-${_xds_rev}.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
	}
}
