浏览代码

Enable SwiftPM build plugin to use the new code generator plugin (#1938)

Motivation:

The SwiftPM build plugin could not be configured to use the new code generator plugin.

Modifications:

- Add a `_V2` boolean option to the SwiftPM build plugin configuration. If this option is set, it is passed to protoc-gen-grpc-swift which then uses the new code generator plugin.

Result:

The SwiftPM build plugin can now be configured use the new code generator plugin.
Clinton Nkwocha 1 年之前
父节点
当前提交
8ae00398b6
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      Plugins/GRPCSwiftPlugin/plugin.swift

+ 7 - 1
Plugins/GRPCSwiftPlugin/plugin.swift

@@ -69,6 +69,8 @@ struct GRPCSwiftPlugin {
       var reflectionData: Bool?
       /// Determines whether the casing of generated function names is kept.
       var keepMethodCasing: Bool?
+      /// Whether the invocation is for `grpc-swift` v2.
+      var _V2: Bool?
     }
 
     /// Specify the directory in which to search for
@@ -155,7 +157,7 @@ struct GRPCSwiftPlugin {
   ///   - protocPath: The path to the `protoc` binary.
   ///   - protocGenSwiftPath: The path to the `protoc-gen-swift` binary.
   ///   - outputDirectory: The output directory for the generated files.
-  ///   - importPaths: List of paths to pass with "-I <path>" to `protoc`
+  ///   - importPaths: List of paths to pass with "-I <path>" to `protoc`.
   /// - Returns: The build command configured based on the arguments
   private func invokeProtoc(
     directory: Path,
@@ -196,6 +198,10 @@ struct GRPCSwiftPlugin {
       protocArgs.append("--grpc-swift_opt=KeepMethodCasing=\(keepMethodCasingOption)")
     }
 
+    if let v2 = invocation._V2 {
+      protocArgs.append("--grpc-swift_opt=_V2=\(v2)")
+    }
+
     var inputFiles = [Path]()
     var outputFiles = [Path]()