Forráskód Böngészése

Introduce SwiftProtobufModuleName option in protoc plugin to match the one in SwiftProtobuf plugin (#1220)

Denis Khitrik 4 éve
szülő
commit
0c1d5b7fc6

+ 1 - 1
Sources/protoc-gen-grpc-swift/Generator.swift

@@ -90,7 +90,7 @@ class Generator {
     let moduleNames = [
       self.options.gRPCModuleName,
       "NIO",
-      "SwiftProtobuf",
+      self.options.swiftProtobufModuleName,
     ]
 
     for moduleName in (moduleNames + self.options.extraModuleImports).sorted() {

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

@@ -60,6 +60,7 @@ final class GeneratorOptions {
   private(set) var fileNaming = FileNaming.FullPath
   private(set) var extraModuleImports: [String] = []
   private(set) var gRPCModuleName = "GRPC"
+  private(set) var swiftProtobufModuleName = "SwiftProtobuf"
 
   init(parameter: String?) throws {
     for pair in GeneratorOptions.parseParameter(string: parameter) {
@@ -132,6 +133,13 @@ final class GeneratorOptions {
           throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
         }
 
+      case "SwiftProtobufModuleName":
+        if !pair.value.isEmpty {
+          self.swiftProtobufModuleName = pair.value
+        } else {
+          throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value)
+        }
+
       default:
         throw GenerationError.unknownParameter(name: pair.key)
       }