Package.swift 3.3 KB

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