Package.swift 7.4 KB

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