Package.swift 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. // swift-tools-version:5.2
  2. /*
  3. * Copyright 2017, gRPC Authors All rights reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import PackageDescription
  18. let package = Package(
  19. name: "grpc-swift",
  20. products: [
  21. .library(name: "GRPC", targets: ["GRPC"]),
  22. .library(name: "CGRPCZlib", targets: ["CGRPCZlib"]),
  23. .executable(name: "protoc-gen-grpc-swift", targets: ["protoc-gen-grpc-swift"]),
  24. ],
  25. dependencies: [
  26. // GRPC dependencies:
  27. // Main SwiftNIO package
  28. .package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
  29. // HTTP2 via SwiftNIO
  30. .package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.18.2"),
  31. // TLS via SwiftNIO
  32. .package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.14.0"),
  33. // Support for Network.framework where possible.
  34. .package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.11.1"),
  35. // Extra NIO stuff; quiescing helpers.
  36. .package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.4.0"),
  37. // Official SwiftProtobuf library, for [de]serializing data to send on the wire.
  38. .package(
  39. name: "SwiftProtobuf",
  40. url: "https://github.com/apple/swift-protobuf.git",
  41. from: "1.9.0"
  42. ),
  43. // Logging API.
  44. .package(url: "https://github.com/apple/swift-log.git", from: "1.4.0"),
  45. // Argument parsing: only for internal targets (i.e. examples).
  46. .package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
  47. ],
  48. targets: [
  49. // The main GRPC module.
  50. .target(
  51. name: "GRPC",
  52. dependencies: [
  53. .product(name: "NIO", package: "swift-nio"),
  54. .product(name: "NIOCore", package: "swift-nio"),
  55. .product(name: "NIOPosix", package: "swift-nio"),
  56. .product(name: "NIOEmbedded", package: "swift-nio"),
  57. .product(name: "NIOFoundationCompat", package: "swift-nio"),
  58. .product(name: "NIOTLS", package: "swift-nio"),
  59. .product(name: "_NIOConcurrency", package: "swift-nio"),
  60. .product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
  61. .product(name: "NIOHTTP1", package: "swift-nio"),
  62. .product(name: "NIOHTTP2", package: "swift-nio-http2"),
  63. .product(name: "NIOExtras", package: "swift-nio-extras"),
  64. .product(name: "NIOSSL", package: "swift-nio-ssl"),
  65. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  66. .product(name: "Logging", package: "swift-log"),
  67. .target(name: "CGRPCZlib"),
  68. ]
  69. ), // and its tests.
  70. .testTarget(
  71. name: "GRPCTests",
  72. dependencies: [
  73. .target(name: "GRPC"),
  74. .target(name: "EchoModel"),
  75. .target(name: "EchoImplementation"),
  76. .target(name: "GRPCSampleData"),
  77. .target(name: "GRPCInteroperabilityTestsImplementation"),
  78. .target(name: "HelloWorldModel"),
  79. .product(name: "NIOCore", package: "swift-nio"),
  80. .product(name: "NIOPosix", package: "swift-nio"),
  81. .product(name: "NIOEmbedded", package: "swift-nio"),
  82. ]
  83. ),
  84. .target(
  85. name: "CGRPCZlib",
  86. linkerSettings: [
  87. .linkedLibrary("z"),
  88. ]
  89. ),
  90. // The `protoc` plugin.
  91. .target(
  92. name: "protoc-gen-grpc-swift",
  93. dependencies: [
  94. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  95. .product(name: "SwiftProtobufPluginLibrary", package: "SwiftProtobuf"),
  96. ]
  97. ),
  98. // Interoperability tests implementation.
  99. .target(
  100. name: "GRPCInteroperabilityTestsImplementation",
  101. dependencies: [
  102. .target(name: "GRPC"),
  103. .target(name: "GRPCInteroperabilityTestModels"),
  104. ]
  105. ),
  106. // Generated interoperability test models.
  107. .target(
  108. name: "GRPCInteroperabilityTestModels",
  109. dependencies: [
  110. .target(name: "GRPC"),
  111. .product(name: "NIO", package: "swift-nio"),
  112. .product(name: "NIOHTTP1", package: "swift-nio"),
  113. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  114. ]
  115. ),
  116. // The CLI for the interoperability tests.
  117. .target(
  118. name: "GRPCInteroperabilityTests",
  119. dependencies: [
  120. .target(name: "GRPCInteroperabilityTestsImplementation"),
  121. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  122. ]
  123. ),
  124. // The connection backoff interoperability test.
  125. .target(
  126. name: "GRPCConnectionBackoffInteropTest",
  127. dependencies: [
  128. .target(name: "GRPC"),
  129. .target(name: "GRPCInteroperabilityTestModels"),
  130. .product(name: "Logging", package: "swift-log"),
  131. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  132. ]
  133. ),
  134. // Performance tests implementation and CLI.
  135. .target(
  136. name: "GRPCPerformanceTests",
  137. dependencies: [
  138. .target(name: "GRPC"),
  139. .product(name: "NIO", package: "swift-nio"),
  140. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  141. ]
  142. ),
  143. // Sample data, used in examples and tests.
  144. .target(
  145. name: "GRPCSampleData",
  146. dependencies: [
  147. .product(name: "NIOSSL", package: "swift-nio-ssl"),
  148. ]
  149. ),
  150. // Echo example CLI.
  151. .target(
  152. name: "Echo",
  153. dependencies: [
  154. .target(name: "EchoModel"),
  155. .target(name: "EchoImplementation"),
  156. .target(name: "GRPC"),
  157. .target(name: "GRPCSampleData"),
  158. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  159. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  160. ],
  161. path: "Sources/Examples/Echo/Runtime"
  162. ),
  163. // Echo example service implementation.
  164. .target(
  165. name: "EchoImplementation",
  166. dependencies: [
  167. .target(name: "EchoModel"),
  168. .target(name: "GRPC"),
  169. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  170. ],
  171. path: "Sources/Examples/Echo/Implementation"
  172. ),
  173. // Model for Echo example.
  174. .target(
  175. name: "EchoModel",
  176. dependencies: [
  177. .target(name: "GRPC"),
  178. .product(name: "NIO", package: "swift-nio"),
  179. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  180. ],
  181. path: "Sources/Examples/Echo/Model"
  182. ),
  183. // Model for the HelloWorld example
  184. .target(
  185. name: "HelloWorldModel",
  186. dependencies: [
  187. .target(name: "GRPC"),
  188. .product(name: "NIO", package: "swift-nio"),
  189. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  190. ],
  191. path: "Sources/Examples/HelloWorld/Model"
  192. ),
  193. // Client for the HelloWorld example
  194. .target(
  195. name: "HelloWorldClient",
  196. dependencies: [
  197. .target(name: "GRPC"),
  198. .target(name: "HelloWorldModel"),
  199. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  200. ],
  201. path: "Sources/Examples/HelloWorld/Client"
  202. ),
  203. // Server for the HelloWorld example
  204. .target(
  205. name: "HelloWorldServer",
  206. dependencies: [
  207. .target(name: "GRPC"),
  208. .product(name: "NIO", package: "swift-nio"),
  209. .target(name: "HelloWorldModel"),
  210. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  211. ],
  212. path: "Sources/Examples/HelloWorld/Server"
  213. ),
  214. // Model for the RouteGuide example
  215. .target(
  216. name: "RouteGuideModel",
  217. dependencies: [
  218. .target(name: "GRPC"),
  219. .product(name: "NIO", package: "swift-nio"),
  220. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  221. ],
  222. path: "Sources/Examples/RouteGuide/Model"
  223. ),
  224. // Client for the RouteGuide example
  225. .target(
  226. name: "RouteGuideClient",
  227. dependencies: [
  228. .target(name: "GRPC"),
  229. .target(name: "RouteGuideModel"),
  230. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  231. ],
  232. path: "Sources/Examples/RouteGuide/Client"
  233. ),
  234. // Server for the RouteGuide example
  235. .target(
  236. name: "RouteGuideServer",
  237. dependencies: [
  238. .target(name: "GRPC"),
  239. .product(name: "NIO", package: "swift-nio"),
  240. .target(name: "RouteGuideModel"),
  241. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  242. ],
  243. path: "Sources/Examples/RouteGuide/Server"
  244. ),
  245. // Client for the PacketCapture example
  246. .target(
  247. name: "PacketCapture",
  248. dependencies: [
  249. .target(name: "GRPC"),
  250. .target(name: "EchoModel"),
  251. .product(name: "NIO", package: "swift-nio"),
  252. .product(name: "NIOExtras", package: "swift-nio-extras"),
  253. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  254. ],
  255. path: "Sources/Examples/PacketCapture"
  256. ),
  257. ]
  258. )