summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-30 12:17:38 -0600
committerJeff Carr <[email protected]>2024-11-30 12:17:38 -0600
commitdc356e9d0fc6b05f50b01d141206f679ecda2de9 (patch)
treea875c8f8288f0a7292bac99176894a3b7fd07426 /main.go
parent10cf601ea03e92323d802391a437f335924e5107 (diff)
auto run protoc
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/main.go b/main.go
index a0575eb..cbff6a6 100644
--- a/main.go
+++ b/main.go
@@ -1,4 +1,6 @@
+//go:build go1.20
// +build go1.20
+
package main
import (
@@ -7,6 +9,7 @@ import (
"github.com/alexflint/go-arg"
"go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
"golang.org/x/text/cases"
"golang.org/x/text/language"
@@ -17,6 +20,7 @@ var VERSION string
var BUILDTIME string
var sortmap map[string]string
+var forge *forgepb.Forge // forgepb figures out how to run protoc correctly if it's needed
func main() {
pp := arg.MustParse(&argv)
@@ -48,7 +52,6 @@ func main() {
if !shell.Exists("go.sum") {
shell.Run([]string{"go", "mod", "init"})
shell.Run([]string{"go", "mod", "tidy"})
- shell.Run([]string{"go", "mod", "edit", "-go=1.20"})
}
cmd := []string{"go", "list", "-f", "'{{.Name}}'"}
@@ -86,6 +89,16 @@ func main() {
os.Exit(0)
}
+ sortmap["protoc"] = protobase + ".pb.go"
+ if !shell.Exists(sortmap["protoc"]) {
+ if err := protocBuild(sortmap); err != nil {
+ log.Info("protoc build error:", err)
+ os.Exit(-1)
+ }
+ os.Exit(0)
+ }
+ os.Exit(0)
+
// add mutex
if err := addMutex(sortmap); err == nil {
log.Info("adding mutex to existing protoc-gen-go file worked")