rpc.scm 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
  4. ;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
  5. ;;; Copyright © 2020 Brett Gilio <brettg@gnu.org>
  6. ;;; Copyright © 2021 Greg Hogan <code@greghogan.com>
  7. ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  8. ;;;
  9. ;;; This file is part of GNU Guix.
  10. ;;;
  11. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  12. ;;; under the terms of the GNU General Public License as published by
  13. ;;; the Free Software Foundation; either version 3 of the License, or (at
  14. ;;; your option) any later version.
  15. ;;;
  16. ;;; GNU Guix is distributed in the hope that it will be useful, but
  17. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ;;; GNU General Public License for more details.
  20. ;;;
  21. ;;; You should have received a copy of the GNU General Public License
  22. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  23. (define-module (gnu packages rpc)
  24. #:use-module ((guix licenses) #:prefix license:)
  25. #:use-module (guix packages)
  26. #:use-module (guix git-download)
  27. #:use-module (guix download)
  28. #:use-module (guix utils)
  29. #:use-module (guix build-system cmake)
  30. #:use-module (guix build-system gnu)
  31. #:use-module (guix build-system python)
  32. #:use-module (gnu packages adns)
  33. #:use-module (gnu packages autotools)
  34. #:use-module (gnu packages bison)
  35. #:use-module (gnu packages boost)
  36. #:use-module (gnu packages compression)
  37. #:use-module (gnu packages cpp)
  38. #:use-module (gnu packages flex)
  39. #:use-module (gnu packages pkg-config)
  40. #:use-module (gnu packages protobuf)
  41. #:use-module (gnu packages python)
  42. #:use-module (gnu packages python-xyz)
  43. #:use-module (gnu packages regex)
  44. #:use-module (gnu packages tls)
  45. #:use-module (srfi srfi-1))
  46. (define-public grpc
  47. (package
  48. (name "grpc")
  49. (version "1.34.0")
  50. (outputs '("out" "static"))
  51. (source (origin
  52. (method git-fetch)
  53. (uri (git-reference
  54. (url "https://github.com/grpc/grpc")
  55. (commit (string-append "v" version))))
  56. (file-name (git-file-name name version))
  57. (sha256
  58. (base32
  59. "1fs407hnlnm0b8sncjwys9rc7ia5nb7wxrpx39nq3pzzfs1lv3vq"))))
  60. (build-system cmake-build-system)
  61. (arguments
  62. `(#:tests? #f ; no test target
  63. #:configure-flags
  64. (list "-DgRPC_ZLIB_PROVIDER=package"
  65. "-DgRPC_ABSL_PROVIDER=package"
  66. "-DgRPC_CARES_PROVIDER=package"
  67. "-DgRPC_SSL_PROVIDER=package"
  68. "-DgRPC_PROTOBUF_PROVIDER=package"
  69. "-DgRPC_RE2_PROVIDER=package"
  70. (string-append "-DCMAKE_INSTALL_PREFIX="
  71. (assoc-ref %outputs "out"))
  72. "-DCMAKE_INSTALL_LIBDIR=lib"
  73. (string-append "-DCMAKE_INSTALL_RPATH="
  74. (assoc-ref %outputs "out") "/lib")
  75. "-DCMAKE_VERBOSE_MAKEFILE=ON")
  76. #:phases
  77. (modify-phases %standard-phases
  78. (add-before 'configure 'configure-shared
  79. (lambda* (#:key (configure-flags '()) #:allow-other-keys)
  80. (mkdir "../build-shared")
  81. (with-directory-excursion "../build-shared"
  82. (apply invoke
  83. "cmake" "../source"
  84. "-DBUILD_SHARED_LIBS=ON"
  85. configure-flags)
  86. (apply invoke "make"
  87. `("-j" ,(number->string (parallel-job-count)))))))
  88. (add-after 'install 'install-shared-libraries
  89. (lambda _
  90. (with-directory-excursion "../build-shared"
  91. (invoke "make" "install"))))
  92. (add-before 'strip 'move-static-libs
  93. (lambda* (#:key outputs #:allow-other-keys)
  94. (let ((out (assoc-ref outputs "out"))
  95. (static (assoc-ref outputs "static")))
  96. (mkdir-p (string-append static "/lib"))
  97. (with-directory-excursion
  98. (string-append out "/lib")
  99. (for-each
  100. (lambda (file)
  101. (rename-file file
  102. (string-append static "/lib/" file)))
  103. (find-files "." "\\.a$"))))
  104. #t)))))
  105. (inputs
  106. `(("abseil-cpp" ,abseil-cpp)
  107. ("c-ares" ,c-ares/cmake)
  108. ("openssl" ,openssl)
  109. ("re2" ,re2)
  110. ("zlib" ,zlib)))
  111. (native-inputs
  112. `(("pkg-config" ,pkg-config)
  113. ("protobuf" ,protobuf)
  114. ("python" ,python-wrapper)))
  115. (home-page "https://grpc.io")
  116. (synopsis "High performance universal RPC framework")
  117. (description "gRPC is a modern high performance @dfn{Remote Procedure Call}
  118. (RPC) framework that can run in any environment. It can efficiently connect
  119. services in and across data centers with pluggable support for load balancing,
  120. tracing, health checking and authentication. It is also applicable in last
  121. mile of distributed computing to connect devices, mobile applications and
  122. browsers to backend services.")
  123. (license license:asl2.0)))
  124. ;; Some packages require this older version.
  125. (define-public grpc-1.16.1
  126. (package
  127. (inherit grpc)
  128. (version "1.16.1")
  129. (source (origin
  130. (method git-fetch)
  131. (uri (git-reference
  132. (url "https://github.com/grpc/grpc")
  133. (commit (string-append "v" version))))
  134. (file-name (git-file-name "grpc" version))
  135. (sha256
  136. (base32
  137. "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
  138. (arguments
  139. (substitute-keyword-arguments (package-arguments grpc)
  140. ((#:phases phases)
  141. `(modify-phases ,phases
  142. ;; Note: This would be nicer as a snippet, but that creates a tarball
  143. ;; instead of a checkout and breaks assumptions made by the builder.
  144. (add-after 'unpack 'rename-gettid
  145. (lambda _
  146. ;; Rename custom gettid() syscall wrapper to avoid conflict
  147. ;; with gettid() from glibc 2.30.
  148. (substitute* '("src/core/lib/gpr/log_linux.cc"
  149. "src/core/lib/gpr/log_posix.cc"
  150. "src/core/lib/iomgr/ev_epollex_linux.cc")
  151. (("gettid\\(")
  152. "sys_gettid("))
  153. #t))))))
  154. (native-inputs
  155. `(("protobuf" ,protobuf-3.6)
  156. ,@(alist-delete "protobuf" (package-native-inputs grpc))))))
  157. (define-public python-grpcio
  158. (package
  159. (name "python-grpcio")
  160. (version "1.27.2")
  161. (source
  162. (origin
  163. (method url-fetch)
  164. (uri (pypi-uri "grpcio" version))
  165. (sha256
  166. (base32
  167. "0zl89jwcff9hkd8mi4yf3qbhns9vbv1s4x4vahm5mkpr7jwk5ras"))
  168. (modules '((guix build utils) (ice-9 ftw)))
  169. (snippet
  170. '(begin
  171. (with-directory-excursion "third_party"
  172. ;; Delete the bundled source code of libraries that are possible
  173. ;; to provide as inputs.
  174. (for-each delete-file-recursively
  175. (scandir "."
  176. (lambda (file)
  177. (not (member file
  178. '("." ".."
  179. "abseil-cpp"
  180. "address_sorting"
  181. "upb")))))))
  182. #t))))
  183. (build-system python-build-system)
  184. (arguments
  185. '(#:phases (modify-phases %standard-phases
  186. (add-before 'build 'use-system-libraries
  187. (lambda _
  188. (setenv "GRPC_PYTHON_BUILD_SYSTEM_CARES" "1")
  189. (setenv "GRPC_PYTHON_BUILD_SYSTEM_OPENSSL" "1")
  190. (setenv "GRPC_PYTHON_BUILD_SYSTEM_ZLIB" "1")
  191. #t))
  192. (add-before 'build 'configure-compiler
  193. (lambda _
  194. (substitute* '("setup.py" "src/python/grpcio/commands.py")
  195. (("'cc'") "'gcc'"))
  196. #t)))))
  197. (inputs
  198. `(("c-ares" ,c-ares)
  199. ("openssl" ,openssl)
  200. ("zlib" ,zlib)))
  201. (propagated-inputs
  202. `(("python-six" ,python-six)))
  203. (home-page "https://grpc.io")
  204. (synopsis "HTTP/2-based RPC framework")
  205. (description "This package provides a Python library for communicating
  206. with the HTTP/2-based RPC framework gRPC.")
  207. (license license:asl2.0)))
  208. (define-public apache-thrift
  209. (package
  210. (name "apache-thrift")
  211. (version "0.14.2")
  212. (source
  213. (origin
  214. (method git-fetch)
  215. (uri (git-reference
  216. (url "https://github.com/apache/thrift")
  217. (commit (string-append "v" version))))
  218. (file-name (git-file-name name version))
  219. (sha256
  220. (base32 "0wmnb3h0xq8qc5a9g9lliszh6qg254f5856h72viab46bizmdd4a"))))
  221. (build-system gnu-build-system)
  222. (arguments
  223. '(#:tests? #f
  224. #:configure-flags
  225. (list (string-append "--with-boost="
  226. (assoc-ref %build-inputs "boost")))))
  227. (native-inputs
  228. `(("autoconf" ,autoconf)
  229. ("automake" ,automake)
  230. ("libtool" ,libtool)
  231. ("pkg-config" ,pkg-config)
  232. ("flex" ,flex)
  233. ("bison" ,bison)))
  234. (inputs
  235. `(("boost" ,boost)
  236. ("libressl" ,libressl)))
  237. (outputs '("out" "lib" "include"))
  238. (home-page "https://thrift.apache.org/")
  239. (synopsis
  240. "Lightweight, language-independent software stack for point-to-point
  241. RPC")
  242. (description
  243. "Thrift provides clean abstractions and implementations for data
  244. transport, data serialization, and application level processing. The code
  245. generation system takes a simple definition language as input and generates
  246. code across programming languages that uses the abstracted stack to build
  247. interoperable RPC clients and servers.")
  248. (license license:asl2.0)))