Przeglądaj źródła

Swift 6-ify the package manifest (#1955)

Motivation:

v2 will require the Swift 6 language mode. In order to continue
developing v1 and v2 on main we'll need a Swift 6 specific manifest
version in addition to the 5.x version.

Moving forward we'll have two package manifests, `Package.swift` for 5.x
containing only v1, and `Package@swift-6.swift` using tools version 6.0
targetting v1 and v2.

Modifications:

- Remove v2 targets from Package.swift
- Add a second manifest and make it warning free with Swift 6, this
  requires turning `static let`s to `static var`s.
- Conditionalise some imports in `protoc-gen-grpc-swift` (as it is
  shared by v1 and v2)
- Fix an error in the plugin for Swift 6

Result:

v2 now only compiles with a Swift 6 compiler
George Barnett 1 rok temu
rodzic
commit
36ffcb49fd
28 zmienionych plików z 956 dodań i 360 usunięć
  1. 4 2
      .github/workflows/ci.yaml
  2. 0 255
      Package.swift
  3. 927 0
      Package@swift-6.swift
  4. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json
  5. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Add_string.p90.json
  6. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json
  7. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json
  8. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json
  9. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json
  10. 0 7
      Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json
  11. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json
  12. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Add_string.p90.json
  13. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json
  14. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json
  15. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json
  16. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json
  17. 0 7
      Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json
  18. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json
  19. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Add_string.p90.json
  20. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json
  21. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json
  22. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json
  23. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json
  24. 0 0
      Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json
  25. 3 3
      Plugins/GRPCSwiftPlugin/plugin.swift
  26. 13 2
      Sources/protoc-gen-grpc-swift/main.swift
  27. 4 0
      Sources/protoc-gen-grpc-swift/options.swift
  28. 5 0
      scripts/license-check.sh

+ 4 - 2
.github/workflows/ci.yaml

@@ -61,7 +61,7 @@ jobs:
       matrix:
         include:
           - image: swiftlang/swift:nightly-jammy
-            swift-version: main
+            swift-version: 'main'
             env:
               MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 323000
               MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 161000
@@ -72,7 +72,7 @@ jobs:
               MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_client: 170000
               MAX_ALLOCS_ALLOWED_unary_1k_ping_pong_interceptors_server: 170000
           - image: swiftlang/swift:nightly-6.0-jammy
-            swift-version: main
+            swift-version: '6.0'
             env:
               MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_10_requests: 323000
               MAX_ALLOCS_ALLOWED_bidi_1k_rpcs_1_request: 161000
@@ -126,9 +126,11 @@ jobs:
       env: ${{ matrix.env }}
       timeout-minutes: 20
     - name: Install jemalloc for benchmarking
+      if: ${{ matrix.swift-version == '6.0' || matrix.swift-version == 'main' }}
       run: apt update && apt-get install -y libjemalloc-dev
       timeout-minutes: 20
     - name: Run Benchmarks
+      if: ${{ matrix.swift-version == '6.0' || matrix.swift-version == 'main' }}
       working-directory: ./Performance/Benchmarks
       run: swift package benchmark baseline check --no-progress --check-absolute-path Thresholds/${{ matrix.swift-version }}/
       timeout-minutes: 20

+ 0 - 255
Package.swift

@@ -50,10 +50,6 @@ let packageDependencies: [Package.Dependency] = [
     url: "https://github.com/apple/swift-collections.git",
     from: "1.0.5"
   ),
-  .package(
-    url: "https://github.com/apple/swift-atomics.git",
-    from: "1.2.0"
-  ),
   .package(
     url: "https://github.com/apple/swift-protobuf.git",
     from: "1.20.2"
@@ -68,14 +64,6 @@ let packageDependencies: [Package.Dependency] = [
     // version and indluded async support.
     from: "1.1.1"
   ),
-  .package(
-    url: "https://github.com/apple/swift-docc-plugin",
-    from: "1.0.0"
-  ),
-  .package(
-    url: "https://github.com/apple/swift-distributed-tracing.git",
-    from: "1.0.0"
-  ),
 ].appending(
   .package(
     url: "https://github.com/apple/swift-nio-ssl.git",
@@ -91,11 +79,7 @@ extension Target.Dependency {
   static let grpc: Self = .target(name: grpcTargetName)
   static let cgrpcZlib: Self = .target(name: cgrpcZlibTargetName)
   static let protocGenGRPCSwift: Self = .target(name: "protoc-gen-grpc-swift")
-  static let performanceWorker: Self = .target(name: "performance-worker")
   static let reflectionService: Self = .target(name: "GRPCReflectionService")
-  static let grpcCodeGen: Self = .target(name: "GRPCCodeGen")
-  static let grpcProtobuf: Self = .target(name: "GRPCProtobuf")
-  static let grpcProtobufCodeGen: Self = .target(name: "GRPCProtobufCodeGen")
 
   // Target dependencies; internal
   static let grpcSampleData: Self = .target(name: "GRPCSampleData")
@@ -140,15 +124,6 @@ extension Target.Dependency {
     package: "swift-protobuf"
   )
   static let dequeModule: Self = .product(name: "DequeModule", package: "swift-collections")
-  static let atomics: Self = .product(name: "Atomics", package: "swift-atomics")
-  static let tracing: Self = .product(name: "Tracing", package: "swift-distributed-tracing")
-
-  static let grpcCore: Self = .target(name: "GRPCCore")
-  static let grpcInProcessTransport: Self = .target(name: "GRPCInProcessTransport")
-  static let grpcInterceptors: Self = .target(name: "GRPCInterceptors")
-  static let grpcHTTP2Core: Self = .target(name: "GRPCHTTP2Core")
-  static let grpcHTTP2TransportNIOPosix: Self = .target(name: "GRPCHTTP2TransportNIOPosix")
-  static let grpcHTTP2TransportNIOTransportServices: Self = .target(name: "GRPCHTTP2TransportNIOTransportServices")
 }
 
 // MARK: - Targets
@@ -177,63 +152,6 @@ extension Target {
     path: "Sources/GRPC"
   )
 
-  static let grpcCore: Target = .target(
-    name: "GRPCCore",
-    dependencies: [
-      .dequeModule,
-      .atomics
-    ],
-    path: "Sources/GRPCCore"
-  )
-
-  static let grpcInProcessTransport: Target = .target(
-    name: "GRPCInProcessTransport",
-    dependencies: [
-      .grpcCore
-    ]
-  )
-
-  static let grpcInterceptors: Target = .target(
-    name: "GRPCInterceptors",
-    dependencies: [
-      .grpcCore,
-      .tracing
-    ]
-  )
-
-  static let grpcHTTP2Core: Target = .target(
-    name: "GRPCHTTP2Core",
-    dependencies: [
-      .grpcCore,
-      .nioCore,
-      .nioHTTP2,
-      .cgrpcZlib,
-      .dequeModule,
-      .atomics
-    ]
-  )
-
-  static let grpcHTTP2TransportNIOPosix: Target = .target(
-    name: "GRPCHTTP2TransportNIOPosix",
-    dependencies: [
-      .grpcCore,
-      .grpcHTTP2Core,
-      .nioPosix,
-      .nioExtras
-    ]
-  )
-
-  static let grpcHTTP2TransportNIOTransportServices: Target = .target(
-    name: "GRPCHTTP2TransportNIOTransportServices",
-    dependencies: [
-      .grpcCore,
-      .grpcHTTP2Core,
-      .nioCore,
-      .nioExtras,
-      .nioTransportServices
-    ]
-  )
-
   static let cgrpcZlib: Target = .target(
     name: cgrpcZlibTargetName,
     path: "Sources/CGRPCZlib",
@@ -247,27 +165,12 @@ extension Target {
     dependencies: [
       .protobuf,
       .protobufPluginLibrary,
-      .grpcCodeGen,
-      .grpcProtobufCodeGen
     ],
     exclude: [
       "README.md",
     ]
   )
 
-  static let performanceWorker: Target = .executableTarget(
-    name: "performance-worker",
-    dependencies: [
-      .grpcCore,
-      .grpcHTTP2Core,
-      .grpcHTTP2TransportNIOPosix,
-      .grpcProtobuf,
-      .nioCore,
-      .nioFileSystem,
-      .argumentParser
-    ]
-  )
-
   static let grpcSwiftPlugin: Target = .plugin(
     name: "GRPCSwiftPlugin",
     capability: .buildTool(),
@@ -304,91 +207,6 @@ extension Target {
     ]
   )
 
-  static let grpcCoreTests: Target = .testTarget(
-    name: "GRPCCoreTests",
-    dependencies: [
-      .grpcCore,
-      .grpcInProcessTransport,
-      .dequeModule,
-      .atomics,
-      .protobuf,
-    ]
-  )
-
-  static let grpcInProcessTransportTests: Target = .testTarget(
-    name: "GRPCInProcessTransportTests",
-    dependencies: [
-      .grpcCore,
-      .grpcInProcessTransport
-    ]
-  )
-
-  static let grpcInterceptorsTests: Target = .testTarget(
-    name: "GRPCInterceptorsTests",
-    dependencies: [
-      .grpcCore,
-      .tracing,
-      .nioCore,
-      .grpcInterceptors
-    ]
-  )
-
-  static let grpcHTTP2CoreTests: Target = .testTarget(
-    name: "GRPCHTTP2CoreTests",
-    dependencies: [
-      .grpcHTTP2Core,
-      .nioCore,
-      .nioHTTP2,
-      .nioEmbedded,
-      .nioTestUtils,
-    ]
-  )
-
-  static let grpcHTTP2TransportTests: Target = .testTarget(
-    name: "GRPCHTTP2TransportTests",
-    dependencies: [
-      .grpcHTTP2Core,
-      .grpcHTTP2TransportNIOPosix,
-      .grpcHTTP2TransportNIOTransportServices,
-      .grpcProtobuf
-    ]
-  )
-
-  static let grpcCodeGenTests: Target = .testTarget(
-    name: "GRPCCodeGenTests",
-    dependencies: [
-      .grpcCodeGen
-    ]
-  )
-
-  static let grpcProtobufTests: Target = .testTarget(
-    name: "GRPCProtobufTests",
-    dependencies: [
-      .grpcProtobuf,
-      .grpcCore,
-      .protobuf
-    ]
-  )
-
-  static let grpcProtobufCodeGenTests: Target = .testTarget(
-    name: "GRPCProtobufCodeGenTests",
-    dependencies: [
-      .grpcCodeGen,
-      .grpcProtobufCodeGen,
-      .protobuf,
-      .protobufPluginLibrary
-    ]
-  )
-
-  static let inProcessInteroperabilityTests: Target = .testTarget(
-    name: "InProcessInteroperabilityTests",
-    dependencies: [
-      .grpcInProcessTransport,
-      .interoperabilityTests,
-      .grpcCore
-    ]
-  )
-
   static let interopTestModels: Target = .target(
     name: "GRPCInteroperabilityTestModels",
     dependencies: [
@@ -407,25 +225,6 @@ extension Target {
     ]
   )
 
-  static let interoperabilityTestImplementation: Target = .target(
-    name: "InteroperabilityTests",
-    dependencies: [
-      .grpcCore,
-      .grpcProtobuf
-    ]
-  )
-
-  static let interoperabilityTestsExecutable: Target = .executableTarget(
-    name: "interoperability-tests",
-    dependencies: [
-      .grpcCore,
-      .grpcHTTP2Core,
-      .grpcHTTP2TransportNIOPosix,
-      .interoperabilityTests,
-      .argumentParser
-    ]
-  )
-
   static let interopTestImplementation: Target = .target(
     name: "GRPCInteroperabilityTestsImplementation",
     dependencies: [
@@ -639,29 +438,6 @@ extension Target {
       .copy("Generated")
     ]
   )
-
-  static let grpcCodeGen: Target = .target(
-    name: "GRPCCodeGen",
-    path: "Sources/GRPCCodeGen"
-  )
-
-  static let grpcProtobuf: Target = .target(
-    name: "GRPCProtobuf",
-    dependencies: [
-      .grpcCore,
-      .protobuf,
-    ],
-    path: "Sources/GRPCProtobuf"
-  )
-  static let grpcProtobufCodeGen: Target = .target(
-    name: "GRPCProtobufCodeGen",
-    dependencies: [
-      .protobuf,
-      .protobufPluginLibrary,
-      .grpcCodeGen
-    ],
-    path: "Sources/GRPCProtobufCodeGen"
-  )
 }
 
 // MARK: - Products
@@ -672,11 +448,6 @@ extension Product {
     targets: [grpcTargetName]
   )
 
-  static let grpcCore: Product = .library(
-    name: "_GRPCCore",
-    targets: ["GRPCCore"]
-  )
-
   static let cgrpcZlib: Product = .library(
     name: cgrpcZlibProductName,
     targets: [cgrpcZlibTargetName]
@@ -704,7 +475,6 @@ let package = Package(
   name: grpcPackageName,
   products: [
     .grpc,
-    .grpcCore,
     .cgrpcZlib,
     .grpcReflectionService,
     .protocGenGRPCSwift,
@@ -740,31 +510,6 @@ let package = Package(
     .routeGuideServer,
     .packetCapture,
     .reflectionServer,
-
-    // v2
-    .grpcCore,
-    .grpcInProcessTransport,
-    .grpcCodeGen,
-    .grpcInterceptors,
-    .grpcHTTP2Core,
-    .grpcHTTP2TransportNIOPosix,
-    .grpcHTTP2TransportNIOTransportServices,
-    .grpcProtobuf,
-    .grpcProtobufCodeGen,
-    .interoperabilityTestImplementation,
-    .interoperabilityTestsExecutable,
-    .performanceWorker,
-
-    // v2 tests
-    .grpcCoreTests,
-    .grpcInProcessTransportTests,
-    .grpcCodeGenTests,
-    .grpcInterceptorsTests,
-    .grpcHTTP2CoreTests,
-    .grpcHTTP2TransportTests,
-    .grpcProtobufTests,
-    .grpcProtobufCodeGenTests,
-    .inProcessInteroperabilityTests
   ]
 )
 

+ 927 - 0
Package@swift-6.swift

@@ -0,0 +1,927 @@
+// swift-tools-version:6.0
+/*
+ * Copyright 2024, gRPC Authors All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import PackageDescription
+// swiftformat puts the next import before the tools version.
+// swiftformat:disable:next sortImports
+import class Foundation.ProcessInfo
+
+let grpcPackageName = "grpc-swift"
+let grpcProductName = "GRPC"
+let cgrpcZlibProductName = "CGRPCZlib"
+let grpcTargetName = grpcProductName
+let cgrpcZlibTargetName = cgrpcZlibProductName
+
+let includeNIOSSL = ProcessInfo.processInfo.environment["GRPC_NO_NIO_SSL"] == nil
+
+// MARK: - Package Dependencies
+
+let packageDependencies: [Package.Dependency] = [
+  .package(
+    url: "https://github.com/apple/swift-nio.git",
+    from: "2.65.0"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-nio-http2.git",
+    from: "1.32.0"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-nio-transport-services.git",
+    from: "1.15.0"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-nio-extras.git",
+    from: "1.4.0"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-collections.git",
+    from: "1.0.5"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-atomics.git",
+    from: "1.2.0"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-protobuf.git",
+    from: "1.20.2"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-log.git",
+    from: "1.4.4"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-argument-parser.git",
+    // Version is higher than in other Package@swift manifests: 1.1.0 raised the minimum Swift
+    // version and indluded async support.
+    from: "1.1.1"
+  ),
+  .package(
+    url: "https://github.com/apple/swift-distributed-tracing.git",
+    from: "1.0.0"
+  ),
+].appending(
+  .package(
+    url: "https://github.com/apple/swift-nio-ssl.git",
+    from: "2.23.0"
+  ),
+  if: includeNIOSSL
+)
+
+// MARK: - Target Dependencies
+
+extension Target.Dependency {
+  // Target dependencies; external
+  static var grpc: Self { .target(name: grpcTargetName) }
+  static var cgrpcZlib: Self { .target(name: cgrpcZlibTargetName) }
+  static var protocGenGRPCSwift: Self { .target(name: "protoc-gen-grpc-swift") }
+  static var performanceWorker: Self { .target(name: "performance-worker") }
+  static var reflectionService: Self { .target(name: "GRPCReflectionService") }
+  static var grpcCodeGen: Self { .target(name: "GRPCCodeGen") }
+  static var grpcProtobuf: Self { .target(name: "GRPCProtobuf") }
+  static var grpcProtobufCodeGen: Self { .target(name: "GRPCProtobufCodeGen") }
+
+  // Target dependencies; internal
+  static var grpcSampleData: Self { .target(name: "GRPCSampleData") }
+  static var echoModel: Self { .target(name: "EchoModel") }
+  static var echoImplementation: Self { .target(name: "EchoImplementation") }
+  static var helloWorldModel: Self { .target(name: "HelloWorldModel") }
+  static var routeGuideModel: Self { .target(name: "RouteGuideModel") }
+  static var interopTestModels: Self { .target(name: "GRPCInteroperabilityTestModels") }
+  static var interopTestImplementation: Self {
+    .target(name: "GRPCInteroperabilityTestsImplementation")
+  }
+  static var interoperabilityTests: Self { .target(name: "InteroperabilityTests") }
+
+  // Product dependencies
+  static var argumentParser: Self {
+    .product(
+      name: "ArgumentParser",
+      package: "swift-argument-parser"
+    )
+  }
+  static var nio: Self { .product(name: "NIO", package: "swift-nio") }
+  static var nioConcurrencyHelpers: Self {
+    .product(
+      name: "NIOConcurrencyHelpers",
+      package: "swift-nio"
+    )
+  }
+  static var nioCore: Self { .product(name: "NIOCore", package: "swift-nio") }
+  static var nioEmbedded: Self { .product(name: "NIOEmbedded", package: "swift-nio") }
+  static var nioExtras: Self { .product(name: "NIOExtras", package: "swift-nio-extras") }
+  static var nioFoundationCompat: Self { .product(name: "NIOFoundationCompat", package: "swift-nio") }
+  static var nioHTTP1: Self { .product(name: "NIOHTTP1", package: "swift-nio") }
+  static var nioHTTP2: Self { .product(name: "NIOHTTP2", package: "swift-nio-http2") }
+  static var nioPosix: Self { .product(name: "NIOPosix", package: "swift-nio") }
+  static var nioSSL: Self { .product(name: "NIOSSL", package: "swift-nio-ssl") }
+  static var nioTLS: Self { .product(name: "NIOTLS", package: "swift-nio") }
+  static var nioTransportServices: Self {
+    .product(
+      name: "NIOTransportServices",
+      package: "swift-nio-transport-services"
+    )
+  }
+  static var nioTestUtils: Self { .product(name: "NIOTestUtils", package: "swift-nio") }
+  static var nioFileSystem: Self { .product(name: "_NIOFileSystem", package: "swift-nio") }
+  static var logging: Self { .product(name: "Logging", package: "swift-log") }
+  static var protobuf: Self { .product(name: "SwiftProtobuf", package: "swift-protobuf") }
+  static var protobufPluginLibrary: Self {
+    .product(
+      name: "SwiftProtobufPluginLibrary",
+      package: "swift-protobuf"
+    )
+  }
+  static var dequeModule: Self { .product(name: "DequeModule", package: "swift-collections") }
+  static var atomics: Self { .product(name: "Atomics", package: "swift-atomics") }
+  static var tracing: Self { .product(name: "Tracing", package: "swift-distributed-tracing") }
+
+  static var grpcCore: Self { .target(name: "GRPCCore") }
+  static var grpcInProcessTransport: Self { .target(name: "GRPCInProcessTransport") }
+  static var grpcInterceptors: Self { .target(name: "GRPCInterceptors") }
+  static var grpcHTTP2Core: Self { .target(name: "GRPCHTTP2Core") }
+  static var grpcHTTP2TransportNIOPosix: Self { .target(name: "GRPCHTTP2TransportNIOPosix") }
+  static var grpcHTTP2TransportNIOTransportServices: Self { .target(name: "GRPCHTTP2TransportNIOTransportServices") }
+}
+
+// MARK: - Targets
+
+extension Target {
+  static var grpc: Target {
+    .target(
+      name: grpcTargetName,
+      dependencies: [
+        .cgrpcZlib,
+        .nio,
+        .nioCore,
+        .nioPosix,
+        .nioEmbedded,
+        .nioFoundationCompat,
+        .nioTLS,
+        .nioTransportServices,
+        .nioHTTP1,
+        .nioHTTP2,
+        .nioExtras,
+        .logging,
+        .protobuf,
+        .dequeModule,
+      ].appending(
+        .nioSSL, if: includeNIOSSL
+      ),
+      path: "Sources/GRPC",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcCore: Target {
+    .target(
+      name: "GRPCCore",
+      dependencies: [
+        .dequeModule,
+        .atomics
+      ],
+      path: "Sources/GRPCCore",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcInProcessTransport: Target {
+    .target(
+      name: "GRPCInProcessTransport",
+      dependencies: [
+        .grpcCore
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcInterceptors: Target {
+    .target(
+      name: "GRPCInterceptors",
+      dependencies: [
+        .grpcCore,
+        .tracing
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcHTTP2Core: Target {
+    .target(
+      name: "GRPCHTTP2Core",
+      dependencies: [
+        .grpcCore,
+        .nioCore,
+        .nioHTTP2,
+        .cgrpcZlib,
+        .dequeModule,
+        .atomics
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcHTTP2TransportNIOPosix: Target {
+    .target(
+      name: "GRPCHTTP2TransportNIOPosix",
+      dependencies: [
+        .grpcCore,
+        .grpcHTTP2Core,
+        .nioPosix,
+        .nioExtras
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcHTTP2TransportNIOTransportServices: Target {
+    .target(
+      name: "GRPCHTTP2TransportNIOTransportServices",
+      dependencies: [
+        .grpcCore,
+        .grpcHTTP2Core,
+        .nioCore,
+        .nioExtras,
+        .nioTransportServices
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var cgrpcZlib: Target {
+    .target(
+      name: cgrpcZlibTargetName,
+      path: "Sources/CGRPCZlib",
+      linkerSettings: [
+        .linkedLibrary("z"),
+      ]
+    )
+  }
+
+  static var protocGenGRPCSwift: Target {
+    .executableTarget(
+      name: "protoc-gen-grpc-swift",
+      dependencies: [
+        .protobuf,
+        .protobufPluginLibrary,
+        .grpcCodeGen,
+        .grpcProtobufCodeGen
+      ],
+      exclude: [
+        "README.md",
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var performanceWorker: Target {
+    .executableTarget(
+      name: "performance-worker",
+      dependencies: [
+        .grpcCore,
+        .grpcHTTP2Core,
+        .grpcHTTP2TransportNIOPosix,
+        .grpcProtobuf,
+        .nioCore,
+        .nioFileSystem,
+        .argumentParser
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcSwiftPlugin: Target {
+    .plugin(
+      name: "GRPCSwiftPlugin",
+      capability: .buildTool(),
+      dependencies: [
+        .protocGenGRPCSwift,
+      ]
+    )
+  }
+
+  static var grpcTests: Target {
+    .testTarget(
+      name: "GRPCTests",
+      dependencies: [
+        .grpc,
+        .echoModel,
+        .echoImplementation,
+        .helloWorldModel,
+        .interopTestModels,
+        .interopTestImplementation,
+        .grpcSampleData,
+        .nioCore,
+        .nioConcurrencyHelpers,
+        .nioPosix,
+        .nioTLS,
+        .nioHTTP1,
+        .nioHTTP2,
+        .nioEmbedded,
+        .nioTransportServices,
+        .logging,
+        .reflectionService
+      ].appending(
+        .nioSSL, if: includeNIOSSL
+      ),
+      exclude: [
+        "Codegen/Serialization/echo.grpc.reflection"
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcCoreTests: Target {
+    .testTarget(
+      name: "GRPCCoreTests",
+      dependencies: [
+        .grpcCore,
+        .grpcInProcessTransport,
+        .dequeModule,
+        .atomics,
+        .protobuf,
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcInProcessTransportTests: Target {
+    .testTarget(
+      name: "GRPCInProcessTransportTests",
+      dependencies: [
+        .grpcCore,
+        .grpcInProcessTransport
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcInterceptorsTests: Target {
+    .testTarget(
+      name: "GRPCInterceptorsTests",
+      dependencies: [
+        .grpcCore,
+        .tracing,
+        .nioCore,
+        .grpcInterceptors
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcHTTP2CoreTests: Target {
+    .testTarget(
+      name: "GRPCHTTP2CoreTests",
+      dependencies: [
+        .grpcHTTP2Core,
+        .nioCore,
+        .nioHTTP2,
+        .nioEmbedded,
+        .nioTestUtils,
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcHTTP2TransportTests: Target {
+    .testTarget(
+      name: "GRPCHTTP2TransportTests",
+      dependencies: [
+        .grpcHTTP2Core,
+        .grpcHTTP2TransportNIOPosix,
+        .grpcHTTP2TransportNIOTransportServices,
+        .grpcProtobuf
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcCodeGenTests: Target {
+    .testTarget(
+      name: "GRPCCodeGenTests",
+      dependencies: [
+        .grpcCodeGen
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcProtobufTests: Target {
+    .testTarget(
+      name: "GRPCProtobufTests",
+      dependencies: [
+        .grpcProtobuf,
+        .grpcCore,
+        .protobuf
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcProtobufCodeGenTests: Target {
+    .testTarget(
+      name: "GRPCProtobufCodeGenTests",
+      dependencies: [
+        .grpcCodeGen,
+        .grpcProtobufCodeGen,
+        .protobuf,
+        .protobufPluginLibrary
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var inProcessInteroperabilityTests: Target {
+    .testTarget(
+      name: "InProcessInteroperabilityTests",
+      dependencies: [
+        .grpcInProcessTransport,
+        .interoperabilityTests,
+        .grpcCore
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var interopTestModels: Target {
+    .target(
+      name: "GRPCInteroperabilityTestModels",
+      dependencies: [
+        .grpc,
+        .nio,
+        .protobuf,
+      ],
+      exclude: [
+        "README.md",
+        "generate.sh",
+        "src/proto/grpc/testing/empty.proto",
+        "src/proto/grpc/testing/empty_service.proto",
+        "src/proto/grpc/testing/messages.proto",
+        "src/proto/grpc/testing/test.proto",
+        "unimplemented_call.patch",
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var interoperabilityTestImplementation: Target {
+    .target(
+      name: "InteroperabilityTests",
+      dependencies: [
+        .grpcCore,
+        .grpcProtobuf
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var interoperabilityTestsExecutable: Target {
+    .executableTarget(
+      name: "interoperability-tests",
+      dependencies: [
+        .grpcCore,
+        .grpcHTTP2Core,
+        .grpcHTTP2TransportNIOPosix,
+        .interoperabilityTests,
+        .argumentParser
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var interopTestImplementation: Target {
+    .target(
+      name: "GRPCInteroperabilityTestsImplementation",
+      dependencies: [
+        .grpc,
+        .interopTestModels,
+        .nioCore,
+        .nioPosix,
+        .nioHTTP1,
+        .logging,
+      ].appending(
+        .nioSSL, if: includeNIOSSL
+      ),
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var interopTests: Target {
+    .executableTarget(
+      name: "GRPCInteroperabilityTests",
+      dependencies: [
+        .grpc,
+        .interopTestImplementation,
+        .nioCore,
+        .nioPosix,
+        .logging,
+        .argumentParser,
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var backoffInteropTest: Target {
+    .executableTarget(
+      name: "GRPCConnectionBackoffInteropTest",
+      dependencies: [
+        .grpc,
+        .interopTestModels,
+        .nioCore,
+        .nioPosix,
+        .logging,
+        .argumentParser,
+      ],
+      exclude: [
+        "README.md",
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var perfTests: Target {
+    .executableTarget(
+      name: "GRPCPerformanceTests",
+      dependencies: [
+        .grpc,
+        .grpcSampleData,
+        .nioCore,
+        .nioEmbedded,
+        .nioPosix,
+        .nioHTTP2,
+        .argumentParser,
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcSampleData: Target {
+    .target(
+      name: "GRPCSampleData",
+      dependencies: includeNIOSSL ? [.nioSSL] : [],
+      exclude: [
+        "bundle.p12",
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var echoModel: Target {
+    .target(
+      name: "EchoModel",
+      dependencies: [
+        .grpc,
+        .nio,
+        .protobuf,
+      ],
+      path: "Sources/Examples/Echo/Model",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var echoImplementation: Target {
+    .target(
+      name: "EchoImplementation",
+      dependencies: [
+        .echoModel,
+        .grpc,
+        .nioCore,
+        .nioHTTP2,
+        .protobuf,
+      ],
+      path: "Sources/Examples/Echo/Implementation",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var echo: Target {
+    .executableTarget(
+      name: "Echo",
+      dependencies: [
+        .grpc,
+        .echoModel,
+        .echoImplementation,
+        .grpcSampleData,
+        .nioCore,
+        .nioPosix,
+        .logging,
+        .argumentParser,
+      ].appending(
+        .nioSSL, if: includeNIOSSL
+      ),
+      path: "Sources/Examples/Echo/Runtime",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var helloWorldModel: Target {
+    .target(
+      name: "HelloWorldModel",
+      dependencies: [
+        .grpc,
+        .nio,
+        .protobuf,
+      ],
+      path: "Sources/Examples/HelloWorld/Model",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var helloWorldClient: Target {
+    .executableTarget(
+      name: "HelloWorldClient",
+      dependencies: [
+        .grpc,
+        .helloWorldModel,
+        .nioCore,
+        .nioPosix,
+        .argumentParser,
+      ],
+      path: "Sources/Examples/HelloWorld/Client",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var helloWorldServer: Target {
+    .executableTarget(
+      name: "HelloWorldServer",
+      dependencies: [
+        .grpc,
+        .helloWorldModel,
+        .nioCore,
+        .nioPosix,
+        .argumentParser,
+      ],
+      path: "Sources/Examples/HelloWorld/Server",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var routeGuideModel: Target {
+    .target(
+      name: "RouteGuideModel",
+      dependencies: [
+        .grpc,
+        .nio,
+        .protobuf,
+      ],
+      path: "Sources/Examples/RouteGuide/Model",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var routeGuideClient: Target {
+    .executableTarget(
+      name: "RouteGuideClient",
+      dependencies: [
+        .grpc,
+        .routeGuideModel,
+        .nioCore,
+        .nioPosix,
+        .argumentParser,
+      ],
+      path: "Sources/Examples/RouteGuide/Client",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var routeGuideServer: Target {
+    .executableTarget(
+      name: "RouteGuideServer",
+      dependencies: [
+        .grpc,
+        .routeGuideModel,
+        .nioCore,
+        .nioConcurrencyHelpers,
+        .nioPosix,
+        .argumentParser,
+      ],
+      path: "Sources/Examples/RouteGuide/Server",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var packetCapture: Target {
+    .executableTarget(
+      name: "PacketCapture",
+      dependencies: [
+        .grpc,
+        .echoModel,
+        .nioCore,
+        .nioPosix,
+        .nioExtras,
+        .argumentParser,
+      ],
+      path: "Sources/Examples/PacketCapture",
+      exclude: [
+        "README.md",
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var reflectionService: Target {
+    .target(
+      name: "GRPCReflectionService",
+      dependencies: [
+        .grpc,
+        .nio,
+        .protobuf,
+      ],
+      path: "Sources/GRPCReflectionService",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var reflectionServer: Target {
+    .executableTarget(
+      name: "ReflectionServer",
+      dependencies: [
+        .grpc,
+        .reflectionService,
+        .helloWorldModel,
+        .nioCore,
+        .nioPosix,
+        .argumentParser,
+        .echoModel,
+        .echoImplementation
+      ],
+      path: "Sources/Examples/ReflectionService",
+      resources: [
+        .copy("Generated")
+      ],
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcCodeGen: Target {
+    .target(
+      name: "GRPCCodeGen",
+      path: "Sources/GRPCCodeGen",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcProtobuf: Target {
+    .target(
+      name: "GRPCProtobuf",
+      dependencies: [
+        .grpcCore,
+        .protobuf,
+      ],
+      path: "Sources/GRPCProtobuf",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+
+  static var grpcProtobufCodeGen: Target {
+    .target(
+      name: "GRPCProtobufCodeGen",
+      dependencies: [
+        .protobuf,
+        .protobufPluginLibrary,
+        .grpcCodeGen
+      ],
+      path: "Sources/GRPCProtobufCodeGen",
+      swiftSettings: [.swiftLanguageVersion(.v5)]
+    )
+  }
+}
+
+// MARK: - Products
+
+extension Product {
+  static var grpc: Product {
+    .library(
+      name: grpcProductName,
+      targets: [grpcTargetName]
+    )
+  }
+
+  static var grpcCore: Product {
+    .library(
+      name: "_GRPCCore",
+      targets: ["GRPCCore"]
+    )
+  }
+
+  static var cgrpcZlib: Product {
+    .library(
+      name: cgrpcZlibProductName,
+      targets: [cgrpcZlibTargetName]
+    )
+  }
+
+  static var grpcReflectionService: Product {
+    .library(
+      name: "GRPCReflectionService",
+      targets: ["GRPCReflectionService"]
+    )
+  }
+
+  static var protocGenGRPCSwift: Product {
+    .executable(
+      name: "protoc-gen-grpc-swift",
+      targets: ["protoc-gen-grpc-swift"]
+    )
+  }
+
+  static var grpcSwiftPlugin: Product {
+    .plugin(
+      name: "GRPCSwiftPlugin",
+      targets: ["GRPCSwiftPlugin"]
+    )
+  }
+}
+
+// MARK: - Package
+
+let package = Package(
+  name: grpcPackageName,
+  products: [
+    .grpc,
+    .grpcCore,
+    .cgrpcZlib,
+    .grpcReflectionService,
+    .protocGenGRPCSwift,
+    .grpcSwiftPlugin,
+  ],
+  dependencies: packageDependencies,
+  targets: [
+    // Products
+    .grpc,
+    .cgrpcZlib,
+    .protocGenGRPCSwift,
+    .grpcSwiftPlugin,
+    .reflectionService,
+
+    // Tests etc.
+    .grpcTests,
+    .interopTestModels,
+    .interopTestImplementation,
+    .interopTests,
+    .backoffInteropTest,
+    .perfTests,
+    .grpcSampleData,
+
+    // Examples
+    .echoModel,
+    .echoImplementation,
+    .echo,
+    .helloWorldModel,
+    .helloWorldClient,
+    .helloWorldServer,
+    .routeGuideModel,
+    .routeGuideClient,
+    .routeGuideServer,
+    .packetCapture,
+    .reflectionServer,
+
+    // v2
+    .grpcCore,
+    .grpcInProcessTransport,
+    .grpcCodeGen,
+    .grpcInterceptors,
+    .grpcHTTP2Core,
+    .grpcHTTP2TransportNIOPosix,
+    .grpcHTTP2TransportNIOTransportServices,
+    .grpcProtobuf,
+    .grpcProtobufCodeGen,
+    .interoperabilityTestImplementation,
+    .interoperabilityTestsExecutable,
+    .performanceWorker,
+
+    // v2 tests
+    .grpcCoreTests,
+    .grpcInProcessTransportTests,
+    .grpcCodeGenTests,
+    .grpcInterceptorsTests,
+    .grpcHTTP2CoreTests,
+    .grpcHTTP2TransportTests,
+    .grpcProtobufTests,
+    .grpcProtobufCodeGenTests,
+    .inProcessInteroperabilityTests
+  ]
+)
+
+extension Array {
+  func appending(_ element: Element, if condition: Bool) -> [Element] {
+    if condition {
+      return self + [element]
+    } else {
+      return self
+    }
+  }
+}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 11,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1011,
-  "retainCount" : 2000,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Add_string.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 11,
-  "memoryLeaked" : 0,
-  "releaseCount" : 4012,
-  "retainCount" : 2000,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1002,
-  "retainCount" : 1001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1002,
-  "retainCount" : 1001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 2000,
-  "memoryLeaked" : 0,
-  "releaseCount" : 4002,
-  "retainCount" : 2001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1002,
-  "retainCount" : 1001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.8/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 2002000,
-  "retainCount" : 1999000,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 11,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1011,
-  "retainCount" : 2000,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Add_string.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 11,
-  "memoryLeaked" : 0,
-  "releaseCount" : 4012,
-  "retainCount" : 2000,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1002,
-  "retainCount" : 1001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1002,
-  "retainCount" : 1001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 2000,
-  "memoryLeaked" : 0,
-  "releaseCount" : 4002,
-  "retainCount" : 2001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 1002,
-  "retainCount" : 1001,
-  "syscalls" : 0
-}

+ 0 - 7
Performance/Benchmarks/Thresholds/5.9/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json

@@ -1,7 +0,0 @@
-{
-  "mallocCountTotal" : 0,
-  "memoryLeaked" : 0,
-  "releaseCount" : 2002000,
-  "retainCount" : 1999000,
-  "syscalls" : 0
-}

+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Add_binary.p90.json


+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Add_string.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Add_string.p90.json


+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_all_values.p90.json


+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_binary_values_stored.p90.json


+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_binary_values_when_only_strings_stored.p90.json


+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Iterate_string_values.p90.json


+ 0 - 0
Performance/Benchmarks/Thresholds/5.10/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json → Performance/Benchmarks/Thresholds/6.0/GRPCSwiftBenchmark.Metadata_Remove_values_for_key.p90.json


+ 3 - 3
Plugins/GRPCSwiftPlugin/plugin.swift

@@ -22,7 +22,7 @@ struct GRPCSwiftPlugin {
   /// Errors thrown by the `GRPCSwiftPlugin`
   enum PluginError: Error, CustomStringConvertible {
     /// Indicates that the target where the plugin was applied to was not `SourceModuleTarget`.
-    case invalidTarget(Target)
+    case invalidTarget(String)
     /// Indicates that the file extension of an input file was not `.proto`.
     case invalidInputFileExtension(String)
     /// Indicates that there was no configuration file at the required location.
@@ -31,7 +31,7 @@ struct GRPCSwiftPlugin {
     var description: String {
       switch self {
       case let .invalidTarget(target):
-        return "Expected a SwiftSourceModuleTarget but got '\(type(of: target))'."
+        return "Expected a SwiftSourceModuleTarget but got '\(target)'."
       case let .invalidInputFileExtension(path):
         return "The input file '\(path)' does not have a '.proto' extension."
       case let .noConfigFound(path):
@@ -259,7 +259,7 @@ extension GRPCSwiftPlugin: BuildToolPlugin {
     target: Target
   ) async throws -> [Command] {
     guard let swiftTarget = target as? SwiftSourceModuleTarget else {
-      throw PluginError.invalidTarget(target)
+      throw PluginError.invalidTarget("\(type(of: target))")
     }
     return try self.createBuildCommands(
       pluginWorkDirectory: context.pluginWorkDirectory,

+ 13 - 2
Sources/protoc-gen-grpc-swift/main.swift

@@ -14,11 +14,14 @@
  * limitations under the License.
  */
 import Foundation
-import GRPCCodeGen
-import GRPCProtobufCodeGen
 import SwiftProtobuf
 import SwiftProtobufPluginLibrary
 
+#if compiler(>=6.0)
+import GRPCCodeGen
+import GRPCProtobufCodeGen
+#endif
+
 func Log(_ message: String) {
   FileHandle.standardError.write((message + "\n").data(using: .utf8)!)
 }
@@ -168,6 +171,8 @@ func main(args: [String]) throws {
           fileNamingOption: options.fileNaming,
           generatedFiles: &generatedFiles
         )
+
+        #if compiler(>=6.0)
         if options.v2 {
           let grpcGenerator = ProtobufCodeGenerator(
             configuration: SourceGenerator.Configuration(options: options)
@@ -181,6 +186,10 @@ func main(args: [String]) throws {
           let grpcGenerator = Generator(fileDescriptor, options: options)
           grpcFile.content = grpcGenerator.code
         }
+        #else
+        let grpcGenerator = Generator(fileDescriptor, options: options)
+        grpcFile.content = grpcGenerator.code
+        #endif
         grpcFile.name = grpcFileName
         response.file.append(grpcFile)
       }
@@ -198,6 +207,7 @@ do {
   Log("ERROR: \(error)")
 }
 
+#if compiler(>=6.0)
 extension SourceGenerator.Configuration {
   init(options: GeneratorOptions) {
     let accessLevel: SourceGenerator.Configuration.AccessLevel
@@ -216,3 +226,4 @@ extension SourceGenerator.Configuration {
     )
   }
 }
+#endif

+ 4 - 0
Sources/protoc-gen-grpc-swift/options.swift

@@ -68,7 +68,9 @@ final class GeneratorOptions {
   private(set) var gRPCModuleName = "GRPC"
   private(set) var swiftProtobufModuleName = "SwiftProtobuf"
   private(set) var generateReflectionData = false
+  #if compiler(>=6.0)
   private(set) var v2 = false
+  #endif
 
   init(parameter: String?) throws {
     for pair in GeneratorOptions.parseParameter(string: parameter) {
@@ -155,12 +157,14 @@ final class GeneratorOptions {
           throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
         }
 
+      #if compiler(>=6.0)
       case "_V2":
         if let value = Bool(pair.value) {
           self.v2 = value
         } else {
           throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
         }
+      #endif
 
       default:
         throw GenerationError.unknownParameter(name: pair.key)

+ 5 - 0
scripts/license-check.sh

@@ -74,6 +74,11 @@ check_copyright_headers() {
         drop_first=1
         expected_lines=15
         ;;
+      */Package@swift-*.swift)
+        expected_sha="$SWIFT_SHA"
+        drop_first=1
+        expected_lines=15
+        ;;
       */Package@swift-*.*.swift)
         expected_sha="$SWIFT_SHA"
         drop_first=1