Package.swift 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.28.0"),
  29. // HTTP2 via SwiftNIO
  30. .package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.16.1"),
  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.6.0"),
  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 parsering: only for internal targets (i.e. examples).
  46. // swift-argument-parser only provides source compatability guarantees between minor version.
  47. .package(url: "https://github.com/apple/swift-argument-parser", "0.3.0" ..< "0.5.0"),
  48. ],
  49. targets: [
  50. // The main GRPC module.
  51. .target(
  52. name: "GRPC",
  53. dependencies: [
  54. .product(name: "NIO", package: "swift-nio"),
  55. .product(name: "NIOFoundationCompat", package: "swift-nio"),
  56. .product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
  57. .product(name: "NIOHTTP1", package: "swift-nio"),
  58. .product(name: "NIOHTTP2", package: "swift-nio-http2"),
  59. .product(name: "NIOExtras", package: "swift-nio-extras"),
  60. .product(name: "NIOSSL", package: "swift-nio-ssl"),
  61. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  62. .product(name: "Logging", package: "swift-log"),
  63. .target(name: "CGRPCZlib"),
  64. ]
  65. ), // and its tests.
  66. .testTarget(
  67. name: "GRPCTests",
  68. dependencies: [
  69. .target(name: "GRPC"),
  70. .target(name: "EchoModel"),
  71. .target(name: "EchoImplementation"),
  72. .target(name: "GRPCSampleData"),
  73. .target(name: "GRPCInteroperabilityTestsImplementation"),
  74. .target(name: "HelloWorldModel"),
  75. ]
  76. ),
  77. .target(
  78. name: "CGRPCZlib",
  79. linkerSettings: [
  80. .linkedLibrary("z"),
  81. ]
  82. ),
  83. // The `protoc` plugin.
  84. .target(
  85. name: "protoc-gen-grpc-swift",
  86. dependencies: [
  87. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  88. .product(name: "SwiftProtobufPluginLibrary", package: "SwiftProtobuf"),
  89. ]
  90. ),
  91. // Interoperability tests implementation.
  92. .target(
  93. name: "GRPCInteroperabilityTestsImplementation",
  94. dependencies: [
  95. .target(name: "GRPC"),
  96. .target(name: "GRPCInteroperabilityTestModels"),
  97. ]
  98. ),
  99. // Generated interoperability test models.
  100. .target(
  101. name: "GRPCInteroperabilityTestModels",
  102. dependencies: [
  103. .target(name: "GRPC"),
  104. .product(name: "NIO", package: "swift-nio"),
  105. .product(name: "NIOHTTP1", package: "swift-nio"),
  106. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  107. ]
  108. ),
  109. // The CLI for the interoperability tests.
  110. .target(
  111. name: "GRPCInteroperabilityTests",
  112. dependencies: [
  113. .target(name: "GRPCInteroperabilityTestsImplementation"),
  114. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  115. ]
  116. ),
  117. // The connection backoff interoperability test.
  118. .target(
  119. name: "GRPCConnectionBackoffInteropTest",
  120. dependencies: [
  121. .target(name: "GRPC"),
  122. .target(name: "GRPCInteroperabilityTestModels"),
  123. .product(name: "Logging", package: "swift-log"),
  124. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  125. ]
  126. ),
  127. // Performance tests implementation and CLI.
  128. .target(
  129. name: "GRPCPerformanceTests",
  130. dependencies: [
  131. .target(name: "GRPC"),
  132. .product(name: "NIO", package: "swift-nio"),
  133. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  134. ]
  135. ),
  136. // Sample data, used in examples and tests.
  137. .target(
  138. name: "GRPCSampleData",
  139. dependencies: [
  140. .product(name: "NIOSSL", package: "swift-nio-ssl"),
  141. ]
  142. ),
  143. // Echo example CLI.
  144. .target(
  145. name: "Echo",
  146. dependencies: [
  147. .target(name: "EchoModel"),
  148. .target(name: "EchoImplementation"),
  149. .target(name: "GRPC"),
  150. .target(name: "GRPCSampleData"),
  151. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  152. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  153. ],
  154. path: "Sources/Examples/Echo/Runtime"
  155. ),
  156. // Echo example service implementation.
  157. .target(
  158. name: "EchoImplementation",
  159. dependencies: [
  160. .target(name: "EchoModel"),
  161. .target(name: "GRPC"),
  162. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  163. ],
  164. path: "Sources/Examples/Echo/Implementation"
  165. ),
  166. // Model for Echo example.
  167. .target(
  168. name: "EchoModel",
  169. dependencies: [
  170. .target(name: "GRPC"),
  171. .product(name: "NIO", package: "swift-nio"),
  172. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  173. ],
  174. path: "Sources/Examples/Echo/Model"
  175. ),
  176. // Model for the HelloWorld example
  177. .target(
  178. name: "HelloWorldModel",
  179. dependencies: [
  180. .target(name: "GRPC"),
  181. .product(name: "NIO", package: "swift-nio"),
  182. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  183. ],
  184. path: "Sources/Examples/HelloWorld/Model"
  185. ),
  186. // Client for the HelloWorld example
  187. .target(
  188. name: "HelloWorldClient",
  189. dependencies: [
  190. .target(name: "GRPC"),
  191. .target(name: "HelloWorldModel"),
  192. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  193. ],
  194. path: "Sources/Examples/HelloWorld/Client"
  195. ),
  196. // Server for the HelloWorld example
  197. .target(
  198. name: "HelloWorldServer",
  199. dependencies: [
  200. .target(name: "GRPC"),
  201. .product(name: "NIO", package: "swift-nio"),
  202. .target(name: "HelloWorldModel"),
  203. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  204. ],
  205. path: "Sources/Examples/HelloWorld/Server"
  206. ),
  207. // Model for the RouteGuide example
  208. .target(
  209. name: "RouteGuideModel",
  210. dependencies: [
  211. .target(name: "GRPC"),
  212. .product(name: "NIO", package: "swift-nio"),
  213. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  214. ],
  215. path: "Sources/Examples/RouteGuide/Model"
  216. ),
  217. // Client for the RouteGuide example
  218. .target(
  219. name: "RouteGuideClient",
  220. dependencies: [
  221. .target(name: "GRPC"),
  222. .target(name: "RouteGuideModel"),
  223. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  224. ],
  225. path: "Sources/Examples/RouteGuide/Client"
  226. ),
  227. // Server for the RouteGuide example
  228. .target(
  229. name: "RouteGuideServer",
  230. dependencies: [
  231. .target(name: "GRPC"),
  232. .product(name: "NIO", package: "swift-nio"),
  233. .target(name: "RouteGuideModel"),
  234. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  235. ],
  236. path: "Sources/Examples/RouteGuide/Server"
  237. ),
  238. // Client for the PacketCapture example
  239. .target(
  240. name: "PacketCapture",
  241. dependencies: [
  242. .target(name: "GRPC"),
  243. .target(name: "EchoModel"),
  244. .product(name: "NIO", package: "swift-nio"),
  245. .product(name: "NIOExtras", package: "swift-nio-extras"),
  246. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  247. ],
  248. path: "Sources/Examples/PacketCapture"
  249. ),
  250. ]
  251. )