@@ -100,10 +100,10 @@ type GeneratePluginConfig interface {
100
100
//
101
101
// This is not empty only when the plugin is local.
102
102
Path () []string
103
- // ProtocPath returns a path to protoc.
103
+ // ProtocPath returns a path to protoc, including any extra arguments .
104
104
//
105
- // This is not empty only when the plugin is protoc-builtin
106
- ProtocPath () string
105
+ // This is not empty only when the plugin is protoc-builtin.
106
+ ProtocPath () [] string
107
107
// RemoteHost returns the remote host of the remote plugin.
108
108
//
109
109
// This is not empty only when the plugin is remote.
@@ -184,7 +184,7 @@ func NewProtocBuiltinPluginConfig(
184
184
includeImports bool ,
185
185
includeWKT bool ,
186
186
strategy * GenerateStrategy ,
187
- protocPath string ,
187
+ protocPath [] string ,
188
188
) (GeneratePluginConfig , error ) {
189
189
return newProtocBuiltinPluginConfig (
190
190
name ,
@@ -229,7 +229,7 @@ type pluginConfig struct {
229
229
includeWKT bool
230
230
strategy * GenerateStrategy
231
231
path []string
232
- protocPath string
232
+ protocPath [] string
233
233
remoteHost string
234
234
revision int
235
235
}
@@ -307,14 +307,18 @@ func newPluginConfigFromExternalV1(
307
307
if err != nil {
308
308
return nil , err
309
309
}
310
+ protocPath , err := encoding .InterfaceSliceOrStringToStringSlice (externalConfig .ProtocPath )
311
+ if err != nil {
312
+ return nil , err
313
+ }
310
314
if externalConfig .Plugin != "" && bufremotepluginref .IsPluginReferenceOrIdentity (pluginIdentifier ) {
311
315
if externalConfig .Path != nil {
312
316
return nil , fmt .Errorf ("cannot specify path for remote plugin %s" , externalConfig .Plugin )
313
317
}
314
318
if externalConfig .Strategy != "" {
315
319
return nil , fmt .Errorf ("cannot specify strategy for remote plugin %s" , externalConfig .Plugin )
316
320
}
317
- if externalConfig .ProtocPath != "" {
321
+ if externalConfig .ProtocPath != nil {
318
322
return nil , fmt .Errorf ("cannot specify protoc_path for remote plugin %s" , externalConfig .Plugin )
319
323
}
320
324
return newRemotePluginConfig (
@@ -339,15 +343,15 @@ func newPluginConfigFromExternalV1(
339
343
path ,
340
344
)
341
345
}
342
- if externalConfig .ProtocPath != "" {
346
+ if externalConfig .ProtocPath != nil {
343
347
return newProtocBuiltinPluginConfig (
344
348
pluginIdentifier ,
345
349
externalConfig .Out ,
346
350
opt ,
347
351
false ,
348
352
false ,
349
353
strategy ,
350
- externalConfig . ProtocPath ,
354
+ protocPath ,
351
355
)
352
356
}
353
357
// It could be either local or protoc built-in. We defer to the plugin executor
@@ -438,9 +442,9 @@ func newPluginConfigFromExternalV2(
438
442
path ,
439
443
)
440
444
case externalConfig .ProtocBuiltin != nil :
441
- var protocPath string
442
- if externalConfig . ProtocPath != nil {
443
- protocPath = * externalConfig . ProtocPath
445
+ protocPath , err := encoding . InterfaceSliceOrStringToStringSlice ( externalConfig . ProtocPath )
446
+ if err != nil {
447
+ return nil , err
444
448
}
445
449
if externalConfig .Revision != nil {
446
450
return nil , fmt .Errorf ("cannot specify revision for protoc built-in plugin %s" , * externalConfig .ProtocBuiltin )
@@ -545,7 +549,7 @@ func newProtocBuiltinPluginConfig(
545
549
includeImports bool ,
546
550
includeWKT bool ,
547
551
strategy * GenerateStrategy ,
548
- protocPath string ,
552
+ protocPath [] string ,
549
553
) (* pluginConfig , error ) {
550
554
if includeWKT && ! includeImports {
551
555
return nil , errors .New ("cannot include well-known types without including imports" )
@@ -597,7 +601,7 @@ func (p *pluginConfig) Path() []string {
597
601
return p .path
598
602
}
599
603
600
- func (p * pluginConfig ) ProtocPath () string {
604
+ func (p * pluginConfig ) ProtocPath () [] string {
601
605
return p .protocPath
602
606
}
603
607
@@ -653,8 +657,12 @@ func newExternalGeneratePluginConfigV2FromPluginConfig(
653
657
}
654
658
case PluginConfigTypeProtocBuiltin :
655
659
externalPluginConfigV2 .ProtocBuiltin = toPointer (generatePluginConfig .Name ())
656
- if protocPath := generatePluginConfig .ProtocPath (); protocPath != "" {
657
- externalPluginConfigV2 .ProtocPath = & protocPath
660
+ if protocPath := generatePluginConfig .ProtocPath (); len (protocPath ) > 0 {
661
+ if len (protocPath ) == 1 {
662
+ externalPluginConfigV2 .ProtocPath = protocPath [0 ]
663
+ } else {
664
+ externalPluginConfigV2 .ProtocPath = protocPath
665
+ }
658
666
}
659
667
case PluginConfigTypeLocalOrProtocBuiltin :
660
668
binaryName := "protoc-gen-" + generatePluginConfig .Name ()
0 commit comments