Package.swift 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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.22.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.8.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", .upToNextMinor(from: "0.3.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. .target(name: "EchoModel"),
  133. .product(name: "NIO", package: "swift-nio"),
  134. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  135. ]
  136. ),
  137. // Sample data, used in examples and tests.
  138. .target(
  139. name: "GRPCSampleData",
  140. dependencies: [
  141. .product(name: "NIOSSL", package: "swift-nio-ssl"),
  142. ]
  143. ),
  144. // Echo example CLI.
  145. .target(
  146. name: "Echo",
  147. dependencies: [
  148. .target(name: "EchoModel"),
  149. .target(name: "EchoImplementation"),
  150. .target(name: "GRPC"),
  151. .target(name: "GRPCSampleData"),
  152. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  153. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  154. ],
  155. path: "Sources/Examples/Echo/Runtime"
  156. ),
  157. // Echo example service implementation.
  158. .target(
  159. name: "EchoImplementation",
  160. dependencies: [
  161. .target(name: "EchoModel"),
  162. .target(name: "GRPC"),
  163. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  164. ],
  165. path: "Sources/Examples/Echo/Implementation"
  166. ),
  167. // Model for Echo example.
  168. .target(
  169. name: "EchoModel",
  170. dependencies: [
  171. .target(name: "GRPC"),
  172. .product(name: "NIO", package: "swift-nio"),
  173. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  174. ],
  175. path: "Sources/Examples/Echo/Model"
  176. ),
  177. // Model for the HelloWorld example
  178. .target(
  179. name: "HelloWorldModel",
  180. dependencies: [
  181. .target(name: "GRPC"),
  182. .product(name: "NIO", package: "swift-nio"),
  183. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  184. ],
  185. path: "Sources/Examples/HelloWorld/Model"
  186. ),
  187. // Client for the HelloWorld example
  188. .target(
  189. name: "HelloWorldClient",
  190. dependencies: [
  191. .target(name: "GRPC"),
  192. .target(name: "HelloWorldModel"),
  193. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  194. ],
  195. path: "Sources/Examples/HelloWorld/Client"
  196. ),
  197. // Server for the HelloWorld example
  198. .target(
  199. name: "HelloWorldServer",
  200. dependencies: [
  201. .target(name: "GRPC"),
  202. .product(name: "NIO", package: "swift-nio"),
  203. .target(name: "HelloWorldModel"),
  204. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  205. ],
  206. path: "Sources/Examples/HelloWorld/Server"
  207. ),
  208. // Model for the RouteGuide example
  209. .target(
  210. name: "RouteGuideModel",
  211. dependencies: [
  212. .target(name: "GRPC"),
  213. .product(name: "NIO", package: "swift-nio"),
  214. .product(name: "SwiftProtobuf", package: "SwiftProtobuf"),
  215. ],
  216. path: "Sources/Examples/RouteGuide/Model"
  217. ),
  218. // Client for the RouteGuide example
  219. .target(
  220. name: "RouteGuideClient",
  221. dependencies: [
  222. .target(name: "GRPC"),
  223. .target(name: "RouteGuideModel"),
  224. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  225. ],
  226. path: "Sources/Examples/RouteGuide/Client"
  227. ),
  228. // Server for the RouteGuide example
  229. .target(
  230. name: "RouteGuideServer",
  231. dependencies: [
  232. .target(name: "GRPC"),
  233. .product(name: "NIO", package: "swift-nio"),
  234. .target(name: "RouteGuideModel"),
  235. .product(name: "ArgumentParser", package: "swift-argument-parser"),
  236. ],
  237. path: "Sources/Examples/RouteGuide/Server"
  238. ),
  239. ]
  240. )