Package.swift 9.0 KB

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