Package.swift 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // swift-tools-version:4.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. 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.5.0")),
  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. .package(url: "https://github.com/apple/swift-nio-nghttp2-support.git", .upToNextMajor(from: "1.0.0")),
  28. // Main SwiftNIO package
  29. .package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "1.12.0")),
  30. // HTTP2 via SwiftNIO
  31. .package(url: "https://github.com/apple/swift-nio-http2.git", .upToNextMinor(from: "0.2.1"))
  32. ]
  33. var cGRPCDependencies: [Target.Dependency] = []
  34. #if os(Linux)
  35. let isLinux = true
  36. #else
  37. let isLinux = false
  38. #endif
  39. // On Linux, Foundation links with openssl, so we'll need to use that instead of BoringSSL.
  40. // See https://github.com/apple/swift-nio-ssl/issues/16#issuecomment-392705505 for details.
  41. // swift build doesn't pass -Xswiftc flags to dependencies, so here using an environment variable
  42. // is easiest.
  43. if isLinux || ProcessInfo.processInfo.environment.keys.contains("GRPC_USE_OPENSSL") {
  44. packageDependencies.append(.package(url: "https://github.com/apple/swift-nio-ssl-support.git", from: "1.0.0"))
  45. } else {
  46. cGRPCDependencies.append("BoringSSL")
  47. }
  48. let package = Package(
  49. name: "SwiftGRPC",
  50. products: [
  51. .library(name: "SwiftGRPC", targets: ["SwiftGRPC"]),
  52. .library(name: "SwiftGRPCNIO", targets: ["SwiftGRPCNIO"]),
  53. ],
  54. dependencies: packageDependencies,
  55. targets: [
  56. .target(name: "SwiftGRPC",
  57. dependencies: ["CgRPC", "SwiftProtobuf"]),
  58. .target(name: "SwiftGRPCNIO",
  59. dependencies: [
  60. "NIOFoundationCompat",
  61. "NIOHTTP1",
  62. "NIOHTTP2",
  63. "SwiftProtobuf"]),
  64. .target(name: "CgRPC",
  65. dependencies: cGRPCDependencies),
  66. .target(name: "RootsEncoder"),
  67. .target(name: "protoc-gen-swiftgrpc",
  68. dependencies: [
  69. "SwiftProtobuf",
  70. "SwiftProtobufPluginLibrary",
  71. "protoc-gen-swift"]),
  72. .target(name: "BoringSSL"),
  73. .target(name: "Echo",
  74. dependencies: [
  75. "SwiftGRPC",
  76. "SwiftProtobuf",
  77. "Commander"],
  78. path: "Sources/Examples/Echo"),
  79. .target(name: "EchoNIO",
  80. dependencies: [
  81. "SwiftGRPCNIO",
  82. "SwiftProtobuf",
  83. "Commander"],
  84. path: "Sources/Examples/EchoNIO"),
  85. .target(name: "Simple",
  86. dependencies: ["SwiftGRPC", "Commander"],
  87. path: "Sources/Examples/Simple"),
  88. .testTarget(name: "SwiftGRPCTests", dependencies: ["SwiftGRPC"]),
  89. .testTarget(name: "SwiftGRPCNIOTests", dependencies: ["SwiftGRPC", "SwiftGRPCNIO"])
  90. ],
  91. swiftLanguageVersions: [.v4, .v4_2, .version("5")],
  92. cLanguageStandard: .gnu11,
  93. cxxLanguageStandard: .cxx11)