Subject: [PATCH rust-team v2 013/117] gnu: Add rust-grpcio-0.12.

From: Herman Rimm <[email-masked]>
Date: Sun, 28 Apr 2024 20:54:39 +0200

* gnu/packages/crates-io.scm (rust-grpcio-0.12): Add variable.

Change-Id: I985317ac862f4b50e3428ee6f9dbcf57f8eae5a6
---
 gnu/packages/crates-io.scm | 51 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/gnu/packages/crates-io.scm b/gnu/packages/crates-io.scm
index faea57c6f7..9f4eacad2f 100644
--- a/gnu/packages/crates-io.scm
+++ b/gnu/packages/crates-io.scm
@@ -30681,6 +30681,57 @@ (define-public rust-groupable-0.2
      "This package aggregates groups of values from key-value iterators.")
     (license license:expat)))
 
+(define-public rust-grpcio-0.12
+  (package
+    (name "rust-grpcio")
+    (version "0.12.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (crate-uri "grpcio" version))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32 "02j3dxlww8m2gf09m2abiw2msgyqkvd2z4w1viibdbhva3535630"))
+       (modules '((guix build utils)))
+       (snippet '(begin
+                   (substitute* "Cargo.toml.orig"
+                     ;; Workspace members are not included.
+                     (("path = \"(grpc-sys|compiler)\", ") "")
+                     (("    \"(proto|benchmark|compiler|health)\",\n") "")
+                     (("    \"(interop|tests-and-examples)\",\n") "")
+                     ;; Use openssl and remove boringssl.
+                     (("\"boringssl\"")
+                      "\"openssl\"")
+                     (("boringssl = .*") "")
+                     ;; Use patch crate as direct dependency.
+                     (("patch.crates-io")
+                      "target.'cfg(unix)'.dependencies"))
+                   (copy-file "Cargo.toml.orig" "Cargo.toml")))))
+    (build-system cargo-build-system)
+    (arguments
+     `(#:cargo-inputs (("rust-bytes" ,rust-bytes-1)
+                       ("rust-futures-executor" ,rust-futures-executor-0.3)
+                       ("rust-futures-util" ,rust-futures-util-0.3)
+                       ("rust-grpcio-sys" ,rust-grpcio-sys-0.12)
+                       ("rust-grpcio-compiler" ,rust-grpcio-compiler-0.12)
+                       ("rust-libc" ,rust-libc-0.2)
+                       ("rust-log" ,rust-log-0.4)
+                       ("rust-parking-lot" ,rust-parking-lot-0.12)
+                       ("rust-prost" ,rust-prost-0.11)
+                       ("rust-protobuf" ,rust-protobuf-2))
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'build 'use-pkg-config
+           (lambda _ (setenv "GRPCIO_SYS_USE_PKG_CONFIG" "1"))))))
+    (native-inputs (list pkg-config))
+    (inputs (list abseil-cpp c-ares grpc-for-python-grpcio openssl re2 zlib))
+    (home-page "https://github.com/tikv/grpc-rs")
+    (synopsis "Rust implementation of gRPC based on the C core library.")
+    (description
+     "This package provides the Rust language implementation of
+@code{gRPC} based on the @code{gRPC} C core library.")
+    (license license:asl2.0)))
+
 (define-public rust-grpcio-compiler-0.12
   (package
     (name "rust-grpcio-compiler")
-- 
2.41.0