rpc.scm 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. (list abseil-cpp c-ares/cmake openssl re2 zlib))
  107. (native-inputs
  108. `(("pkg-config" ,pkg-config)
  109. ("protobuf" ,protobuf)
  110. ("python" ,python-wrapper)))
  111. (home-page "https://grpc.io")
  112. (synopsis "High performance universal RPC framework")
  113. (description "gRPC is a modern high performance @dfn{Remote Procedure Call}
  114. (RPC) framework that can run in any environment. It can efficiently connect
  115. services in and across data centers with pluggable support for load balancing,
  116. tracing, health checking and authentication. It is also applicable in last
  117. mile of distributed computing to connect devices, mobile applications and
  118. browsers to backend services.")
  119. (license license:asl2.0)))
  120. ;; Some packages require this older version.
  121. (define-public grpc-1.16.1
  122. (package
  123. (inherit grpc)
  124. (version "1.16.1")
  125. (source (origin
  126. (method git-fetch)
  127. (uri (git-reference
  128. (url "https://github.com/grpc/grpc")
  129. (commit (string-append "v" version))))
  130. (file-name (git-file-name "grpc" version))
  131. (sha256
  132. (base32
  133. "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
  134. (arguments
  135. (substitute-keyword-arguments (package-arguments grpc)
  136. ((#:phases phases)
  137. `(modify-phases ,phases
  138. ;; Note: This would be nicer as a snippet, but that creates a tarball
  139. ;; instead of a checkout and breaks assumptions made by the builder.
  140. (add-after 'unpack 'rename-gettid
  141. (lambda _
  142. ;; Rename custom gettid() syscall wrapper to avoid conflict
  143. ;; with gettid() from glibc 2.30.
  144. (substitute* '("src/core/lib/gpr/log_linux.cc"
  145. "src/core/lib/gpr/log_posix.cc"
  146. "src/core/lib/iomgr/ev_epollex_linux.cc")
  147. (("gettid\\(")
  148. "sys_gettid("))))))))
  149. (native-inputs
  150. (modify-inputs (package-native-inputs grpc)
  151. (delete "abseil-cpp" "protobuf")
  152. (prepend abseil-cpp-20200923.3 protobuf-3.6)))))
  153. (define-public python-grpcio
  154. (package
  155. (name "python-grpcio")
  156. (version "1.27.2")
  157. (source
  158. (origin
  159. (method url-fetch)
  160. (uri (pypi-uri "grpcio" version))
  161. (sha256
  162. (base32
  163. "0zl89jwcff9hkd8mi4yf3qbhns9vbv1s4x4vahm5mkpr7jwk5ras"))
  164. (modules '((guix build utils) (ice-9 ftw)))
  165. (snippet
  166. '(begin
  167. (with-directory-excursion "third_party"
  168. ;; Delete the bundled source code of libraries that are possible
  169. ;; to provide as inputs.
  170. (for-each delete-file-recursively
  171. (scandir "."
  172. (lambda (file)
  173. (not (member file
  174. '("." ".."
  175. "abseil-cpp"
  176. "address_sorting"
  177. "upb")))))))
  178. #t))))
  179. (build-system python-build-system)
  180. (arguments
  181. '(#:phases (modify-phases %standard-phases
  182. (add-before 'build 'use-system-libraries
  183. (lambda _
  184. (setenv "GRPC_PYTHON_BUILD_SYSTEM_CARES" "1")
  185. (setenv "GRPC_PYTHON_BUILD_SYSTEM_OPENSSL" "1")
  186. (setenv "GRPC_PYTHON_BUILD_SYSTEM_ZLIB" "1")
  187. #t))
  188. (add-before 'build 'configure-compiler
  189. (lambda _
  190. (substitute* '("setup.py" "src/python/grpcio/commands.py")
  191. (("'cc'") "'gcc'"))
  192. #t)))))
  193. (inputs
  194. (list c-ares openssl zlib))
  195. (propagated-inputs
  196. (list python-six))
  197. (home-page "https://grpc.io")
  198. (synopsis "HTTP/2-based RPC framework")
  199. (description "This package provides a Python library for communicating
  200. with the HTTP/2-based RPC framework gRPC.")
  201. (license license:asl2.0)))
  202. (define-public apache-thrift
  203. (package
  204. (name "apache-thrift")
  205. (version "0.14.2")
  206. (source
  207. (origin
  208. (method git-fetch)
  209. (uri (git-reference
  210. (url "https://github.com/apache/thrift")
  211. (commit (string-append "v" version))))
  212. (file-name (git-file-name name version))
  213. (sha256
  214. (base32 "0wmnb3h0xq8qc5a9g9lliszh6qg254f5856h72viab46bizmdd4a"))))
  215. (build-system gnu-build-system)
  216. (arguments
  217. '(#:tests? #f
  218. #:configure-flags
  219. (list (string-append "--with-boost="
  220. (assoc-ref %build-inputs "boost")))))
  221. (native-inputs
  222. (list autoconf
  223. automake
  224. libtool
  225. pkg-config
  226. flex
  227. bison))
  228. (inputs
  229. (list boost libressl))
  230. (outputs '("out" "lib" "include"))
  231. (home-page "https://thrift.apache.org/")
  232. (synopsis
  233. "Lightweight, language-independent software stack for point-to-point
  234. RPC")
  235. (description
  236. "Thrift provides clean abstractions and implementations for data
  237. transport, data serialization, and application level processing. The code
  238. generation system takes a simple definition language as input and generates
  239. code across programming languages that uses the abstracted stack to build
  240. interoperable RPC clients and servers.")
  241. (license license:asl2.0)))