diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -4,6 +4,7 @@ package main import ( + "errors" "os" "strings" @@ -21,6 +22,8 @@ var BUILDTIME string var sortmap map[string]string var forge *forgepb.Forge // forgepb figures out how to run protoc correctly if it's needed +var marshalKeys []string +var uniqueKeys []string func main() { pp := arg.MustParse(&argv) @@ -90,6 +93,12 @@ func main() { os.Exit(0) } + // parse sort & marshal options from the .proto file + if err := findAutogenpb(sortmap); err != nil { + log.Info("autogenpb parse error:", err) + os.Exit(-1) + } + // try to make foo.pb.go with protoc if it's not here sortmap["protoc"] = protobase + ".pb.go" if !shell.Exists(sortmap["protoc"]) { @@ -103,7 +112,7 @@ func main() { // exit here if !shell.Exists(sortmap["protoc"]) { log.Info("protoc build error.", sortmap["protoc"], "failed to be created with protoc and proto-gen-go") - os.Exit(-1) + badExit(errors.New("failed to be created with protoc and proto-gen-go")) } // add mutex @@ -118,14 +127,28 @@ func main() { if argv.NoSort { log.Info("not making sort.pb.go file (--no-sort == true)") } else { + if len(uniqueKeys) != 0 { + } makeSortfile() } if argv.NoMarshal { log.Info("not making marshal.pb.go file (--no-marshal == true)") } else { + if len(marshalKeys) != 0 { + } // make the foo.marshal.pb.go file marshal(sortmap) } } + +func okExit(s string) { + log.Info("autogenpb ok", s) + os.Exit(0) +} + +func badExit(err error) { + log.Info("autogenpb error:", err) + os.Exit(-1) +} |
