vendor: Update github.com/gogo/protobuf
Also tweaks the proto definitions: - [packed=false] on the block_indexes field to retain compat with v0.14.16 and earlier. - Uses the vendored protobuf package in include paths. And, "build.go setup" will install the vendored protoc-gen-gogofast. This should ensure that a proto rebuild isn't so dependent on whatever version of the compiler and package the developer has installed... GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3864
This commit is contained in:
committed by
Audrius Butkevicius
parent
4fb9c143ac
commit
987718baf8
68
vendor/github.com/gogo/protobuf/protoc-gen-combo/combo.go
generated
vendored
68
vendor/github.com/gogo/protobuf/protoc-gen-combo/combo.go
generated
vendored
@@ -1,5 +1,7 @@
|
||||
// Copyright (c) 2013, Vastech SA (PTY) LTD. All rights reserved.
|
||||
// http://github.com/gogo/protobuf/gogoproto
|
||||
// Protocol Buffers for Go with Gadgets
|
||||
//
|
||||
// Copyright (c) 2013, The GoGo Authors. All rights reserved.
|
||||
// http://github.com/gogo/protobuf
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
@@ -44,7 +46,6 @@ type MixMatch struct {
|
||||
Old []string
|
||||
Filename string
|
||||
Args []string
|
||||
Plugins string
|
||||
}
|
||||
|
||||
func (this MixMatch) Gen(folder string, news []string) {
|
||||
@@ -68,8 +69,7 @@ func (this MixMatch) Gen(folder string, news []string) {
|
||||
if err = ioutil.WriteFile(filepath.Join(folder, this.Filename), []byte(content), 0666); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
args := append([]string{"--gogo_out=" + this.Plugins + "."}, this.Args...)
|
||||
args = append(args, filepath.Join(folder, this.Filename))
|
||||
args := append(this.Args, filepath.Join(folder, this.Filename))
|
||||
var regenerate = exec.Command("protoc", args...)
|
||||
out, err := regenerate.CombinedOutput()
|
||||
|
||||
@@ -93,27 +93,56 @@ func (this MixMatch) Gen(folder string, news []string) {
|
||||
}
|
||||
}
|
||||
|
||||
var min = flag.String("version", "2.3.0", "minimum protoc version")
|
||||
var proto_path = flag.String("proto_path", ".", "")
|
||||
var def = flag.Bool("default", true, "generate the case where everything is false")
|
||||
var plugins = flag.String("plugins", "", "--gogo_out=plugins=<plugins>:.")
|
||||
func filter(ss []string, flag string) ([]string, string) {
|
||||
s := make([]string, 0, len(ss))
|
||||
var v string
|
||||
for i := range ss {
|
||||
if strings.Contains(ss[i], flag) {
|
||||
vs := strings.Split(ss[i], "=")
|
||||
v = vs[1]
|
||||
continue
|
||||
}
|
||||
s = append(s, ss[i])
|
||||
}
|
||||
return s, v
|
||||
}
|
||||
|
||||
func filterArgs(ss []string) ([]string, []string) {
|
||||
var args []string
|
||||
var flags []string
|
||||
for i := range ss {
|
||||
if strings.Contains(ss[i], "=") {
|
||||
flags = append(flags, ss[i])
|
||||
continue
|
||||
}
|
||||
args = append(args, ss[i])
|
||||
}
|
||||
return flags, args
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if !version.AtLeast(*min) {
|
||||
flag.String("version", "2.3.0", "minimum protoc version")
|
||||
flag.Bool("default", true, "generate the case where everything is false")
|
||||
flags, args := filterArgs(os.Args[1:])
|
||||
var min string
|
||||
flags, min = filter(flags, "-version")
|
||||
if len(min) == 0 {
|
||||
min = "2.3.1"
|
||||
}
|
||||
if !version.AtLeast(min) {
|
||||
fmt.Printf("protoc version not high enough to parse this proto file\n")
|
||||
return
|
||||
}
|
||||
args := flag.Args()
|
||||
if len(args) != 1 {
|
||||
fmt.Printf("protoc-gen-combo expects a filename\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
filename := args[0]
|
||||
args = append([]string{"--proto_path=" + *proto_path})
|
||||
var def string
|
||||
flags, def = filter(flags, "-default")
|
||||
if _, err := exec.LookPath("protoc"); err != nil {
|
||||
panic("cannot find protoc in PATH")
|
||||
}
|
||||
pluginStr := ""
|
||||
if len(*plugins) > 0 {
|
||||
pluginStr = "plugins=" + *plugins + ":"
|
||||
}
|
||||
m := MixMatch{
|
||||
Old: []string{
|
||||
"option (gogoproto.unmarshaler_all) = false;",
|
||||
@@ -122,10 +151,9 @@ func main() {
|
||||
"option (gogoproto.unsafe_marshaler_all) = false;",
|
||||
},
|
||||
Filename: filename,
|
||||
Args: args,
|
||||
Plugins: pluginStr,
|
||||
Args: flags,
|
||||
}
|
||||
if *def {
|
||||
if def != "false" {
|
||||
m.Gen("./combos/neither/", []string{
|
||||
"option (gogoproto.unmarshaler_all) = false;",
|
||||
"option (gogoproto.marshaler_all) = false;",
|
||||
|
||||
Reference in New Issue
Block a user