1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
6 ;;; This file is part of GNU Guix.
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21 (define-module (gnu packages rpc)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix packages)
24 #:use-module (guix git-download)
25 #:use-module (guix download)
26 #:use-module (guix build-system cmake)
27 #:use-module (guix build-system python)
28 #:use-module (gnu packages adns)
29 #:use-module (gnu packages compression)
30 #:use-module (gnu packages cpp)
31 #:use-module (gnu packages protobuf)
32 #:use-module (gnu packages python)
33 #:use-module (gnu packages python-xyz)
34 #:use-module (gnu packages tls))
40 (outputs '("out" "static"))
44 (url "https://github.com/grpc/grpc.git")
45 (commit (string-append "v" version))))
46 (file-name (git-file-name name version))
49 "0czmbwnafc7jnrrq2fnac2av83vs2q7q0wy4k11w9zbpld7j5h6d"))))
50 (build-system cmake-build-system)
52 `(#:tests? #f ; no test target
54 (list "-DgRPC_ZLIB_PROVIDER=package"
55 "-DgRPC_ABSL_PROVIDER=package"
56 "-DgRPC_CARES_PROVIDER=package"
57 "-DgRPC_SSL_PROVIDER=package"
58 "-DgRPC_PROTOBUF_PROVIDER=package"
59 (string-append "-DCMAKE_INSTALL_PREFIX="
60 (assoc-ref %outputs "out"))
61 "-DCMAKE_INSTALL_LIBDIR=lib"
62 (string-append "-DCMAKE_INSTALL_RPATH="
63 (assoc-ref %outputs "out") "/lib")
64 "-DCMAKE_VERBOSE_MAKEFILE=ON")
66 (modify-phases %standard-phases
67 (add-before 'configure 'configure-shared
68 (lambda* (#:key (configure-flags '()) #:allow-other-keys)
69 (mkdir "../build-shared")
70 (with-directory-excursion "../build-shared"
73 "-DBUILD_SHARED_LIBS=ON"
76 `("-j" ,(number->string (parallel-job-count)))))))
77 (add-after 'install 'install-shared-libraries
79 (with-directory-excursion "../build-shared"
80 (invoke "make" "install"))))
81 (add-before 'strip 'move-static-libs
82 (lambda* (#:key outputs #:allow-other-keys)
83 (let ((out (assoc-ref outputs "out"))
84 (static (assoc-ref outputs "static")))
85 (mkdir-p (string-append static "/lib"))
86 (with-directory-excursion
87 (string-append out "/lib")
91 (string-append static "/lib/" file)))
92 (find-files "." "\\.a$"))))
95 `(("abseil-cpp" ,abseil-cpp)
96 ("c-ares" ,c-ares/cmake)
100 `(("protobuf" ,protobuf)
101 ("python" ,python-wrapper)))
102 (home-page "https://grpc.io")
103 (synopsis "High performance universal RPC framework")
104 (description "gRPC is a modern high performance @dfn{Remote Procedure Call}
105 (RPC) framework that can run in any environment. It can efficiently connect
106 services in and across data centers with pluggable support for load balancing,
107 tracing, health checking and authentication. It is also applicable in last
108 mile of distributed computing to connect devices, mobile applications and
109 browsers to backend services.")
110 (license license:asl2.0)))
112 ;; Some packages require this older version.
113 (define-public grpc-1.16.1
120 (url "https://github.com/grpc/grpc.git")
121 (commit (string-append "v" version))))
122 (file-name (git-file-name "grpc" version))
125 "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))))
127 (define-public python-grpcio
129 (name "python-grpcio")
134 (uri (pypi-uri "grpcio" version))
137 "0zl89jwcff9hkd8mi4yf3qbhns9vbv1s4x4vahm5mkpr7jwk5ras"))
138 (modules '((guix build utils) (ice-9 ftw)))
141 (with-directory-excursion "third_party"
142 ;; Delete the bundled source code of libraries that are possible
143 ;; to provide as inputs.
144 (for-each delete-file-recursively
153 (build-system python-build-system)
155 '(#:phases (modify-phases %standard-phases
156 (add-before 'build 'use-system-libraries
158 (setenv "GRPC_PYTHON_BUILD_SYSTEM_CARES" "1")
159 (setenv "GRPC_PYTHON_BUILD_SYSTEM_OPENSSL" "1")
160 (setenv "GRPC_PYTHON_BUILD_SYSTEM_ZLIB" "1")
162 (add-before 'build 'configure-compiler
164 (substitute* '("setup.py" "src/python/grpcio/commands.py")
172 `(("python-six" ,python-six)))
173 (home-page "https://grpc.io")
174 (synopsis "HTTP/2-based RPC framework")
175 (description "This package provides a Python library for communicating
176 with the HTTP/2-based RPC framework gRPC.")
177 (license license:asl2.0)))