Package.swift 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // swift-tools-version:6.0
  2. /*
  3. * Copyright 2024, 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 CompilerPluginSupport
  18. import PackageDescription
  19. let products: [Product] = [
  20. .library(
  21. name: "GRPCCore",
  22. targets: ["GRPCCore"]
  23. ),
  24. .library(
  25. name: "GRPCCodeGen",
  26. targets: ["GRPCCodeGen"]
  27. ),
  28. .library(
  29. name: "GRPCInProcessTransport",
  30. targets: ["GRPCInProcessTransport"]
  31. ),
  32. ]
  33. let dependencies: [Package.Dependency] = [
  34. .package(
  35. url: "https://github.com/apple/swift-collections.git",
  36. from: "1.1.3"
  37. ),
  38. // Test-only dependencies:
  39. .package(
  40. url: "https://github.com/apple/swift-protobuf.git",
  41. from: "1.28.1"
  42. ),
  43. ]
  44. // -------------------------------------------------------------------------------------------------
  45. // This adds some build settings which allow us to map "@available(gRPCSwift 2.x, *)" to
  46. // the appropriate OS platforms.
  47. let nextMinorVersion = 2
  48. let availabilitySettings: [SwiftSetting] = (0 ... nextMinorVersion).map { minor in
  49. let name = "gRPCSwift"
  50. let version = "2.\(minor)"
  51. let platforms = "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"
  52. let setting = "AvailabilityMacro=\(name) \(version):\(platforms)"
  53. return .enableExperimentalFeature(setting)
  54. }
  55. let defaultSwiftSettings: [SwiftSetting] =
  56. availabilitySettings + [
  57. .swiftLanguageMode(.v6),
  58. .enableUpcomingFeature("ExistentialAny"),
  59. .enableUpcomingFeature("InternalImportsByDefault"),
  60. .enableUpcomingFeature("MemberImportVisibility"),
  61. ]
  62. // -------------------------------------------------------------------------------------------------
  63. let targets: [Target] = [
  64. // Runtime serialization components
  65. .target(
  66. name: "GRPCCore",
  67. dependencies: [
  68. .product(name: "DequeModule", package: "swift-collections")
  69. ],
  70. swiftSettings: defaultSwiftSettings
  71. ),
  72. .testTarget(
  73. name: "GRPCCoreTests",
  74. dependencies: [
  75. .target(name: "GRPCCore"),
  76. .target(name: "GRPCInProcessTransport"),
  77. .product(name: "SwiftProtobuf", package: "swift-protobuf"),
  78. ],
  79. resources: [
  80. .copy("Configuration/Inputs")
  81. ],
  82. swiftSettings: defaultSwiftSettings
  83. ),
  84. // In-process client and server transport implementations
  85. .target(
  86. name: "GRPCInProcessTransport",
  87. dependencies: [
  88. .target(name: "GRPCCore")
  89. ],
  90. swiftSettings: defaultSwiftSettings
  91. ),
  92. .testTarget(
  93. name: "GRPCInProcessTransportTests",
  94. dependencies: [
  95. .target(name: "GRPCInProcessTransport")
  96. ],
  97. swiftSettings: defaultSwiftSettings
  98. ),
  99. // Code generator library for protoc-gen-grpc-swift
  100. .target(
  101. name: "GRPCCodeGen",
  102. dependencies: [],
  103. swiftSettings: defaultSwiftSettings
  104. ),
  105. .testTarget(
  106. name: "GRPCCodeGenTests",
  107. dependencies: [
  108. .target(name: "GRPCCodeGen")
  109. ],
  110. swiftSettings: defaultSwiftSettings
  111. ),
  112. ]
  113. let package = Package(
  114. name: "grpc-swift",
  115. products: products,
  116. dependencies: dependencies,
  117. targets: targets
  118. )