Package.swift 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // swift-tools-version:5.0
  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. import Foundation
  19. var packageDependencies: [Package.Dependency] = [
  20. // Official SwiftProtobuf library, for [de]serializing data to send on the wire.
  21. .package(url: "https://github.com/apple/swift-protobuf.git", .upToNextMajor(from: "1.3.1")),
  22. // Command line argument parser for our auxiliary command line tools.
  23. .package(url: "https://github.com/kylef/Commander.git", .upToNextMinor(from: "0.8.0")),
  24. // SwiftGRPCNIO dependencies:
  25. // Transitive dependencies
  26. .package(url: "https://github.com/apple/swift-nio-zlib-support.git", .upToNextMajor(from: "1.0.0")),
  27. // Main SwiftNIO package
  28. .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
  29. // HTTP2 via SwiftNIO
  30. .package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.0.0"),
  31. // TLS via SwiftNIO
  32. .package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.0.0"),
  33. ]
  34. var cGRPCDependencies: [Target.Dependency] = []
  35. #if os(Linux)
  36. let isLinux = true
  37. #else
  38. let isLinux = false
  39. #endif
  40. // On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
  41. // See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
  42. // swift build doesn't pass -Xswiftc flags to dependencies, so here using an environment variable
  43. // is easiest.
  44. if isLinux || ProcessInfo.processInfo.environment.keys.contains("GRPC_USE_OPENSSL") {
  45. packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
  46. } else {
  47. cGRPCDependencies.append("BoringSSL")
  48. }
  49. let package = Package(
  50. name: "SwiftGRPC",
  51. products: [
  52. .library(name: "SwiftGRPC", targets: ["SwiftGRPC"]),
  53. .library(name: "SwiftGRPCNIO", targets: ["SwiftGRPCNIO"]),
  54. ],
  55. dependencies: packageDependencies,
  56. targets: [
  57. .target(name: "SwiftGRPC",
  58. dependencies: ["CgRPC", "SwiftProtobuf"]),
  59. .target(name: "SwiftGRPCNIO",
  60. dependencies: [
  61. "NIO",
  62. "NIOFoundationCompat",
  63. "NIOHTTP1",
  64. "NIOHTTP2",
  65. "NIOSSL",
  66. "SwiftProtobuf"]),
  67. .target(name: "CgRPC",
  68. dependencies: cGRPCDependencies),
  69. .target(name: "RootsEncoder"),
  70. .target(name: "protoc-gen-swiftgrpc",
  71. dependencies: [
  72. "SwiftProtobuf",
  73. "SwiftProtobufPluginLibrary",
  74. "protoc-gen-swift"]),
  75. .target(name: "BoringSSL"),
  76. .target(name: "Echo",
  77. dependencies: [
  78. "SwiftGRPC",
  79. "SwiftProtobuf",
  80. "Commander"],
  81. path: "Sources/Examples/Echo"),
  82. .target(name: "EchoNIO",
  83. dependencies: [
  84. "SwiftGRPCNIO",
  85. "SwiftGRPCNIOSampleData",
  86. "SwiftProtobuf",
  87. "Commander"],
  88. path: "Sources/Examples/EchoNIO"),
  89. .target(name: "SwiftGRPCNIOInteroperabilityTests",
  90. dependencies: ["SwiftGRPCNIO"]),
  91. .target(name: "SwiftGRPCNIOInteroperabilityTestsCLI",
  92. dependencies: [
  93. "SwiftGRPCNIOInteroperabilityTests",
  94. "Commander"]),
  95. .target(name: "Simple",
  96. dependencies: ["SwiftGRPC", "Commander"],
  97. path: "Sources/Examples/Simple"),
  98. .target(name: "SwiftGRPCNIOSampleData",
  99. dependencies: ["NIOSSL"]),
  100. .testTarget(name: "SwiftGRPCTests",
  101. dependencies: ["SwiftGRPC"]),
  102. .testTarget(name: "SwiftGRPCNIOTests",
  103. dependencies: [
  104. "SwiftGRPC",
  105. "SwiftGRPCNIO",
  106. "SwiftGRPCNIOSampleData",
  107. "SwiftGRPCNIOInteroperabilityTests"]),
  108. ],
  109. cLanguageStandard: .gnu11,
  110. cxxLanguageStandard: .cxx11)