|
| 1 | +diff --git a/Sources/protoc-gen-swift/FileGenerator.swift b/Sources/protoc-gen-swift/FileGenerator.swift |
| 2 | +index d370e25..cea7bd2 100644 |
| 3 | +--- a/Sources/protoc-gen-swift/FileGenerator.swift |
| 4 | ++++ b/Sources/protoc-gen-swift/FileGenerator.swift |
| 5 | +@@ -161,6 +161,14 @@ class FileGenerator { |
| 6 | + return |
| 7 | + } |
| 8 | + |
| 9 | ++ let neededCustomImports = generatorOptions.extraModuleImports |
| 10 | ++ if !neededCustomImports.isEmpty { |
| 11 | ++ p.print() |
| 12 | ++ for i in neededCustomImports { |
| 13 | ++ p.print("import \(i)\n") |
| 14 | ++ } |
| 15 | ++ } |
| 16 | ++ |
| 17 | + p.print() |
| 18 | + generateVersionCheck(printer: &p) |
| 19 | + |
| 20 | +diff --git a/Sources/protoc-gen-swift/GeneratorOptions.swift b/Sources/protoc-gen-swift/GeneratorOptions.swift |
| 21 | +index 159e621..a8f631e 100644 |
| 22 | +--- a/Sources/protoc-gen-swift/GeneratorOptions.swift |
| 23 | ++++ b/Sources/protoc-gen-swift/GeneratorOptions.swift |
| 24 | +@@ -115,6 +115,7 @@ package class GeneratorOptions { |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | ++ let extraModuleImports: [String] |
| 29 | + let outputNaming: OutputNaming |
| 30 | + let enumGeneration: EnumGeneration |
| 31 | + let protoToModuleMappings: ProtoFileToModuleMappings |
| 32 | +@@ -146,6 +147,7 @@ package class GeneratorOptions { |
| 33 | + } |
| 34 | + |
| 35 | + package init(parameter: any CodeGeneratorParameter) throws { |
| 36 | ++ var externalModuleImports: [String] = [] |
| 37 | + var outputNaming: OutputNaming = .fullPath |
| 38 | + var enumGeneration: EnumGeneration = .none |
| 39 | + var moduleMapPath: String? |
| 40 | +@@ -238,6 +240,15 @@ package class GeneratorOptions { |
| 41 | + value: pair.value |
| 42 | + ) |
| 43 | + } |
| 44 | ++ case "ExtraModuleImports": |
| 45 | ++ if !pair.value.isEmpty { |
| 46 | ++ externalModuleImports.append(pair.value) |
| 47 | ++ } else { |
| 48 | ++ throw GenerationError.invalidParameterValue( |
| 49 | ++ name: pair.key, |
| 50 | ++ value: pair.value |
| 51 | ++ ) |
| 52 | ++ } |
| 53 | + default: |
| 54 | + throw GenerationError.unknownParameter(name: pair.key) |
| 55 | + } |
| 56 | +@@ -272,6 +283,7 @@ package class GeneratorOptions { |
| 57 | + visibilitySourceSnippet = "package " |
| 58 | + } |
| 59 | + |
| 60 | ++ self.extraModuleImports = externalModuleImports |
| 61 | + self.experimentalStripNonfunctionalCodegen = experimentalStripNonfunctionalCodegen |
| 62 | + self.experimentalHiddenNames = experimentalHiddenNames |
| 63 | + |
0 commit comments