Package@swift-4.2.swift 2.7 KB

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